Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make remove free NULL checks (Tilman Sauerbeck)



details:   https://anonhg.NetBSD.org/src/rev/5cb3dc4503da
branches:  trunk
changeset: 813138:5cb3dc4503da
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jan 17 17:45:21 2016 +0000

description:
remove free NULL checks (Tilman Sauerbeck)

diffstat:

 usr.bin/make/arch.c   |  35 ++++++++++++++++-------------------
 usr.bin/make/compat.c |  24 +++++++++++-------------
 usr.bin/make/cond.c   |  28 +++++++++++-----------------
 usr.bin/make/job.c    |  18 +++++++-----------
 usr.bin/make/main.c   |  25 ++++++++++---------------
 usr.bin/make/make.c   |  24 +++++++++---------------
 usr.bin/make/meta.c   |  23 ++++++++---------------
 usr.bin/make/parse.c  |  15 ++++++---------
 usr.bin/make/suff.c   |  12 +++++-------
 usr.bin/make/targ.c   |  12 +++++-------
 10 files changed, 88 insertions(+), 128 deletions(-)

diffs (truncated from 709 to 300 lines):

diff -r 476f7755ae36 -r 5cb3dc4503da usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Sun Jan 17 15:59:26 2016 +0000
+++ b/usr.bin/make/arch.c       Sun Jan 17 17:45:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.66 2016/01/17 15:32:38 christos Exp $       */
+/*     $NetBSD: arch.c,v 1.67 2016/01/17 17:45:21 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.66 2016/01/17 15:32:38 christos Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.67 2016/01/17 17:45:21 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.66 2016/01/17 15:32:38 christos Exp $");
+__RCSID("$NetBSD: arch.c,v 1.67 2016/01/17 17:45:21 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -203,8 +203,7 @@
        free(Hash_GetValue(entry));
 
     free(a->name);
-    if (a->fnametab)
-       free(a->fnametab);
+    free(a->fnametab);
     Hash_DeleteTable(&a->members);
     free(a);
 }
@@ -261,8 +260,8 @@
            char        *result;
 
            result = Var_Parse(cp, ctxt, TRUE, TRUE, FALSE, &length, &freeIt);
-           if (freeIt)
-               free(freeIt);
+           free(freeIt);
+
            if (result == var_Error) {
                return(FAILURE);
            } else {
@@ -302,8 +301,8 @@
                char    *result;
 
                result = Var_Parse(cp, ctxt, TRUE, TRUE, FALSE, &length, &freeIt);
-               if (freeIt)
-                   free(freeIt);
+               free(freeIt);
+
                if (result == var_Error) {
                    return(FAILURE);
                } else {
@@ -710,8 +709,7 @@
 badarch:
     fclose(arch);
     Hash_DeleteTable(&ar->members);
-    if (ar->fnametab)
-       free(ar->fnametab);
+    free(ar->fnametab);
     free(ar);
     return NULL;
 }
@@ -996,10 +994,10 @@
     arch = ArchFindMember(Var_Value(ARCHIVE, gn, &p1),
                          Var_Value(MEMBER, gn, &p2),
                          &arh, "r+");
-    if (p1)
-       free(p1);
-    if (p2)
-       free(p2);
+
+    free(p1);
+    free(p2);
+
     snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long) now);
 
     if (arch != NULL) {
@@ -1078,10 +1076,9 @@
     arhPtr = ArchStatMember(Var_Value(ARCHIVE, gn, &p1),
                             Var_Value(MEMBER, gn, &p2),
                             TRUE);
-    if (p1)
-       free(p1);
-    if (p2)
-       free(p2);
+
+    free(p1);
+    free(p2);
 
     if (arhPtr != NULL) {
        modTime = (time_t)strtol(arhPtr->ar_date, NULL, 10);
diff -r 476f7755ae36 -r 5cb3dc4503da usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sun Jan 17 15:59:26 2016 +0000
+++ b/usr.bin/make/compat.c     Sun Jan 17 17:45:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.102 2016/01/09 00:55:17 christos Exp $    */
+/*     $NetBSD: compat.c,v 1.103 2016/01/17 17:45:21 christos Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.102 2016/01/09 00:55:17 christos Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.103 2016/01/17 17:45:21 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c   8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.102 2016/01/09 00:55:17 christos Exp $");
+__RCSID("$NetBSD: compat.c,v 1.103 2016/01/17 17:45:21 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -143,8 +143,8 @@
        if (!noExecute && eunlink(file) != -1) {
            Error("*** %s removed", file);
        }
-       if (p1)
-           free(p1);
+
+       free(p1);
 
        /*
         * Run .INTERRUPT only if hit with interrupt signal
@@ -371,10 +371,10 @@
        execError("exec", av[0]);
        _exit(1);
     }
-    if (mav)
-       free(mav);
-    if (bp)
-       free(bp);
+
+    free(mav);
+    free(bp);
+
     Lst_Replace(cmdNode, NULL);
 
 #ifdef USE_META
@@ -513,8 +513,7 @@
        if (Lst_Member(gn->iParents, pgn) != NULL) {
            char *p1;
            Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
-           if (p1)
-               free(p1);
+           free(p1);
        }
 
        /*
@@ -617,8 +616,7 @@
        if (Lst_Member(gn->iParents, pgn) != NULL) {
            char *p1;
            Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
-           if (p1)
-               free(p1);
+           free(p1);
        }
        switch(gn->made) {
            case BEINGMADE:
diff -r 476f7755ae36 -r 5cb3dc4503da usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sun Jan 17 15:59:26 2016 +0000
+++ b/usr.bin/make/cond.c       Sun Jan 17 17:45:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.72 2016/01/09 00:55:17 christos Exp $       */
+/*     $NetBSD: cond.c,v 1.73 2016/01/17 17:45:21 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.72 2016/01/09 00:55:17 christos Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.73 2016/01/17 17:45:21 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c     8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.72 2016/01/09 00:55:17 christos Exp $");
+__RCSID("$NetBSD: cond.c,v 1.73 2016/01/17 17:45:21 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -291,8 +291,7 @@
 
            cp2 = Var_Parse(cp, VAR_CMD, TRUE, TRUE, FALSE, &len, &freeIt);
            Buf_AddBytes(&buf, strlen(cp2), cp2);
-           if (freeIt)
-               free(freeIt);
+           free(freeIt);
            cp += len;
            continue;
        }
@@ -346,8 +345,8 @@
     } else {
        result = FALSE;
     }
-    if (p1)
-       free(p1);
+
+    free(p1);
     return (result);
 }
 
@@ -805,10 +804,8 @@
     }
 
 done:
-    if (lhsFree)
-       free(lhsFree);
-    if (rhsFree)
-       free(rhsFree);
+    free(lhsFree);
+    free(rhsFree);
     return t;
 }
 
@@ -848,8 +845,7 @@
      * true/false here.
      */
     length = *val ? 2 : 1;
