]> granicus.if.org Git - procps-ng/commitdiff
w: fix printf compile warning
authorMike Frysinger <vapier@gentoo.org>
Sun, 20 May 2012 10:20:32 +0000 (06:20 -0400)
committerCraig Small <csmall@enc.com.au>
Tue, 22 May 2012 10:18:51 +0000 (20:18 +1000)
Building w on an x86_64 system triggers:
w.c:404:4: warning: format '%zu' expects argument of type 'size_t',
                    but argument 4 has type 'int' [-Wformat]

Since we're comparing UT_NAMESIZE to an int, cast it to that type
(since it can't exceed it) and update the printf.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
w.c

diff --git a/w.c b/w.c
index 4ca84debcd13008f6360542849e83630fd90e557..9c54d10240865adbb8d15837c04d0bd4a473b7e5 100644 (file)
--- a/w.c
+++ b/w.c
@@ -399,11 +399,12 @@ int main(int argc, char **argv)
 
        /* Get user field length from environment */
        if ((env_var = getenv("PROCPS_USERLEN")) != NULL) {
+               int ut_namesize = UT_NAMESIZE;
                userlen = atoi(env_var);
-               if (userlen < 8 || UT_NAMESIZE < userlen) {
+               if (userlen < 8 || ut_namesize < userlen) {
                        xwarnx
-                           (_("User length environment PROCPS_USERLEN must be between 8 and %zu, ignoring.\n"),
-                            UT_NAMESIZE);
+                           (_("User length environment PROCPS_USERLEN must be between 8 and %i, ignoring.\n"),
+                            ut_namesize);
                        userlen = 8;
                }
        }