Vitezslav Samel <vitezslav(a)samel.cz> writes:
gcc-4.7.0 on x86-64 spills out this warning:
src/sockaddr.c: In function "sockaddr_ntop":
src/sockaddr.c:131:4: warning: format "%u" expects argument of type
"unsigned int", but argument 3 has type
"size_t" [-Wformat]
you don't have to wrap that line; gcc warnings are fine even it is
longer; (psss, kernel do the same)
Change the "%u" format to "%zu" (available since
glibc-2.1) to prevent
this warning.
Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/sockaddr.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/sockaddr.c b/src/sockaddr.c
index 6ffc989..f5de68c 100644
--- a/src/sockaddr.c
+++ b/src/sockaddr.c
@@ -128,7 +128,7 @@ void sockaddr_ntop(struct sockaddr_storage *addr, char *buf, size_t
buflen)
if (ret == NULL) {
switch (errno) {
case ENOSPC:
- die("%s(): buffer too small (must be at least %u bytes)", __FUNCTION__,
minlen);
+ die("%s(): buffer too small (must be at least %zu bytes)", __FUNCTION__,
minlen);
case EAFNOSUPPORT:
die("%s(): Unknown address family", __FUNCTION__);
}
__FUNCTION__ is another name for __func__. Older versions of GCC
recognize only this name. However, it is not standardized. For maximum
portability, we recommend you use __func__, but provide a fallback
definition with the preprocessor:
#if __STDC_VERSION__ < 199901L
# if __GNUC__ >= 2
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#endif
applied.
--
Nikola