Re: [PATCH] mntent: clean up gcc warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 08 October 2007, Randy Dunlap wrote:
> Mike Frysinger wrote:
> > On Monday 08 October 2007, Randy Dunlap wrote:
> >> From: Randy Dunlap <randy.dunlap@xxxxxxxxxx>
> >>
> >> Fix gcc warnings from:
> >>   (try compilation with "-Wall -Wp,-D_FORTIFY_SOURCE=2")
> >>
> >> mount_mntent.c:28: warning: pointer targets in passing argument 1 of
> >> 'strlen' differ in signedness mount_mntent.c:129: warning: pointer
> >> targets in passing argument 1 of 'mangle' differ in signedness
> >> mount_mntent.c:130: warning: pointer targets in passing argument 1 of
> >> 'mangle' differ in signedness mount_mntent.c:131: warning: pointer
> >> targets in passing argument 1 of 'mangle' differ in signedness
> >> mount_mntent.c:132: warning: pointer targets in passing argument 1 of
> >> 'mangle' differ in signedness
> >>
> >> Signed-off-by: Randy Dunlap <randy.dunlap@xxxxxxxxxx>
> >> ---
> >>  mount/mount_mntent.c |   10 +++++-----
> >>  1 file changed, 5 insertions(+), 5 deletions(-)
> >>
> >> --- util-linux-ng-2.13.orig/mount/mount_mntent.c
> >> +++ util-linux-ng-2.13/mount/mount_mntent.c
> >> @@ -25,7 +25,7 @@ mangle(const unsigned char *s) {
> >>  	char *ss, *sp;
> >>  	int n;
> >>
> >> -	n = strlen(s);
> >> +	n = strlen((const char *)s);
> >>  	ss = sp = xmalloc(4*n+1);
> >>  	while(1) {
> >>  		for (n = 0; n < sizeof(need_escaping); n++) {
> >> @@ -126,10 +126,10 @@ my_addmntent (mntFILE *mfp, struct my_mn
> >>  	if (fseek (mfp->mntent_fp, 0, SEEK_END))
> >>  		return 1;			/* failure */
> >>
> >> -	m1 = mangle(mnt->mnt_fsname);
> >> -	m2 = mangle(mnt->mnt_dir);
> >> -	m3 = mangle(mnt->mnt_type);
> >> -	m4 = mangle(mnt->mnt_opts);
> >> +	m1 = mangle((const unsigned char *)mnt->mnt_fsname);
> >> +	m2 = mangle((const unsigned char *)mnt->mnt_dir);
> >> +	m3 = mangle((const unsigned char *)mnt->mnt_type);
> >> +	m4 = mangle((const unsigned char *)mnt->mnt_opts);
> >>
> >>  	res = fprintf (mfp->mntent_fp, "%s %s %s %s %d %d\n",
> >>  		       m1, m2, m3, m4, mnt->mnt_freq, mnt->mnt_passno);
> >
> > considering mangle() works on filenames, and the signedness of such
> > strings is irrelevant, why not change it to take a "char *" instead of
> > adding ugly casts all over the place
>
> I'm not fond of the casting either, but ISTM that the real problem is in
> the top-level makefile.  This is what causes most of the problems AFAICT:
>
> AM_CFLAGS = -fsigned-char
>
> but I suppose that it has some history/baggage along with it that I don't
> know about.

i dont know the history either, but -fsigned-char is most likely not a good 
idea ... it should be punted and have the source code fixed imo

however, that wont change the fact that when a buffer is declared "char *" and 
given to "unsigned char *", you're going to get warnings ... i dont think 
that'd change anything as -fsigned-char on i386/x86_64 is redundant.

> And if mangle() just takes a "char *", casts are still needed, aren't they?

no, because the buffers would also be char *
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux