Subject: Re: toolchain/22118: make won't compile with -Wcast-qual -Wstrict-prototypes and more
To: None <tech-toolchain@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-toolchain
Date: 07/14/2003 16:39:35
On Sat, 12 Jul 2003, Simon J. Gerraty wrote:
> 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.  

> -	    int len = strlen (member);
> +	    size_t len = strlen (member);

I approve of this kind of change.

> @@ -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);

This kind of change makes the code much more difficult to read.
Perhaps ArchFindMember() should be change to take a const 4th argument?

Failing that, using DISCARD_CONST("r") would be better than the r_mode[]
dance.

--apb (Alan Barrett)