Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Aug 2001 13:40:23 +0100
From:      Mark Murray <mark@grondar.za>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        audit@FreeBSD.ORG
Subject:   Re: [patch] su(1) WARNS=2 cleanup 
Message-ID:  <200108081240.f78CeNf03323@grimreaper.grondar.za>
In-Reply-To: <20010808165645.W5697-100000@besplex.bde.org> ; from Bruce Evans <bde@zeta.org.au>  "Wed, 08 Aug 2001 17:21:33 %2B1000."
References:  <20010808165645.W5697-100000@besplex.bde.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > -		execv(shell, np);
> > +		execv(shell, (char * const *)np);
> 
> Style bug: bogus cast.  execve(2)'s second parameter has type
> "char * const *".  Conversion of np's type "(char **)" is automatic in C.

I'm having a problem unravelling this.

With np declared as "const char **", the other (bogus) casts can be
removed, but gcc whines about execv(2):

cc -O -pipe    -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Werror -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow  -c /usr/src/usr.bin/su/su.c
cc1: warnings being treated as errors
/usr/src/usr.bin/su/su.c: In function `main':
/usr/src/usr.bin/su/su.c:395: warning: passing arg 2 of `execv' from incompatible pointer type
*** Error code 1

If I try to cast arg 2 like:

                execv(shell, (const char * const *)np);

I get from gcc:

cc -O -pipe    -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wno-uninitialized -Werror -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow  -c /usr/src/usr.bin/su/su.c
cc1: warnings being treated as errors
/usr/src/usr.bin/su/su.c: In function `main':
/usr/src/usr.bin/su/su.c:395: warning: passing arg 2 of `execv' from incompatible pointer type
*** Error code 1

Playing with "const" in various parts of the const ony ever gets one of the
above warning/errors.

Hints? GCC bug?

M
-- 
Mark Murray
Warning: this .sig is umop ap!sdn

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108081240.f78CeNf03323>