Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: None <tech-toolchain@netbsd.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 07/12/2003 00:59:18
After getting sick of this, I found a freebsd 4.8 tree and checked how
they are building make - no -W flags at all.   So I've tweaked
bmake/Makefile.in to only set WARNS on NetBSD - immediate problem
solved.

Now is it worth actually trying to fix our make to be const correct
etc?  The diffs below are just a sample of the sort of changes needed.  
I'm adding -W -Wcast-qual -Wstrict-prototypes -Wwrite-strings to CFLAGS

Should I back these out or soldier on?


--sjg

Index: arch.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/arch.c,v
retrieving revision 1.36
diff -u -r1.36 arch.c
--- arch.c	2003/06/02 21:49:00	1.36
+++ arch.c	2003/07/12 00:16:19
@@ -530,7 +530,7 @@
 	} else {
 	    /* Try truncated name */
 	    char copy[AR_MAX_NAME_LEN+1];
-	    int len = strlen (member);
+	    size_t len = strlen (member);
 
 	    if (len > AR_MAX_NAME_LEN) {
 		len = AR_MAX_NAME_LEN;
@@ -552,8 +552,9 @@
 	 * so just declare it static.
 	 */
 	 static struct ar_hdr	sarh;
+	 char r_mode[] = "r";
 
-	 arch = ArchFindMember(archive, member, &sarh, "r");
+	 arch = ArchFindMember(archive, member, &sarh, r_mode);
 
 	 if (arch == (FILE *)NULL) {
 	    return ((struct ar_hdr *)NULL);
@@ -823,7 +824,7 @@
     int		  size;       /* Size of archive member */
     char	  *cp;	      /* Useful character pointer */
     char	  magic[SARMAG];
-    int		  len, tlen;
+    size_t	  len, tlen;
 
     arch = fopen (archive, mode);
     if (arch == (FILE *) NULL) {
@@ -964,11 +965,12 @@
 {
     FILE *	  arch;	  /* Stream open to archive, positioned properly */
     struct ar_hdr arh;	  /* Current header describing member */
+    char ra_mode[] = "r+";
     char *p1, *p2;
 
     arch = ArchFindMember(Var_Value (ARCHIVE, gn, &p1),
 			  Var_Value (MEMBER, gn, &p2),
-			  &arh, "r+");
+			  &arh, ra_mode);
     if (p1)
 	free(p1);
     if (p2)
@@ -1000,7 +1002,7 @@
  *-----------------------------------------------------------------------
  */
 void
-Arch_TouchLib(GNode *gn)
+Arch_TouchLib(GNode *gn UNUSED)
 {
 #ifdef RANLIBMAG
     FILE *	    arch;	/* Stream open to archive */
Index: compat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/compat.c,v
retrieving revision 1.44
diff -u -r1.44 compat.c
--- compat.c	2002/06/15 18:24:56	1.44
+++ compat.c	2003/07/12 00:16:20
@@ -259,7 +259,7 @@
 	 * -e flag as well as -c if it's supposed to exit when it hits an
 	 * error.
 	 */
-	static char	*shargv[4] = { _PATH_BSHELL };
+	static const char	*shargv[4] = { _PATH_BSHELL };
 
 	if (DEBUG(SHELL))
 		shargv[1] = (errCheck ? "-exc" : "-xc");
@@ -267,7 +267,7 @@
 		shargv[1] = (errCheck ? "-ec" : "-c");
 	shargv[2] = cmd;
 	shargv[3] = (char *)NULL;
-	av = shargv;
+	av = DISCARD_CONST(shargv);
 	argc = 0;
 	bp = NULL;
     } else {
@@ -549,6 +549,7 @@
     char    	  *cp;	    /* Pointer to string of shell meta-characters */
     GNode   	  *gn = NULL;/* Current root target */
     int	    	  errors;   /* Number of targets not remade due to errors */
+    char shell_meta[] = "#=|^(){};&<>*?[]:$`\\\n";
 
     if (signal(SIGINT, SIG_IGN) != SIG_IGN) {
 	signal(SIGINT, CompatInterrupt);
@@ -563,7 +564,7 @@
 	signal(SIGQUIT, CompatInterrupt);
     }
 
-    for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
+    for (cp = shell_meta; *cp != '\0'; cp++) {
 	meta[(unsigned char) *cp] = 1;
     }
     /*
Index: cond.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/cond.c,v
retrieving revision 1.15
diff -u -r1.15 cond.c
--- cond.c	2003/04/17 15:57:52	1.15
+++ cond.c	2003/07/12 00:16:21
@@ -107,7 +107,7 @@
  * last two fields are stored in condInvert and condDefProc, respectively.
  */
 static void CondPushBack(Token);
-static int CondGetArg(char **, char **, char *, Boolean);
+static int CondGetArg(char **, char **, const char *, Boolean);
 static Boolean CondDoDefined(int, char *);
 static int CondStrMatch(ClientData, ClientData);
 static Boolean CondDoMake(int, char *);
@@ -121,7 +121,7 @@
 static Token CondE(Boolean);
 
 static struct If {
-    char	*form;	      /* Form of if */
+    const char	*form;	      /* Form of if */
     int		formlen;      /* Length of form */
     Boolean	doNot;	      /* TRUE if default function should be negated */
     Boolean	(*defProc)(int, char *); /* Default function to apply */
@@ -189,7 +189,7 @@
  *-----------------------------------------------------------------------
  */
 static int
-CondGetArg(char **linePtr, char **argPtr, char *func, Boolean parens)
+CondGetArg(char **linePtr, char **argPtr, const char *func, Boolean parens)
 {
     char	  *cp;
     int	    	  argLen;
@@ -552,6 +552,8 @@
 		char	*lhs;
 		char	*rhs;
 		char	*op;
+		char	default_op[] = "!=";
+		char	default_rhs[] = "0";
 		int	varSpecLen;
 		Boolean	doFree;
 
@@ -618,8 +620,8 @@
 			}
 			break;
 		    default:
-			op = "!=";
-			rhs = "0";
+			op = default_op;
+			rhs = default_rhs;
 
 			goto do_compare;
 		}
Index: dir.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/dir.c,v
retrieving revision 1.35
diff -u -r1.35 dir.c
--- dir.c	2002/11/26 06:12:59	1.35
+++ dir.c	2003/07/12 00:16:22
@@ -825,7 +825,7 @@
  *-----------------------------------------------------------------------
  */
 static char *
-DirLookup(Path *p, char *name, char *cp, Boolean hasSlash)
+DirLookup(Path *p, char *name UNUSED, char *cp, Boolean hasSlash UNUSED)
 {
     char *file;		/* the current filename to check */
 
@@ -926,6 +926,7 @@
 {
 	char *p1;		/* pointer into p->name */
 	char *p2;		/* pointer into name */
+	static char empty[] = "";
 
 	if (DEBUG(DIR)) {
 		printf("%s...", p->name);
@@ -949,7 +950,7 @@
 			printf("must be here but isn't -- returning\n");
 		}
 		/* Return empty string: terminates search */
-		return "";
+		return empty;
 	}
 
 	if (DEBUG(DIR)) {
@@ -977,7 +978,7 @@
  *-----------------------------------------------------------------------
  */
 static char *
-DirFindDot(Boolean hasSlash, char *name, char *cp)
+DirFindDot(Boolean hasSlash UNUSED, char *name, char *cp)
 {
 
 	if (Hash_FindEntry (&dot->files, cp) != (Hash_Entry *)NULL) {
@@ -1398,7 +1399,7 @@
     struct dirent *dp;	      /* entry in directory */
 
     if (strcmp(name, ".DOTLAST") == 0) {
-	ln = Lst_Find (path, (ClientData)name, DirFindName);
+	ln = Lst_Find (path, (ClientData)DISCARD_CONST(name), DirFindName);
 	if (ln != NILLNODE)
 	    return (Path *) Lst_Datum(ln);
 	else {
@@ -1408,7 +1409,7 @@
     }
 
     if (path)
-	ln = Lst_Find (openDirectories, (ClientData)name, DirFindName);
+	ln = Lst_Find (openDirectories, (ClientData)DISCARD_CONST(name), DirFindName);
     if (ln != NILLNODE) {
 	p = (Path *)Lst_Datum (ln);
 	if (Lst_Member(path, (ClientData)p) == NILLNODE) {
Index: for.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/for.c,v
retrieving revision 1.13
diff -u -r1.13 for.c
--- for.c	2002/06/15 18:24:56	1.13
+++ for.c	2003/07/12 00:16:23
@@ -117,7 +117,7 @@
 	int varlen;
 
 	buf = Buf_Init(0);
-	Buf_AddBytes(buf, len, (Byte *) data);
+	Buf_AddBytes(buf, len, (const Byte *) data);
 
 	accumFor.nvars++;
 	accumFor.vars = erealloc(accumFor.vars, accumFor.nvars*sizeof(char *));
Index: hash.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/hash.c,v
retrieving revision 1.10
diff -u -r1.10 hash.c
--- hash.c	2002/06/15 18:24:56	1.10
+++ hash.c	2003/07/12 00:16:23
@@ -184,11 +184,11 @@
  */
 
 Hash_Entry *
-Hash_FindEntry(Hash_Table *t, char *key)
+Hash_FindEntry(Hash_Table *t, const char *key)
 {
 	Hash_Entry *e;
 	unsigned h;
-	char *p;
+	const char *p;
 
 	for (h = 0, p = key; *p;)
 		h = (h << 5) - h + *p++;
Index: hash.h
===================================================================
RCS file: /cvsroot/src/usr.bin/make/hash.h,v
retrieving revision 1.6
diff -u -r1.6 hash.h
--- hash.h	2002/06/15 18:24:56	1.6
+++ hash.h	2003/07/12 00:16:23
@@ -109,7 +109,7 @@
 
 void Hash_InitTable(Hash_Table *, int);
 void Hash_DeleteTable(Hash_Table *);
-Hash_Entry *Hash_FindEntry(Hash_Table *, char *);
+Hash_Entry *Hash_FindEntry(Hash_Table *, const char *);
 Hash_Entry *Hash_CreateEntry(Hash_Table *, char *, Boolean *);
 void Hash_DeleteEntry(Hash_Table *, Hash_Entry *);
 Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *);
Index: job.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/job.c,v
retrieving revision 1.76
diff -u -r1.76 job.c
--- job.c	2003/04/08 17:46:59	1.76
+++ job.c	2003/07/12 00:16:26
@@ -223,7 +223,7 @@
 						   * commands in the Makefile.
 						   * It is set by the
 						   * Job_ParseShell function */
-static char   	*shellPath = NULL,		  /* full pathname of
+static const char *shellPath = NULL,		  /* full pathname of
 						   * executable image */
                	*shellName = NULL,	      	  /* last component of shell */
 		*shellArgv = NULL;		  /* Custom shell args */
@@ -254,7 +254,7 @@
 
 STATIC GNode   	*lastNode;	/* The node for which output was most recently
 				 * produced. */
-STATIC char    	*targFmt;   	/* Format string to use to head output from a
+STATIC const char    	*targFmt;   	/* Format string to use to head output from a
 				 * job when it's not the most-recent job heard
 				 * from */
 static Job tokenWaitJob;	/* token wait pseudo-job */
@@ -424,7 +424,7 @@
  *-----------------------------------------------------------------------
  */
 static void
-JobChildSig(int signo)
+JobChildSig(int signo UNUSED)
 {
     write(exit_pipe[1], ".", 1);
 }
@@ -448,7 +448,7 @@
  *-----------------------------------------------------------------------
  */
 static void
-JobContinueSig(int signo)
+JobContinueSig(int signo UNUSED)
 {
     JobRestartJobs();
 }
@@ -629,13 +629,13 @@
     Boolean	  errOff = FALSE;   /* true if we turned error checking
 				     * off before printing the command
 				     * and need to turn it back on */
-    char       	  *cmdTemplate;	    /* Template to use when printing the
+    const char    *cmdTemplate;	    /* Template to use when printing the
 				     * command */
     char    	  *cmdStart;	    /* Start of expanded command */
     char     	  *cmd = (char *) cmdp;
     Job           *job = (Job *) jobp;
     char	*cp;
-    
+
     noSpecials = NoExecute(job->node);
 
     if (strcmp(cmd, "...") == 0) {
@@ -1224,7 +1224,7 @@
  *-----------------------------------------------------------------------
  */
 Boolean
-Job_CheckCommands(GNode *gn, void (*abortProc)(char *, ...))
+Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))
 {
     if (OP_NOP(gn->type) && Lst_IsEmpty(gn->commands) &&
 	((gn->type & OP_LIB) == 0 || Lst_IsEmpty(gn->children))) {
@@ -1520,7 +1520,7 @@
     int	    	  argc;
     static char	  args[10]; 	/* For merged arguments */
 
-    argv[0] = shellName;
+    argv[0] = DISCARD_CONST(shellName);
     argc = 1;
 
     if ((commandShell->exit && (*commandShell->exit != '-')) ||
@@ -1544,11 +1544,11 @@
 	}
     } else {
 	if (!(job->flags & JOB_IGNERR) && commandShell->exit) {
-	    argv[argc] = commandShell->exit;
+	    argv[argc] = DISCARD_CONST(commandShell->exit);
 	    argc++;
 	}
 	if (!(job->flags & JOB_SILENT) && commandShell->echo) {
-	    argv[argc] = commandShell->echo;
+	    argv[argc] = DISCARD_CONST(commandShell->echo);
 	    argc++;
 	}
     }
Index: job.h
===================================================================
RCS file: /cvsroot/src/usr.bin/make/job.h,v
retrieving revision 1.17
diff -u -r1.17 job.h
--- job.h	2002/11/16 22:22:23	1.17
+++ job.h	2003/07/12 00:16:26
@@ -207,28 +207,28 @@
  * anyway as is and if it causes an error, so be it.
  */
 typedef struct Shell {
-    char	  *name;	/* the name of the shell. For Bourne and C
+    const char	  *name;	/* the name of the shell. For Bourne and C
 				 * shells, this is used only to find the
 				 * shell description when used as the single
 				 * source of a .SHELL target. For user-defined
 				 * shells, this is the full path of the shell.
 				 */
     Boolean 	  hasEchoCtl;	/* True if both echoOff and echoOn defined */
-    char          *echoOff;	/* command to turn off echo */
-    char          *echoOn;	/* command to turn it back on again */
-    char          *noPrint;	/* command to skip when printing output from
+    const char    *echoOff;	/* command to turn off echo */
+    const char    *echoOn;	/* command to turn it back on again */
+    const char    *noPrint;	/* command to skip when printing output from
 				 * shell. This is usually the command which
 				 * was executed to turn off echoing */
     int           noPLen;	/* length of noPrint command */
     Boolean	  hasErrCtl;	/* set if can control error checking for
 				 * individual commands */
-    char	  *errCheck;	/* string to turn error checking on */
-    char	  *ignErr;	/* string to turn off error checking */
+    const char	  *errCheck;	/* string to turn error checking on */
+    const char	  *ignErr;	/* string to turn off error checking */
     /*
      * command-line flags
      */
-    char          *echo;	/* echo commands */
-    char          *exit;	/* exit on error */
+    const char    *echo;	/* echo commands */
+    const char    *exit;	/* exit on error */
 }               Shell;
 
 extern int	job_pipe[2];	/* token pipe for jobs. */
@@ -252,7 +252,7 @@
 #endif
 
 void Job_Touch(GNode *, Boolean);
-Boolean Job_CheckCommands(GNode *, void (*abortProc )(char *, ...));
+Boolean Job_CheckCommands(GNode *, void (*abortProc )(const char *, ...));
 void Job_CatchChildren(Boolean);
 void Job_CatchOutput(void);
 void Job_Make(GNode *);
Index: main.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/main.c,v
retrieving revision 1.88
diff -u -r1.88 main.c
--- main.c	2003/05/10 19:21:40	1.88
+++ main.c	2003/07/12 00:16:28
@@ -155,6 +155,8 @@
 
 Boolean forceJobs = FALSE;
 
+const_glue_t const_glue;		/* needed by DISCARD_CONST() */
+
 extern Lst parseIncPath;
 
 /*-
@@ -1340,7 +1342,7 @@
  */
 /* VARARGS */
 void
-Error(char *fmt, ...)
+Error(const char *fmt, ...)
 {
 	va_list ap;
 
@@ -1365,7 +1367,7 @@
  */
 /* VARARGS */
 void
-Fatal(char *fmt, ...)
+Fatal(const char *fmt, ...)
 {
 	va_list ap;
 
@@ -1400,7 +1402,7 @@
  */
 /* VARARGS */
 void
-Punt(char *fmt, ...)
+Punt(const char *fmt, ...)
 {
 	va_list ap;
 
@@ -1582,7 +1584,7 @@
 
 
 void
-PrintOnError(char *s)
+PrintOnError(const char *s)
 {
     char tmp[64];
 	
Index: make.h
===================================================================
RCS file: /cvsroot/src/usr.bin/make/make.h,v
retrieving revision 1.45
diff -u -r1.45 make.h
--- make.h	2003/03/14 05:19:43	1.45
+++ make.h	2003/07/12 00:16:28
@@ -387,6 +387,26 @@
 #define	DEBUG(module)	(debug & CONCAT(DEBUG_,module))
 
 /*
+ * Welcome to const correctness hell...
+ * This is better done with a static inline
+ */
+typedef union const_glue_u {
+	const void * cg_cvp;
+	void * cg_vp;
+} const_glue_t;
+extern const_glue_t const_glue;
+
+#define DISCARD_CONST(expr) ( const_glue.cg_cvp = expr, const_glue.cg_vp )
+
+#ifndef UNUSED
+# ifdef __GNUC__
+#   define UNUSED __attribute__ ((unused))
+# else
+#   define UNUSED
+# endif
+#endif
+
+/*
  * Since there are so many, all functions that return non-integer values are
  * extracted by means of a sed script or two and stuck in the file "nonints.h"
  */
@@ -400,9 +420,9 @@
 void Make_Update(GNode *);
 void Make_DoAllVar(GNode *);
 Boolean Make_Run(Lst);
-char * Check_Cwd_Cmd(char *);
+char * Check_Cwd_Cmd(const char *);
 void Check_Cwd(char **);
-void PrintOnError(char *);
+void PrintOnError(const char *);
 void Main_ExportMAKEFLAGS(Boolean);
 Boolean Main_SetObjdir(const char *);
 
Index: nonints.h
===================================================================
RCS file: /cvsroot/src/usr.bin/make/nonints.h,v
retrieving revision 1.27
diff -u -r1.27 nonints.h
--- nonints.h	2002/06/15 18:24:57	1.27
+++ nonints.h	2003/07/12 00:16:28
@@ -73,10 +73,10 @@
 void Main_ParseArgLine(char *);
 int main(int, char **);
 char *Cmd_Exec(char *, char **);
-void Error(char *, ...) __attribute__((__format__(__printf__, 1, 2)));
-void Fatal(char *, ...)
+void Error(const char *, ...) __attribute__((__format__(__printf__, 1, 2)));
+void Fatal(const char *, ...)
     __attribute__((__format__(__printf__, 1, 2),__noreturn__));
-void Punt(char *, ...)
+void Punt(const char *, ...)
     __attribute__((__format__(__printf__, 1, 2),__noreturn__));
 void DieHorribly(void) __attribute__((__noreturn__));
 int PrintAddr(ClientData, ClientData);
@@ -89,7 +89,7 @@
 void execError(const char *, const char *);
 
 /* parse.c */
-void Parse_Error(int, char *, ...)
+void Parse_Error(int, const char *, ...)
      __attribute__((__format__(__printf__, 2, 3)));
 Boolean Parse_AnyExport(void);
 Boolean Parse_IsVar(char *);
@@ -102,9 +102,9 @@
 Lst Parse_MainName(void);
 
 /* str.c */
-char *str_concat(char *, char *, int);
+char *str_concat(const char *, const char *, int);
 char **brk_string(char *, int *, Boolean, char **);
-char *Str_FindSubstring(char *, char *);
+char *Str_FindSubstring(char *, const char *);
 int Str_Match(char *, char *);
 char *Str_SYSVMatch(char *, char *, int *len);
 void Str_SYSVSubst(Buffer, char *, char *, int);
@@ -130,7 +130,7 @@
 void Targ_End(void);
 Lst Targ_List(void);
 GNode *Targ_NewGN(char *);
-GNode *Targ_FindNode(char *, int);
+GNode *Targ_FindNode(const char *, int);
 Lst Targ_FindList(Lst, int);
 Boolean Targ_Ignore(GNode *);
 Boolean Targ_Silent(GNode *);
@@ -143,11 +143,11 @@
 void Targ_Propagate(void);
 
 /* var.c */
-void Var_Delete(char *, GNode *);
-void Var_Set(char *, char *, GNode *, int);
-void Var_Append(char *, char *, GNode *);
+void Var_Delete(const char *, GNode *);
+void Var_Set(const char *, char *, GNode *, int);
+void Var_Append(const char *, char *, GNode *);
 Boolean Var_Exists(char *, GNode *);
-char *Var_Value(char *, GNode *, char **);
+char *Var_Value(const char *, GNode *, char **);
 char *Var_Parse(char *, GNode *, Boolean, int *, Boolean *);
 char *Var_Subst(char *, char *, GNode *, Boolean);
 char *Var_GetTail(char *);
Index: parse.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/parse.c,v
retrieving revision 1.92
diff -u -r1.92 parse.c
--- parse.c	2003/03/23 22:48:35	1.92
+++ parse.c	2003/07/12 00:16:31
@@ -443,7 +443,7 @@
  */
 /* VARARGS */
 void
-Parse_Error(int type, char *fmt, ...)
+Parse_Error(int type, const char *fmt, ...)
 {
 	va_list ap;
 
Index: str.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/str.c,v
retrieving revision 1.18
diff -u -r1.18 str.c
--- str.c	2002/06/15 18:24:57	1.18
+++ str.c	2003/07/12 00:16:31
@@ -62,7 +62,7 @@
  *	the resulting string in allocated space.
  */
 char *
-str_concat(char *s1, char *s2, int flags)
+str_concat(const char *s1, const char *s2, int flags)
 {
 	int len1, len2;
 	char *result;
@@ -239,7 +239,7 @@
  * Side effects: None.
  */
 char *
-Str_FindSubstring(char *string, char *substring)
+Str_FindSubstring(char *string, const char *substring)
 {
 	char *a, *b;
 
Index: targ.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/targ.c,v
retrieving revision 1.28
diff -u -r1.28 targ.c
--- targ.c	2002/06/15 18:24:58	1.28
+++ targ.c	2003/07/12 00:16:32
@@ -296,7 +296,7 @@
  *-----------------------------------------------------------------------
  */
 GNode *
-Targ_FindNode(char *name, int flags)
+Targ_FindNode(const char *name, int flags)
 {
     GNode         *gn;	      /* node in that element */
     Hash_Entry	  *he;	      /* New or used hash entry for node */
Index: var.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/var.c,v
retrieving revision 1.72
diff -u -r1.72 var.c
--- var.c	2003/05/22 18:20:10	1.72
+++ var.c	2003/07/12 00:16:33
@@ -247,7 +247,7 @@
  *-----------------------------------------------------------------------
  */
 static Var *
-VarFind(char *name, GNode *ctxt, int flags)
+VarFind(const char *name, GNode *ctxt, int flags)
 {
     Hash_Entry         	*var;
     Var		  	*v;
@@ -393,7 +393,7 @@
  *-----------------------------------------------------------------------
  */
 void
-Var_Delete(char *name, GNode *ctxt)
+Var_Delete(const char *name, GNode *ctxt)
 {
     Hash_Entry 	  *ln;
 
@@ -440,7 +440,7 @@
  *-----------------------------------------------------------------------
  */
 void
-Var_Set(char *name, char *val, GNode *ctxt, int flags)
+Var_Set(const char *name, char *val, GNode *ctxt, int flags)
 {
     Var   *v;
     char *cp = name;
@@ -514,7 +514,7 @@
  *-----------------------------------------------------------------------
  */
 void
-Var_Append(char *name, char *val, GNode *ctxt)
+Var_Append(const char *name, char *val, GNode *ctxt)
 {
     Var		   *v;
     Hash_Entry	   *h;
@@ -605,7 +605,7 @@
  *-----------------------------------------------------------------------
  */
 char *
-Var_Value(char *name, GNode *ctxt, char **frp)
+Var_Value(const char *name, GNode *ctxt, char **frp)
 {
     Var            *v;