-    if (freeIt)
-       free(freeIt);
+    free(freeIt);
     return length;
 }
 
@@ -900,8 +896,7 @@
        }
        /* Evaluate the argument using the required function. */
        t = !doEval || fn_def->fn_proc(arglen, arg);
-       if (arg)
-           free(arg);
+       free(arg);
        condExpr = cp;
        return t;
     }
@@ -933,8 +928,7 @@
      * be empty - even if it contained a variable expansion.
      */
     t = !doEval || if_info->defProc(arglen, arg) != if_info->doNot;
-    if (arg)
-       free(arg);
+    free(arg);
     return t;
 }
 
diff -r 476f7755ae36 -r 5cb3dc4503da usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sun Jan 17 15:59:26 2016 +0000
+++ b/usr.bin/make/job.c        Sun Jan 17 17:45:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.184 2016/01/17 15:32:38 christos Exp $       */
+/*     $NetBSD: job.c,v 1.185 2016/01/17 17:45:21 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.184 2016/01/17 15:32:38 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.185 2016/01/17 17:45:21 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.184 2016/01/17 15:32:38 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.185 2016/01/17 17:45:21 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -852,8 +852,7 @@
     
     DBPRINTF(cmdTemplate, cmd);
     free(cmdStart);
-    if (escCmd)
-        free(escCmd);
+    free(escCmd);
     if (errOff) {
        /*
         * If echoing is already off, there's no point in issuing the
@@ -1219,8 +1218,7 @@
             */
            Make_HandleUse(DEFAULT, gn);
            Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0);
-           if (p1)



Home | Main Index | Thread Index | Old Index