Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make(1): remove useless parameter from Var_Set



details:   https://anonhg.NetBSD.org/src/rev/f9ff61759c04
branches:  trunk
changeset: 935429:f9ff61759c04
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 02 15:47:38 2020 +0000

description:
make(1): remove useless parameter from Var_Set

The enum corresponding to this int parameter is only defined in var.c,
which makes it impractical for the outside to set this parameter to
anything but 0.

On x86_64, this reduces the size of the resulting executable by 5 kB.

diffstat:

 usr.bin/make/arch.c    |  10 ++--
 usr.bin/make/compat.c  |  10 ++--
 usr.bin/make/job.c     |  14 +++---
 usr.bin/make/main.c    |  68 ++++++++++++++++++------------------
 usr.bin/make/make.c    |  22 ++++++------
 usr.bin/make/meta.c    |  30 ++++++++--------
 usr.bin/make/nonints.h |   4 +-
 usr.bin/make/parse.c   |  28 +++++++-------
 usr.bin/make/suff.c    |  40 ++++++++++----------
 usr.bin/make/var.c     |  91 ++++++++++++++++++++++++++-----------------------
 10 files changed, 162 insertions(+), 155 deletions(-)

diffs (truncated from 973 to 300 lines):

diff -r 41f8d0346b3d -r f9ff61759c04 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c       Thu Jul 02 15:26:21 2020 +0000
+++ b/usr.bin/make/arch.c       Thu Jul 02 15:47:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arch.c,v 1.71 2019/10/05 23:35:57 mrg Exp $    */
+/*     $NetBSD: arch.c,v 1.72 2020/07/02 15:47:38 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.71 2019/10/05 23:35:57 mrg Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.72 2020/07/02 15:47:38 rillig 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.71 2019/10/05 23:35:57 mrg Exp $");
+__RCSID("$NetBSD: arch.c,v 1.72 2020/07/02 15:47:38 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1205,9 +1205,9 @@
     free(libName);
 
 #ifdef LIBRARIES
-    Var_Set(TARGET, gn->name, gn, 0);
+    Var_Set(TARGET, gn->name, gn);
 #else
-    Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn, 0);
+    Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn);
 #endif /* LIBRARIES */
 }
 
diff -r 41f8d0346b3d -r f9ff61759c04 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Thu Jul 02 15:26:21 2020 +0000
+++ b/usr.bin/make/compat.c     Thu Jul 02 15:47:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.110 2020/01/19 19:42:32 riastradh Exp $   */
+/*     $NetBSD: compat.c,v 1.111 2020/07/02 15:47:38 rillig 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.110 2020/01/19 19:42:32 riastradh Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.111 2020/07/02 15:47:38 rillig 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.110 2020/01/19 19:42:32 riastradh Exp $");
+__RCSID("$NetBSD: compat.c,v 1.111 2020/07/02 15:47:38 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -547,7 +547,7 @@
 
        if (Lst_Member(gn->iParents, pgn) != NULL) {
            char *p1;
-           Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
+           Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
            free(p1);
        }
 
@@ -651,7 +651,7 @@
     } else {
        if (Lst_Member(gn->iParents, pgn) != NULL) {
            char *p1;
-           Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
+           Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
            free(p1);
        }
        switch(gn->made) {
diff -r 41f8d0346b3d -r f9ff61759c04 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Thu Jul 02 15:26:21 2020 +0000
+++ b/usr.bin/make/job.c        Thu Jul 02 15:47:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $    */
+/*     $NetBSD: job.c,v 1.199 2020/07/02 15:47:38 rillig 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.198 2020/06/19 21:17:48 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.199 2020/07/02 15:47:38 rillig 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.198 2020/06/19 21:17:48 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.199 2020/07/02 15:47:38 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1257,7 +1257,7 @@
             * .DEFAULT itself.
             */
            Make_HandleUse(DEFAULT, gn);
