From: Dirk-Willem van Gulik Date: Mon, 8 Oct 2001 17:51:57 +0000 (+0000) Subject: One of 2 fixes to quell a compiler warning. According to fanf@apache.org X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8e3cb38a8fc913c17270ad1cc2cd29bbce760ef;p=thirdparty%2Fapache%2Fhttpd.git One of 2 fixes to quell a compiler warning. According to fanf@apache.org > 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 --- diff --git a/src/support/htpasswd.c b/src/support/htpasswd.c index 7e262cef8e4..fecbea91bd0 100644 --- a/src/support/htpasswd.c +++ b/src/support/htpasswd.c @@ -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]);