This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] getc/putc -Wunused-value warnings in source.c
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 9 May 2013 10:54:07 +0400
- Subject: Re: [RFC] getc/putc -Wunused-value warnings in source.c
- References: <1367926842-22398-1-git-send-email-brobecker at adacore dot com> <87r4hivozq dot fsf at fleche dot redhat dot com>
> Joel> One could easily work around the problem by using fgetc instead of
> Joel> getc, as done in this patch.
>
> I think this approach is fine.
>
> I wouldn't even bother with the comment about AIX.[...]
Thanks, Tom. I agree with your reasoning, so attached is the patch
I checked in.
gdb/ChangeLog:
* source.c (forward_search_command): Replace call to getc
by call to fgetc.
(reverse_search_command): Likewise.
Tested on x86_64-linux, and checked in.
--
Joel
>From 0b197c94f5b3679848947476d1fa59b3e462ec72 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Wed, 8 May 2013 11:17:06 +0400
Subject: [PATCH] source.c: Use fgetc instead of getc.
On AIX, getc is a macro which triggers an -Wunused-value warning.
gdb/ChangeLog:
* source.c (forward_search_command): Replace call to getc
by call to fgetc.
(reverse_search_command): Likewise.
---
gdb/ChangeLog | 6 ++++++
gdb/source.c | 8 ++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6986d02..2d1e3e1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2013-05-09 Joel Brobecker <brobecker@adacore.com>
+
+ * source.c (forward_search_command): Replace call to getc
+ by call to fgetc.
+ (reverse_search_command): Likewise.
+
2013-05-08 Doug Evans <dje@google.com>
* psymtab.c (expand_symtabs_matching_via_partial): Fix file name
diff --git a/gdb/source.c b/gdb/source.c
index d816c9e..710b90c 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1613,7 +1613,7 @@ forward_search_command (char *regex, int from_tty)
buf = xmalloc (cursize);
p = buf;
- c = getc (stream);
+ c = fgetc (stream);
if (c == EOF)
break;
do
@@ -1627,7 +1627,7 @@ forward_search_command (char *regex, int from_tty)
cursize = newsize;
}
}
- while (c != '\n' && (c = getc (stream)) >= 0);
+ while (c != '\n' && (c = fgetc (stream)) >= 0);
/* Remove the \r, if any, at the end of the line, otherwise
regular expressions that end with $ or \n won't work. */
@@ -1698,14 +1698,14 @@ reverse_search_command (char *regex, int from_tty)
char buf[4096]; /* Should be reasonable??? */
char *p = buf;
- c = getc (stream);
+ c = fgetc (stream);
if (c == EOF)
break;
do
{
*p++ = c;
}
- while (c != '\n' && (c = getc (stream)) >= 0);
+ while (c != '\n' && (c = fgetc (stream)) >= 0);
/* Remove the \r, if any, at the end of the line, otherwise
regular expressions that end with $ or \n won't work. */
--
1.7.10.4