* [patch/minor] fix compile warning in linux-proc.c
@ 2003-08-21 5:08 Randolph Chung
2003-08-25 16:48 ` David Carlton
0 siblings, 1 reply; 4+ messages in thread
From: Randolph Chung @ 2003-08-21 5:08 UTC (permalink / raw)
To: gdb-patches
While trying to get hppa-linux building with -Werror, I came across one
warning in linux-proc.c that's triggered by -Wformat-nonliteral. This
patch fixes it if anybody cares :)
thanks,
randolph
2003-08-20 Randolph Chung <tausq@debian.org>
* linux-proc.c: rework the code so that it compiles with
-Wformat-nonliteral -Werror
Index: linux-proc.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-proc.c,v
retrieving revision 1.16
diff -u -p -r1.16 linux-proc.c
--- gdb/linux-proc.c 4 Aug 2003 17:08:22 -0000 1.16
+++ gdb/linux-proc.c 21 Aug 2003 04:54:45 -0000
@@ -404,35 +404,46 @@ linux_info_proc_cmd (char *args, int fro
{
long long addr, endaddr, size, offset, inode;
char permissions[8], device[8], filename[MAXPATHLEN];
- char *header_fmt_string, *data_fmt_string;
+ printf_filtered ("Mapped address spaces:\n\n");
if (TARGET_ADDR_BIT == 32)
{
- header_fmt_string = "\t%10s %10s %10s %10s %7s\n";
- data_fmt_string = "\t%#10lx %#10lx %#10x %#10x %7s\n";
- }
+ printf_filtered ("\t%10s %10s %10s %10s %7s\n",
+ "Start Addr",
+ " End Addr",
+ " Size", " Offset", "objfile");
+ }
else
- {
- header_fmt_string = " %18s %18s %10s %10s %7s\n";
- data_fmt_string = " %#18lx %#18lx %#10x %#10x %7s\n";
- }
-
- printf_filtered ("Mapped address spaces:\n\n");
- printf_filtered (header_fmt_string,
+ {
+ printf_filtered (" %18s %18s %10s %10s %7s\n",
"Start Addr",
" End Addr",
" Size", " Offset", "objfile");
+ }
while (read_mapping (procfile, &addr, &endaddr, &permissions[0],
&offset, &device[0], &inode, &filename[0]))
{
size = endaddr - addr;
- printf_filtered (data_fmt_string, (unsigned long) addr, /* FIXME: pr_addr */
+
+ if (TARGET_ADDR_BIT == 32)
+ {
+ printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
+ (unsigned long) addr, /* FIXME: pr_addr */
(unsigned long) endaddr,
(int) size,
(unsigned int) offset,
filename[0] ? filename : "");
-
+ }
+ else
+ {
+ printf_filtered (" %#18lx %#18lx %#10x %#10x %7s\n",
+ (unsigned long) addr, /* FIXME: pr_addr */
+ (unsigned long) endaddr,
+ (int) size,
+ (unsigned int) offset,
+ filename[0] ? filename : "");
+ }
}
fclose (procfile);
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch/minor] fix compile warning in linux-proc.c
2003-08-21 5:08 [patch/minor] fix compile warning in linux-proc.c Randolph Chung
@ 2003-08-25 16:48 ` David Carlton
2003-08-27 4:25 ` Andrew Cagney
0 siblings, 1 reply; 4+ messages in thread
From: David Carlton @ 2003-08-25 16:48 UTC (permalink / raw)
To: Randolph Chung; +Cc: gdb-patches, Andrew Cagney
On Wed, 20 Aug 2003 22:11:49 -0700, Randolph Chung <randolph@tausq.org> said:
> While trying to get hppa-linux building with -Werror, I came across one
> warning in linux-proc.c that's triggered by -Wformat-nonliteral. This
> patch fixes it if anybody cares :)
I'm seeing this on i686-pc-linux-gnu, too. The patch looks fine to me
(though I'm not in a position to approve it); if I were in a
hyper-refactoring mode, I suppose I'd be tempted to create new
functions print_header_format_32, print_data_fmt_32,
print_header_format_64, print_data_fmt_64 defined along these lines:
static void
print_data_fmt_64 (unsigned long addr, unsigned long endaddr,
int size, unsigned int offset, const char *filename) {
printf_filtered (" %#181x %#181x %#10x %#10x %7s\n",
addr, endaddr, size, offset, filename);
}
but I don't think it's really urgent to do so. Hmm; maybe we really
should do that, at least for the data strings, because it gets rid of
casts? Andrew, what do you think?
David Carlton
carlton@kealia.com
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch/minor] fix compile warning in linux-proc.c
2003-08-25 16:48 ` David Carlton
@ 2003-08-27 4:25 ` Andrew Cagney
2003-08-27 15:42 ` David Carlton
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2003-08-27 4:25 UTC (permalink / raw)
To: David Carlton; +Cc: Randolph Chung, gdb-patches
> On Wed, 20 Aug 2003 22:11:49 -0700, Randolph Chung <randolph@tausq.org> said:
>
>
>> While trying to get hppa-linux building with -Werror, I came across one
>> warning in linux-proc.c that's triggered by -Wformat-nonliteral. This
>> patch fixes it if anybody cares :)
>
>
> I'm seeing this on i686-pc-linux-gnu, too. The patch looks fine to me
> (though I'm not in a position to approve it); if I were in a
> hyper-refactoring mode, I suppose I'd be tempted to create new
> functions print_header_format_32, print_data_fmt_32,
> print_header_format_64, print_data_fmt_64 defined along these lines:
David, feel free to check it in. A comment mentioning that this should
use a generic (and not yet existing) local_address_string() method would
be useful.
The casts don't phase me. The conflicting "%#10lx" and "%#18lx" do but
again not desperatly. That local_address_string custom method.
Andrew
> static void
> print_data_fmt_64 (unsigned long addr, unsigned long endaddr,
> int size, unsigned int offset, const char *filename) {
> printf_filtered (" %#181x %#181x %#10x %#10x %7s\n",
> addr, endaddr, size, offset, filename);
> }
>
> but I don't think it's really urgent to do so. Hmm; maybe we really
> should do that, at least for the data strings, because it gets rid of
> casts? Andrew, what do you think?
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch/minor] fix compile warning in linux-proc.c
2003-08-27 4:25 ` Andrew Cagney
@ 2003-08-27 15:42 ` David Carlton
0 siblings, 0 replies; 4+ messages in thread
From: David Carlton @ 2003-08-27 15:42 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Randolph Chung, gdb-patches
On Wed, 27 Aug 2003 00:25:39 -0400, Andrew Cagney <ac131313@redhat.com> said:
> David, feel free to check it in. A comment mentioning that this
> should use a generic (and not yet existing) local_address_string()
> method would be useful.
Done; here's what I've committed. Tested on i686-pc-linux-gnu,
DWARF-2, GCC 3.2; no regressions.
David Carlton
carlton@kealia.com
2003-08-27 David Carlton <carlton@kealia.com>
From Randolph Chung <tausq@debian.org>:
* linux-proc.c (linux_info_proc_cmd): rework the code so that it
compiles with -Wformat-nonliteral -Werror.
Index: linux-proc.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-proc.c,v
retrieving revision 1.17
diff -u -p -r1.17 linux-proc.c
--- linux-proc.c 24 Aug 2003 13:34:01 -0000 1.17
+++ linux-proc.c 27 Aug 2003 15:32:58 -0000
@@ -404,35 +404,52 @@ linux_info_proc_cmd (char *args, int fro
{
long long addr, endaddr, size, offset, inode;
char permissions[8], device[8], filename[MAXPATHLEN];
- char *header_fmt_string, *data_fmt_string;
+ printf_filtered ("Mapped address spaces:\n\n");
if (TARGET_ADDR_BIT == 32)
{
- header_fmt_string = "\t%10s %10s %10s %10s %7s\n";
- data_fmt_string = "\t%#10lx %#10lx %#10x %#10x %7s\n";
- }
+ printf_filtered ("\t%10s %10s %10s %10s %7s\n",
+ "Start Addr",
+ " End Addr",
+ " Size", " Offset", "objfile");
+ }
else
- {
- header_fmt_string = " %18s %18s %10s %10s %7s\n";
- data_fmt_string = " %#18lx %#18lx %#10x %#10x %7s\n";
- }
-
- printf_filtered ("Mapped address spaces:\n\n");
- printf_filtered (header_fmt_string,
+ {
+ printf_filtered (" %18s %18s %10s %10s %7s\n",
"Start Addr",
" End Addr",
" Size", " Offset", "objfile");
+ }
while (read_mapping (procfile, &addr, &endaddr, &permissions[0],
&offset, &device[0], &inode, &filename[0]))
{
size = endaddr - addr;
- printf_filtered (data_fmt_string, (unsigned long) addr, /* FIXME: pr_addr */
+
+ /* FIXME: carlton/2003-08-27: Maybe the printf_filtered
+ calls here (and possibly above) should be abstracted
+ out into their own functions? Andrew suggests using
+ a generic local_address_string instead to print out
+ the addresses; that makes sense to me, too. */
+
+ if (TARGET_ADDR_BIT == 32)
+ {
+ printf_filtered ("\t%#10lx %#10lx %#10x %#10x %7s\n",
+ (unsigned long) addr, /* FIXME: pr_addr */
(unsigned long) endaddr,
(int) size,
(unsigned int) offset,
filename[0] ? filename : "");
-
+ }
+ else
+ {
+ printf_filtered (" %#18lx %#18lx %#10x %#10x %7s\n",
+ (unsigned long) addr, /* FIXME: pr_addr */
+ (unsigned long) endaddr,
+ (int) size,
+ (unsigned int) offset,
+ filename[0] ? filename : "");
+ }
}
fclose (procfile);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-08-27 15:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-21 5:08 [patch/minor] fix compile warning in linux-proc.c Randolph Chung
2003-08-25 16:48 ` David Carlton
2003-08-27 4:25 ` Andrew Cagney
2003-08-27 15:42 ` David Carlton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox