[procps] [PATCH] w: fix printf compile warning

  • From: Mike Frysinger <vapier@xxxxxxxxxx>
  • To: procps@xxxxxxxxxxxxx
  • Date: Sun, 20 May 2012 06:20:32 -0400

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@xxxxxxxxxx>
---
 w.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/w.c b/w.c
index 4ca84de..9c54d10 100644
--- 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;
                }
        }
-- 
1.7.8.6


Other related posts:

  • » [procps] [PATCH] w: fix printf compile warning - Mike Frysinger