diff options
author | mmcc <mmcc@cvs.openbsd.org> | 2015-12-08 19:04:51 +0000 |
---|---|---|
committer | mmcc <mmcc@cvs.openbsd.org> | 2015-12-08 19:04:51 +0000 |
commit | e0c089060b61c713cd50b846896d34d2947e55ed (patch) | |
tree | 6446c76760759d3fdac9bec375876d0a7574ae55 | |
parent | 38b5fd1ded8c706b9b48d2321420ed88eab5b63b (diff) |
Remove NULL-checks before free(). ok tb@
-rw-r--r-- | usr.bin/calendar/day.c | 14 | ||||
-rw-r--r-- | usr.bin/calendar/io.c | 14 |
2 files changed, 10 insertions, 18 deletions
diff --git a/usr.bin/calendar/day.c b/usr.bin/calendar/day.c index f33c0accf2a..cea97096eb2 100644 --- a/usr.bin/calendar/day.c +++ b/usr.bin/calendar/day.c @@ -1,4 +1,4 @@ -/* $OpenBSD: day.c,v 1.31 2015/12/07 18:46:35 espie Exp $ */ +/* $OpenBSD: day.c,v 1.32 2015/12/08 19:04:50 mmcc Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -98,8 +98,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (ndays[i].name != NULL) - free(ndays[i].name); + free(ndays[i].name); if ((ndays[i].name = strdup(buf)) == NULL) err(1, NULL); ndays[i].len = strlen(buf); @@ -108,8 +107,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (fndays[i].name != NULL) - free(fndays[i].name); + free(fndays[i].name); if ((fndays[i].name = strdup(buf)) == NULL) err(1, NULL); fndays[i].len = strlen(buf); @@ -121,8 +119,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (nmonths[i].name != NULL) - free(nmonths[i].name); + free(nmonths[i].name); if ((nmonths[i].name = strdup(buf)) == NULL) err(1, NULL); nmonths[i].len = strlen(buf); @@ -131,8 +128,7 @@ setnnames(void) for (; l > 0 && isspace((unsigned char)buf[l - 1]); l--) ; buf[l] = '\0'; - if (fnmonths[i].name != NULL) - free(fnmonths[i].name); + free(fnmonths[i].name); if ((fnmonths[i].name = strdup(buf)) == NULL) err(1, NULL); fnmonths[i].len = strlen(buf); diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 05fe7ae5696..f17cacbd8ed 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.42 2015/10/23 12:36:23 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.43 2015/12/08 19:04:50 mmcc Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -98,8 +98,7 @@ cal(void) !strcmp(buf + 5, "by_BY.KOI8-B")) { bodun_maybe++; bodun = 0; - if (prefix) - free(prefix); + free(prefix); prefix = NULL; } else bodun_maybe = 0; @@ -124,8 +123,7 @@ cal(void) calendar = LUNAR; } else if (bodun_maybe && strncmp(buf, "BODUN=", 6) == 0) { bodun++; - if (prefix) - free(prefix); + free(prefix); if ((prefix = strdup(buf + 6)) == NULL) err(1, NULL); continue; @@ -138,8 +136,7 @@ cal(void) (p - buf == spev[i].nlen) && buf[spev[i].nlen + 1]) { p++; - if (spev[i].uname != NULL) - free(spev[i].uname); + free(spev[i].uname); if ((spev[i].uname = strdup(p)) == NULL) err(1, NULL); spev[i].ulen = strlen(p); @@ -211,8 +208,7 @@ cal(void) tmp = events; while (tmp) { events = tmp; - if (tmp->ldesc) - free(tmp->ldesc); + free(tmp->ldesc); tmp = tmp->next; free(events); } |