From 00b25227dccf095f7f90ed94dc0b8070e4d84ec9 Mon Sep 17 00:00:00 2001 From: charnier Date: Sun, 23 Jan 2000 20:25:01 +0000 Subject: Convert err() to errx(), reason is already provided. Complete the abort on allocation failure instead of deferencing NULL later. --- usr.sbin/tzsetup/tzsetup.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'usr.sbin/tzsetup/tzsetup.c') diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c index c1aafd5..a513870 100644 --- a/usr.sbin/tzsetup/tzsetup.c +++ b/usr.sbin/tzsetup/tzsetup.c @@ -216,7 +216,11 @@ read_iso3166_table(void) ":%d: country code `%s' multiply defined: %s", lineno, t, cp->name); cp->name = strdup(name); + if (cp->name == NULL) + errx(1, "malloc failed"); cp->tlc = strdup(t); + if (cp->tlc == NULL) + errx(1, "malloc failed"); } fclose(fp); @@ -245,13 +249,17 @@ add_zone_to_country(int lineno, const char *tlc, const char *descr, zp = malloc(sizeof *zp); if (zp == 0) - err(1, "malloc(%lu)", (unsigned long)sizeof *zp); + errx(1, "malloc(%lu)", (unsigned long)sizeof *zp); if (cp->nzones == 0) TAILQ_INIT(&cp->zones); zp->descr = strdup(descr); + if (zp->descr == NULL) + errx(1, "malloc failed"); zp->filename = strdup(file); + if (zp->filename == NULL) + errx(1, "malloc failed"); zp->continent = cont; TAILQ_INSERT_TAIL(&cp->zones, zp, link); cp->nzones++; @@ -264,6 +272,8 @@ add_zone_to_country(int lineno, const char *tlc, const char *descr, ":%d: zone multiply defined", lineno); cp->nzones = -1; cp->filename = strdup(file); + if (cp->filename == NULL) + errx(1, "malloc failed"); cp->continent = cont; } } @@ -390,7 +400,7 @@ make_menus(void) malloc(sizeof(dialogMenuItem) * continent_names[i].continent->nitems); if (continent_names[i].continent->menu == 0) - err(1, "malloc for continent menu"); + errx(1, "malloc for continent menu"); continent_names[i].continent->nitems = 0; } @@ -415,7 +425,7 @@ make_menus(void) } else { cp->submenu = malloc(cp->nzones * sizeof *dmi); if (cp->submenu == 0) - err(1, "malloc for submenu"); + errx(1, "malloc for submenu"); cp->nzones = 0; for (zp = cp->zones.tqh_first; zp; zp = zp->link.tqe_next) { -- cgit v1.1