* [PATCH] Trivial printf format warning fixes
@ 2002-04-22 20:00 Jason R Thorpe
2002-04-22 23:11 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Jason R Thorpe @ 2002-04-22 20:00 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 415 bytes --]
Committed as obvious.
* findvar.c (extract_signed_integer): Cast printf argument
to suppress format warning.
(extract_unsigned_integer): Likewise.
* infcmd.c (registers_info): Likewise.
* top.c (get_prompt_1): Likewise.
* valops.c (value_assign): Likewise.
* valprint.c (print_decimal): Likewise.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
[-- Attachment #2: format-patch --]
[-- Type: text/plain, Size: 3633 bytes --]
Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.31
diff -u -r1.31 findvar.c
--- findvar.c 9 Apr 2002 03:06:13 -0000 1.31
+++ findvar.c 23 Apr 2002 02:52:00 -0000
@@ -57,7 +57,7 @@
if (len > (int) sizeof (LONGEST))
error ("\
That operation is not available on integers of more than %d bytes.",
- sizeof (LONGEST));
+ (int) sizeof (LONGEST));
/* Start at the most significant end of the integer, and work towards
the least significant. */
@@ -91,7 +91,7 @@
if (len > (int) sizeof (ULONGEST))
error ("\
That operation is not available on integers of more than %d bytes.",
- sizeof (ULONGEST));
+ (int) sizeof (ULONGEST));
/* Start at the most significant end of the integer, and work towards
the least significant. */
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.45
diff -u -r1.45 infcmd.c
--- infcmd.c 21 Apr 2002 20:23:33 -0000 1.45
+++ infcmd.c 23 Apr 2002 02:52:14 -0000
@@ -1681,7 +1681,7 @@
if (*addr_exp >= '0' && *addr_exp <= '9')
regnum = atoi (addr_exp); /* Take a number */
if (regnum >= numregs) /* Bad name, or bad number */
- error ("%.*s: invalid register", end - addr_exp, addr_exp);
+ error ("%.*s: invalid register", (int) (end - addr_exp), addr_exp);
found:
DO_REGISTERS_INFO (regnum, fpregs);
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.61
diff -u -r1.61 top.c
--- top.c 28 Mar 2002 01:35:55 -0000 1.61
+++ top.c 23 Apr 2002 02:52:24 -0000
@@ -1435,7 +1435,7 @@
if (*promptp != gdb_prompt_escape)
error ("Syntax error at prompt position %d",
- promptp - local_prompt);
+ (int) (promptp - local_prompt));
else
{
promptp++; /* skip second escape char */
@@ -1581,7 +1581,7 @@
break; /* void type -- no output */
default:
error ("bad data type at prompt position %d",
- promptp - local_prompt);
+ (int) (promptp - local_prompt));
break;
}
outp += strlen (outp);
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.53
diff -u -r1.53 valops.c
--- valops.c 22 Mar 2002 18:57:08 -0000 1.53
+++ valops.c 23 Apr 2002 02:52:27 -0000
@@ -607,7 +607,7 @@
if (changed_len > (int) sizeof (LONGEST))
error ("Can't handle bitfields which don't fit in a %d bit word.",
- sizeof (LONGEST) * HOST_CHAR_BIT);
+ (int) sizeof (LONGEST) * HOST_CHAR_BIT);
read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval),
buffer, changed_len);
@@ -644,7 +644,7 @@
if (len > (int) sizeof (LONGEST))
error ("Can't handle bitfields in registers larger than %d bits.",
- sizeof (LONGEST) * HOST_CHAR_BIT);
+ (int) sizeof (LONGEST) * HOST_CHAR_BIT);
if (VALUE_BITPOS (toval) + VALUE_BITSIZE (toval)
> len * HOST_CHAR_BIT)
Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.24
diff -u -r1.24 valprint.c
--- valprint.c 17 Mar 2002 16:10:25 -0000 1.24
+++ valprint.c 23 Apr 2002 02:52:28 -0000
@@ -335,7 +335,7 @@
val_long);
break;
case 'u':
- fprintf_filtered (stream, "%llu", val_long);
+ fprintf_filtered (stream, "%llu", (long long) val_long);
break;
case 'x':
fprintf_filtered (stream,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trivial printf format warning fixes
2002-04-22 20:00 [PATCH] Trivial printf format warning fixes Jason R Thorpe
@ 2002-04-22 23:11 ` Eli Zaretskii
2002-04-22 23:20 ` Andreas Jaeger
2002-04-22 23:22 ` David S. Miller
0 siblings, 2 replies; 7+ messages in thread
From: Eli Zaretskii @ 2002-04-22 23:11 UTC (permalink / raw)
To: Jason R Thorpe; +Cc: gdb-patches
On Mon, 22 Apr 2002, Jason R Thorpe wrote:
> error ("Syntax error at prompt position %d",
> - promptp - local_prompt);
> + (int) (promptp - local_prompt));
I think the result of subtracting two pointers can be wider than an int,
can't it? If so, casting to an int is not right, and the format should
be changed to %ld.
(Yes, this is nitpicking, but if we are to fix this warning, might as
well do it right ;-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trivial printf format warning fixes
2002-04-22 23:11 ` Eli Zaretskii
@ 2002-04-22 23:20 ` Andreas Jaeger
2002-04-23 0:01 ` Jason R Thorpe
2002-04-22 23:22 ` David S. Miller
1 sibling, 1 reply; 7+ messages in thread
From: Andreas Jaeger @ 2002-04-22 23:20 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Jason R Thorpe, gdb-patches
Eli Zaretskii <eliz@is.elta.co.il> writes:
> On Mon, 22 Apr 2002, Jason R Thorpe wrote:
>
>> error ("Syntax error at prompt position %d",
>> - promptp - local_prompt);
>> + (int) (promptp - local_prompt));
>
> I think the result of subtracting two pointers can be wider than an int,
> can't it? If so, casting to an int is not right, and the format should
> be changed to %ld.
ISO C99 introduced 't' for ptrdiff_t, so we could use '%td' here if we
have an ISO C99 compiler.
> (Yes, this is nitpicking, but if we are to fix this warning, might as
> well do it right ;-)
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trivial printf format warning fixes
2002-04-22 23:11 ` Eli Zaretskii
2002-04-22 23:20 ` Andreas Jaeger
@ 2002-04-22 23:22 ` David S. Miller
1 sibling, 0 replies; 7+ messages in thread
From: David S. Miller @ 2002-04-22 23:22 UTC (permalink / raw)
To: eliz; +Cc: thorpej, gdb-patches
From: Eli Zaretskii <eliz@is.elta.co.il>
Date: Tue, 23 Apr 2002 10:10:16 +0300 (IDT)
On Mon, 22 Apr 2002, Jason R Thorpe wrote:
> error ("Syntax error at prompt position %d",
> - promptp - local_prompt);
> + (int) (promptp - local_prompt));
I think the result of subtracting two pointers can be wider than an int,
can't it? If so, casting to an int is not right, and the format should
be changed to %ld.
(Yes, this is nitpicking, but if we are to fix this warning, might as
well do it right ;-)
Aren't there standard printf format strings for ptrdiff_t, that is
what this thing is.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trivial printf format warning fixes
2002-04-22 23:20 ` Andreas Jaeger
@ 2002-04-23 0:01 ` Jason R Thorpe
2002-04-23 3:13 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Jason R Thorpe @ 2002-04-23 0:01 UTC (permalink / raw)
To: Andreas Jaeger; +Cc: Eli Zaretskii, gdb-patches
On Tue, Apr 23, 2002 at 08:20:26AM +0200, Andreas Jaeger wrote:
> ISO C99 introduced 't' for ptrdiff_t, so we could use '%td' here if we
> have an ISO C99 compiler.
Yes, but I don't think it's safe to assume that all platforms on which
GDB is uses are C99 compliant.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trivial printf format warning fixes
2002-04-23 0:01 ` Jason R Thorpe
@ 2002-04-23 3:13 ` Eli Zaretskii
2002-04-23 8:58 ` Jason R Thorpe
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2002-04-23 3:13 UTC (permalink / raw)
To: Jason R Thorpe; +Cc: Andreas Jaeger, gdb-patches
On Tue, 23 Apr 2002, Jason R Thorpe wrote:
> On Tue, Apr 23, 2002 at 08:20:26AM +0200, Andreas Jaeger wrote:
>
> > ISO C99 introduced 't' for ptrdiff_t, so we could use '%td' here if we
> > have an ISO C99 compiler.
>
> Yes, but I don't think it's safe to assume that all platforms on which
> GDB is uses are C99 compliant.
I agree. I think "%ld" is good enough.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Trivial printf format warning fixes
2002-04-23 3:13 ` Eli Zaretskii
@ 2002-04-23 8:58 ` Jason R Thorpe
0 siblings, 0 replies; 7+ messages in thread
From: Jason R Thorpe @ 2002-04-23 8:58 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Andreas Jaeger, gdb-patches
On Tue, Apr 23, 2002 at 02:11:48PM +0300, Eli Zaretskii wrote:
> I agree. I think "%ld" is good enough.
Ok, I'll tweak those, and then cast the corresponding arguments to long.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-04-23 15:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-22 20:00 [PATCH] Trivial printf format warning fixes Jason R Thorpe
2002-04-22 23:11 ` Eli Zaretskii
2002-04-22 23:20 ` Andreas Jaeger
2002-04-23 0:01 ` Jason R Thorpe
2002-04-23 3:13 ` Eli Zaretskii
2002-04-23 8:58 ` Jason R Thorpe
2002-04-22 23:22 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox