Date: Sat, 5 Dec 2009 18:55:16 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r200136 - head/lib/libc/gen Message-ID: <200912051855.nB5ItGQa096004@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Sat Dec 5 18:55:16 2009 New Revision: 200136 URL: http://svn.freebsd.org/changeset/base/200136 Log: Remove warnings from exec.c. The entries in the argv array are not const themselves, but sometimes we want to fill in const values. Just make the array const and use __DECONST() to make it const for the execve()-call itself. Also convert the only K&R prototype to ANSI. Modified: head/lib/libc/gen/exec.c Modified: head/lib/libc/gen/exec.c ============================================================================== --- head/lib/libc/gen/exec.c Sat Dec 5 18:54:21 2009 (r200135) +++ head/lib/libc/gen/exec.c Sat Dec 5 18:55:16 2009 (r200136) @@ -54,7 +54,7 @@ int execl(const char *name, const char *arg, ...) { va_list ap; - char **argv; + const char **argv; int n; va_start(ap, arg); @@ -69,18 +69,19 @@ execl(const char *name, const char *arg, } va_start(ap, arg); n = 1; - argv[0] = (char *)arg; + argv[0] = arg; while ((argv[n] = va_arg(ap, char *)) != NULL) n++; va_end(ap); - return (_execve(name, argv, environ)); + return (_execve(name, __DECONST(char **, argv), environ)); } int execle(const char *name, const char *arg, ...) { va_list ap; - char **argv, **envp; + const char **argv; + char **envp; int n; va_start(ap, arg); @@ -95,19 +96,19 @@ execle(const char *name, const char *arg } va_start(ap, arg); n = 1; - argv[0] = (char *)arg; + argv[0] = arg; while ((argv[n] = va_arg(ap, char *)) != NULL) n++; envp = va_arg(ap, char **); va_end(ap); - return (_execve(name, argv, envp)); + return (_execve(name, __DECONST(char **, argv), envp)); } int execlp(const char *name, const char *arg, ...) { va_list ap; - char **argv; + const char **argv; int n; va_start(ap, arg); @@ -122,11 +123,11 @@ execlp(const char *name, const char *arg } va_start(ap, arg); n = 1; - argv[0] = (char *)arg; + argv[0] = arg; while ((argv[n] = va_arg(ap, char *)) != NULL) n++; va_end(ap); - return (execvp(name, argv)); + return (execvp(name, __DECONST(char **, argv))); } int @@ -145,24 +146,21 @@ execvp(const char *name, char * const *a } static int -execvPe(name, path, argv, envp) - const char *name; - const char *path; - char * const *argv; - char * const *envp; +execvPe(const char *name, const char *path, char * const *argv, + char * const *envp) { - char **memp; - int cnt, lp, ln; - char *p; + const char **memp; + size_t cnt, lp, ln; int eacces, save_errno; - char *bp, *cur, buf[MAXPATHLEN]; + char *cur, buf[MAXPATHLEN]; + const char *p, *bp; struct stat sb; eacces = 0; /* If it's an absolute or relative path name, it's easy. */ if (index(name, '/')) { - bp = (char *)name; + bp = name; cur = NULL; goto retry; } @@ -228,7 +226,8 @@ retry: (void)_execve(bp, argv, envp); memp[0] = "sh"; memp[1] = bp; bcopy(argv + 1, memp + 2, cnt * sizeof(char *)); - (void)_execve(_PATH_BSHELL, memp, envp); + (void)_execve(_PATH_BSHELL, + __DECONST(char **, memp), envp); goto done; case ENOMEM: goto done;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912051855.nB5ItGQa096004>