Mike Frysinger wrote:
On Monday 08 October 2007, Randy Dunlap wrote:
From: Randy Dunlap <[EMAIL PROTECTED]>

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 <[EMAIL PROTECTED]>
---
 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.

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


--
~Randy
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to