]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
One of 2 fixes to quell a compiler warning. According to fanf@apache.org
authorDirk-Willem van Gulik <dirkx@apache.org>
Mon, 8 Oct 2001 17:51:57 +0000 (17:51 +0000)
committerDirk-Willem van Gulik <dirkx@apache.org>
Mon, 8 Oct 2001 17:51:57 +0000 (17:51 +0000)
> Before C99 the correct way to print a size_t is to use %lu, since
> long was guaranteed to be the widest integral type, so redoing the
> fix on that basis would be better. However with C99 size_t can be
> as wide as unsigned long long so you need to use that format to
> be safe, but then you compromise portability.

So options; simply cast to (int) as I know the value is small; use %lu
without a cast - but get warnings later on >C99. Or kind of the compromize
below; do %lu but cast to be sure.

Feel free to patch in a better fix !

Dw

PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@91360 13f79535-47bb-0310-9956-ffa450edef68

src/support/htpasswd.c

index 7e262cef8e4badb1259d961d75b3b01bf1e2d320..fecbea91bd087488a8654cd2f9338d9d9db52c94 100644 (file)
@@ -193,8 +193,8 @@ static int mkrecord(char *user, char *record, size_t rlen, char *passwd,
         return usage();
 #else
        if (ap_getpass("New password: ", pwin, sizeof(pwin)) != 0) {
-           ap_snprintf(record, (rlen - 1), "password too long (>%d)",
-                       sizeof(pwin) - 1);
+           ap_snprintf(record, (rlen - 1), "password too long (>%lu)",
+                       (unsigned long) (sizeof(pwin) - 1));
            return ERR_OVERFLOW;
        }
        ap_getpass("Re-type new password: ", pwv, sizeof(pwv));
@@ -456,8 +456,8 @@ int main(int argc, char *argv[])
        }
        strcpy(pwfilename, argv[i]);
        if (strlen(argv[i + 1]) > (sizeof(user) - 1)) {
-           fprintf(stderr, "%s: username too long (>%d)\n", argv[0],
-                   sizeof(user) - 1);
+           fprintf(stderr, "%s: username too long (>%lu)\n", argv[0],
+                   (unsigned long)(sizeof(user) - 1));
            return ERR_OVERFLOW;
        }
     }
@@ -469,8 +469,8 @@ int main(int argc, char *argv[])
     }
     if (noninteractive) {
        if (strlen(argv[i + 2]) > (sizeof(password) - 1)) {
-           fprintf(stderr, "%s: password too long (>%d)\n", argv[0],
-                   sizeof(password) - 1);
+           fprintf(stderr, "%s: password too long (>%lu)\n", argv[0],
+                   (unsigned long)(sizeof(password) - 1));
            return ERR_OVERFLOW;
        }
        strcpy(password, argv[i + 2]);