Date: Sun, 17 Nov 2002 13:22:10 +0100 From: Johan Karlsson <johan@freebsd.org> To: freebsd-audit@freebsd.org Cc: Sheldon Hearn <sheldonh@starjuice.net>, ken@freebsd.org Subject: removing print format warnings using PRIu64 from inttypes.h Message-ID: <20021117122210.GB746@numeri.campus.luth.se>
next in thread | raw e-mail | index | archive | help
--4bRzO86E/ozDv8r1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi I'm trying to remove warnings from sbin/* and among other warnings there are print format warnigs on alpha/sparc64. cc -O -pipe -g -mcpu=ev4 -mtune=ev5 -Wall -Wno-format-y2k -Wno-uninitialized -c /usr/src/sbin/camcontrol/camcontrol.c /usr/src/sbin/camcontrol/camcontrol.c: In function `scsiformat': /usr/src/sbin/camcontrol/camcontrol.c:3082: warning: long long int format, u_int64_t arg (arg 3) /usr/src/sbin/camcontrol/camcontrol.c:3082: warning: long long int format, u_int64_t arg (arg 4) cc -O -pipe -g -mcpu=ev4 -mtune=ev5 -Wall -Wno-format-y2k -Wno-uninitialized -c /usr/src/sbin/camcontrol/util.c /usr/src/sbin/camcontrol/util.c: In function `arg_put': /usr/src/sbin/camcontrol/util.c:119: warning: int format, different type arg (arg 2) In rev 1.14 of src/usr.bin/find/ls.c obrien used PRId64 from <machine/_inttypes.h> (included from <inttypes.h> to get rid of similar warnings. I have attached a patch for sbin/camcontrol, please have a look at it and let me know it this is the correct way to write the code. Does anyone know if PRId64 et al is documented somewhere? /Johan -- Johan Karlsson mailto:johan@FreeBSD.org --4bRzO86E/ozDv8r1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="camcontrol.diff" Index: sbin/camcontrol/Makefile =================================================================== RCS file: /home/ncvs/src/sbin/camcontrol/Makefile,v retrieving revision 1.11 diff -u -r1.11 Makefile --- sbin/camcontrol/Makefile 24 Jan 2002 16:53:08 -0000 1.11 +++ sbin/camcontrol/Makefile 10 Nov 2002 14:28:43 -0000 @@ -9,7 +9,6 @@ .else CFLAGS+= -DMINIMALISTIC .endif -WARNS= 0 DPADD= ${LIBCAM} ${LIBSBUF} LDADD= -lcam -lsbuf MAN= camcontrol.8 Index: sbin/camcontrol/camcontrol.c =================================================================== RCS file: /home/ncvs/src/sbin/camcontrol/camcontrol.c,v retrieving revision 1.47 diff -u -r1.47 camcontrol.c --- sbin/camcontrol/camcontrol.c 8 Sep 2002 05:39:36 -0000 1.47 +++ sbin/camcontrol/camcontrol.c 10 Nov 2002 14:28:43 -0000 @@ -30,6 +30,8 @@ #include <sys/ioctl.h> #include <sys/types.h> + +#include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -3075,7 +3077,8 @@ percentage = 10000 * val; fprintf(stdout, - "\rFormatting: %qd.%02qd %% " + "\rFormatting: " + "%"PRIu64".%02"PRIu64" %% " "(%d/%d) done", percentage / (0x10000 * 100), (percentage / 0x10000) % 100, Index: sbin/camcontrol/modeedit.c =================================================================== RCS file: /home/ncvs/src/sbin/camcontrol/modeedit.c,v retrieving revision 1.11 diff -u -r1.11 modeedit.c --- sbin/camcontrol/modeedit.c 30 May 2002 21:38:58 -0000 1.11 +++ sbin/camcontrol/modeedit.c 10 Nov 2002 14:28:43 -0000 @@ -641,7 +641,7 @@ char *line; /* Pointer to static fgetln buffer. */ char *name; /* Name portion of the line buffer. */ char *value; /* Value portion of line buffer. */ - int length; /* Length of static fgetln buffer. */ + size_t length; /* Length of static fgetln buffer. */ #define ABORT_READ(message, param) do { \ warnx(message, param); \ Index: sbin/camcontrol/util.c =================================================================== RCS file: /home/ncvs/src/sbin/camcontrol/util.c,v retrieving revision 1.7 diff -u -r1.7 util.c --- sbin/camcontrol/util.c 1 Dec 2000 12:01:35 -0000 1.7 +++ sbin/camcontrol/util.c 10 Nov 2002 14:28:43 -0000 @@ -48,10 +48,12 @@ "$FreeBSD: src/sbin/camcontrol/util.c,v 1.7 2000/12/01 12:01:35 jedgar Exp $"; #endif /* not lint */ +#include <sys/types.h> + +#include <inttypes.h> #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <sys/types.h> #include <camlib.h> #include "camcontrol.h" @@ -116,7 +118,7 @@ { case 'i': case 'b': - printf("%d ", (intptr_t)arg); + printf("%"PRIdPTR" ", (intptr_t)arg); break; case 'c': --4bRzO86E/ozDv8r1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021117122210.GB746>