diff options
author | Patrick McLean <chutzpah@gentoo.org> | 2015-03-11 22:00:59 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2015-03-14 11:15:43 +0100 |
commit | fa6affc66e7829b56d728bb229e6c8fa628bde18 (patch) | |
tree | af0cd83cbaccfd1e73953637204140ecd6d994bd | |
parent | 246aba5ef80d8385053be9205fe8984172a9fc08 (diff) |
Fix formatting of size_t values
In several places the code used a %d format to print a size_t variable.
On amd64 at least size_t is an unsigned long, so use %lu instead.
An alternative would be to use %ud for size_t and %zd fo ssize_t but not
all platforms seem to support that formatter.
-rw-r--r-- | common/tio.c | 4 | ||||
-rw-r--r-- | nslcd/attmap.c | 4 | ||||
-rw-r--r-- | nslcd/cfg.c | 8 | ||||
-rw-r--r-- | nslcd/myldap.c | 12 |
4 files changed, 14 insertions, 14 deletions
diff --git a/common/tio.c b/common/tio.c index e00c8c8..8095dfb 100644 --- a/common/tio.c +++ b/common/tio.c @@ -478,8 +478,8 @@ int tio_close(TFILE *fp) retv = tio_flush(fp); #ifdef DEBUG_TIO_STATS /* dump statistics to stderr */ - fprintf(stderr, "DEBUG_TIO_STATS READ=%d WRITTEN=%d\n", fp->bytesread, - fp->byteswritten); + fprintf(stderr, "DEBUG_TIO_STATS READ=%lu WRITTEN=%lu\n", + (unsigned long)fp->bytesread, (unsigned long)fp->byteswritten); #endif /* DEBUG_TIO_STATS */ /* close file descriptor */ if (close(fp->fd)) diff --git a/nslcd/attmap.c b/nslcd/attmap.c index d024a59..5aad41f 100644 --- a/nslcd/attmap.c +++ b/nslcd/attmap.c @@ -276,8 +276,8 @@ const char *attmap_get_value(MYLDAP_ENTRY *entry, const char *attr, return NULL; if (strlen(values[0]) >= buflen) { - log_log(LOG_ERR, "attmap_get_value(): buffer too small (%d required)", - strlen(values[0])); + log_log(LOG_ERR, "attmap_get_value(): buffer too small (%lu required)", + (unsigned long) strlen(values[0])); return NULL; } strncpy(buffer, values[0], buflen); diff --git a/nslcd/cfg.c b/nslcd/cfg.c index 4928244..cec1b0c 100644 --- a/nslcd/cfg.c +++ b/nslcd/cfg.c @@ -457,8 +457,8 @@ static void add_uris_from_dns(const char *filename, int lnr, hostlist[strlen(hostlist) - 4] = '\0'; if (mysnprintf(buf, sizeof(buf), "ldaps://%s", hostlist)) { - log_log(LOG_ERR, "add_uris_from_dns(): buf buffer too small (%d required)", - strlen(hostlist) + 8); + log_log(LOG_ERR, "add_uris_from_dns(): buf buffer too small (%lu required)", + (unsigned long) strlen(hostlist) + 8); exit(EXIT_FAILURE); } } @@ -469,8 +469,8 @@ static void add_uris_from_dns(const char *filename, int lnr, hostlist[strlen(hostlist) - 4] = '\0'; if (mysnprintf(buf, sizeof(buf), "ldap://%s", hostlist)) { - log_log(LOG_ERR, "add_uris_from_dns(): buf buffer too small (%d required)", - strlen(hostlist) + 7); + log_log(LOG_ERR, "add_uris_from_dns(): buf buffer too small (%lu required)", + (unsigned long) strlen(hostlist) + 7); exit(EXIT_FAILURE); } } diff --git a/nslcd/myldap.c b/nslcd/myldap.c index d7adad3..8fe0bd9 100644 --- a/nslcd/myldap.c +++ b/nslcd/myldap.c @@ -1064,15 +1064,15 @@ int myldap_set_credentials(MYLDAP_SESSION *session, const char *dn, if (strlen(dn) >= sizeof(session->binddn)) { log_log(LOG_ERR, - "myldap_set_credentials(): binddn buffer too small (%d required)", - strlen(dn)); + "myldap_set_credentials(): binddn buffer too small (%lu required)", + (unsigned long) strlen(dn)); return -1; } if (strlen(password) >= sizeof(session->bindpw)) { log_log(LOG_ERR, - "myldap_set_credentials(): bindpw buffer too small (%d required)", - strlen(password)); + "myldap_set_credentials(): bindpw buffer too small (%lu required)", + (unsigned long) strlen(password)); return -1; } /* copy dn and password into session */ @@ -1729,8 +1729,8 @@ static char **myldap_get_ranged_values(MYLDAP_ENTRY *entry, const char *attr) /* build the attribute name to find */ if (mysnprintf(attbuf, sizeof(attbuf), "%s;range=0-*", attr)) { - log_log(LOG_ERR, "myldap_get_ranged_values(): attbuf buffer too small (%d required)", - strlen(attr) + 10); + log_log(LOG_ERR, "myldap_get_ranged_values(): attbuf buffer too small (%lu required)", + (unsigned long) strlen(attr) + 10); return NULL; } /* keep doing lookups untul we can't get any more results */ |