-           Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0);
+           Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
            free(p1);
        } else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) {
            /*
@@ -2241,11 +2241,11 @@
 void
 Job_SetPrefix(void)
 {
-    
+
     if (targPrefix) {
        free(targPrefix);
     } else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
-       Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL, 0);
+       Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL);
     }
 
     targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}",
@@ -3059,7 +3059,7 @@
        return FALSE;
 
     if (fname)
-       Var_Set(ALLSRC, fname, gn, 0);
+       Var_Set(ALLSRC, fname, gn);
 
     JobRun(gn);
     if (gn->made == ERROR) {
diff -r 41f8d0346b3d -r f9ff61759c04 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Thu Jul 02 15:26:21 2020 +0000
+++ b/usr.bin/make/main.c       Thu Jul 02 15:47:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $   */
+/*     $NetBSD: main.c,v 1.277 2020/07/02 15:47:38 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.277 2020/07/02 15:47:38 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.277 2020/07/02 15:47:38 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -462,7 +462,7 @@
                case 'B':
                        compatMake = TRUE;
                        Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
-                       Var_Set(MAKE_MODE, "compat", VAR_GLOBAL, 0);
+                       Var_Set(MAKE_MODE, "compat", VAR_GLOBAL);
                        break;
                case 'C':
                        if (chdir(argvalue) == -1) {
@@ -486,7 +486,7 @@
                        break;
                case 'D':
                        if (argvalue == NULL || argvalue[0] == 0) goto noarg;
-                       Var_Set(argvalue, "1", VAR_GLOBAL, 0);
+                       Var_Set(argvalue, "1", VAR_GLOBAL);
                        Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL);
                        Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
                        break;
@@ -585,7 +585,7 @@
                        }
                        Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
                        Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
-                       Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL, 0);
+                       Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL);
                        maxJobTokens = maxJobs;
                        break;
                case 'k':
@@ -745,7 +745,7 @@
                                      path, strerror(errno));
                } else {
                        strncpy(objdir, path, MAXPATHLEN);
-                       Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
+                       Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
                        setenv("PWD", objdir, 1);
                        Dir_InitDot();
                        purge_cached_realpaths();
@@ -870,14 +870,14 @@
                char *var = (char *)Lst_Datum(ln);
                char *value;
                char *p1;
-               
+
                if (strchr(var, '$')) {
                        value = p1 = Var_Subst(NULL, var, VAR_GLOBAL,
                            VARF_WANTRES);
                } else if (expandVars) {
                        char tmp[128];
                        int len = snprintf(tmp, sizeof(tmp), "${%s}", var);
-                                                       
+
                        if (len >= (int)sizeof(tmp))
                                Fatal("%s: variable name too big: %s",
                                    progname, var);
@@ -982,7 +982,7 @@
         */
        gettimeofday(&rightnow, NULL);
        srandom(rightnow.tv_sec + rightnow.tv_usec);
-       
+
        if ((progname = strrchr(argv[0], '/')) != NULL)
                progname++;
        else
@@ -1032,7 +1032,7 @@
            static char machine_arch_buf[sizeof(utsname.machine)];
            const int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
            size_t len = sizeof(machine_arch_buf);
-                
+
            if (sysctl(mib, __arraycount(mib), machine_arch_buf,
                    &len, NULL, 0) < 0) {
                (void)fprintf(stderr, "%s: sysctl failed (%s).\n", progname,
@@ -1061,13 +1061,13 @@
         */
        Var_Init();             /* Initialize the lists of variables for
                                 * parsing arguments */
-       Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL, 0);
-       Var_Set("MACHINE", machine, VAR_GLOBAL, 0);
-       Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0);
+       Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL);
+       Var_Set("MACHINE", machine, VAR_GLOBAL);
+       Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
 #ifdef MAKE_VERSION
-       Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0);
+       Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
 #endif
-       Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */
+       Var_Set(".newline", "\n", VAR_GLOBAL); /* handy for :@ loops */
        /*
         * This is the traditional preference for makefiles.
         */
@@ -1075,8 +1075,8 @@
 # define MAKEFILE_PREFERENCE_LIST "makefile Makefile"
 #endif
        Var_Set(MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST,
-               VAR_GLOBAL, 0);
-       Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL, 0);
+               VAR_GLOBAL);
+       Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL);
 
        create = Lst_Init(FALSE);
        makefiles = Lst_Init(FALSE);
@@ -1130,14 +1130,14 @@
                p1 = argv[0];           /* realpath failed */
            }
        }
-       Var_Set("MAKE", p1, VAR_GLOBAL, 0);
-       Var_Set(".MAKE", p1, VAR_GLOBAL, 0);
-       Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);
-       Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
-       Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
-       Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0);
+       Var_Set("MAKE", p1, VAR_GLOBAL);
+       Var_Set(".MAKE", p1, VAR_GLOBAL);
+       Var_Set(MAKEFLAGS, "", VAR_GLOBAL);
+       Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL);
+       Var_Set("MFLAGS", "", VAR_GLOBAL);
+       Var_Set(".ALLTARGETS", "", VAR_GLOBAL);
        /* some makefiles need to know this */
-       Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD, 0);
+       Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD);
 
        /*
         * Set some other useful macros
@@ -1149,11 +1149,11 @@
            if (makelevel < 0)
                makelevel = 0;
            snprintf(tmp, sizeof(tmp), "%d", makelevel);
-           Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL, 0);
+           Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL);
            snprintf(tmp, sizeof(tmp), "%u", myPid);
-           Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
+           Var_Set(".MAKE.PID", tmp, VAR_GLOBAL);
            snprintf(tmp, sizeof(tmp), "%u", getppid());



Home | Main Index | Thread Index | Old Index