r110 - in trunk/varnish-cache: include lib/libvarnish

phk at projects.linpro.no phk at projects.linpro.no
Tue Apr 4 09:46:30 CEST 2006


Author: phk
Date: 2006-04-04 09:46:30 +0200 (Tue, 04 Apr 2006)
New Revision: 110

Modified:
   trunk/varnish-cache/include/cli_priv.h
   trunk/varnish-cache/include/libvarnish.h
   trunk/varnish-cache/lib/libvarnish/argv.c
   trunk/varnish-cache/lib/libvarnish/cli.c
Log:
Reverse constification of Argv functions.  After cascading through all
the CLI functions we hit the fact that the evbuffer functions in libevent
are not properly constified.

It's better to deconst the error messages and just "let it be known" that
argv[0] is const (or NULL).



Modified: trunk/varnish-cache/include/cli_priv.h
===================================================================
--- trunk/varnish-cache/include/cli_priv.h	2006-04-04 07:30:32 UTC (rev 109)
+++ trunk/varnish-cache/include/cli_priv.h	2006-04-04 07:46:30 UTC (rev 110)
@@ -11,7 +11,7 @@
 
 struct cli;	/* NB: struct cli is opaque at this level.  */
 
-typedef void cli_func_t(struct cli*, const char **av, void *priv);
+typedef void cli_func_t(struct cli*, char **av, void *priv);
 
 struct cli_proto {
 	/* These must match the CLI_* macros in cli.h */

Modified: trunk/varnish-cache/include/libvarnish.h
===================================================================
--- trunk/varnish-cache/include/libvarnish.h	2006-04-04 07:30:32 UTC (rev 109)
+++ trunk/varnish-cache/include/libvarnish.h	2006-04-04 07:46:30 UTC (rev 110)
@@ -3,8 +3,8 @@
  */
 
 /* from libvarnish/argv.c */
-void FreeArgv(const char **argv);
-const char **ParseArgv(const char *s, int comment);
+void FreeArgv(char **argv);
+char **ParseArgv(const char *s, int comment);
 
 
 /* Assert zero return value */

Modified: trunk/varnish-cache/lib/libvarnish/argv.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/argv.c	2006-04-04 07:30:32 UTC (rev 109)
+++ trunk/varnish-cache/lib/libvarnish/argv.c	2006-04-04 07:46:30 UTC (rev 110)
@@ -96,10 +96,10 @@
 	return (p);
 }
 
-const char **
+char **
 ParseArgv(const char *s, int comment)
 {
-	const char **argv;
+	char **argv;
 	const char *p;
 	int nargv, largv;
 	int i, quote;
@@ -131,7 +131,7 @@
 			if (*s == '\\') {
 				i = BackSlash(s, NULL);
 				if (i == 0) {
-					argv[0] = "Illegal backslash sequence";
+					argv[0] = (void*)(uintptr_t)"Illegal backslash sequence";
 					return (argv);
 				}
 				s += i;
@@ -146,7 +146,7 @@
 			if (*s == '"')
 				break;
 			if (*s == '\0') {
-				argv[0] = "Missing '\"'";
+				argv[0] = (void*)(uintptr_t)"Missing '\"'";
 				return (argv);
 			}
 			s++;
@@ -164,12 +164,12 @@
 }
 
 void
-FreeArgv(const char **argv)
+FreeArgv(char **argv)
 {
 	int i;
 	
 	for (i = 1; argv[i] != NULL; i++)
-		free((void *)(uintptr_t)argv[i]);
+		free(argv[i]);
 	free(argv);
 }
 

Modified: trunk/varnish-cache/lib/libvarnish/cli.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/cli.c	2006-04-04 07:30:32 UTC (rev 109)
+++ trunk/varnish-cache/lib/libvarnish/cli.c	2006-04-04 07:46:30 UTC (rev 110)
@@ -19,7 +19,7 @@
  */
 
 void
-cli_func_help(struct cli *cli, const char **av, void *priv)
+cli_func_help(struct cli *cli, char **av, void *priv)
 {
 	struct cli_proto *cp;
 
@@ -41,7 +41,7 @@
 void
 cli_dispatch(struct cli *cli, struct cli_proto *clp, const char *line)
 {
-	const char **av;
+	char **av;
 	unsigned u;
 	struct cli_proto *cp;
 




More information about the varnish-commit mailing list