Thread (9 messages) flat view 9 messages, 5 authors, 2016-06-15

Re: [PATCH] fast-import.c: Silence build warning

From: Michael Wookey <hidden>
Date: 2016-06-15 22:47:20

2009/9/1 Junio C Hamano [off-list ref]:
Michael Wookey [off-list ref] writes:
quoted
gcc 4.3.3 (Ubuntu 9.04) warns that the return value of strtoul() was not
checked by issuing the following notice:

  warning: ignoring return value of ‘strtoul’, declared with attribute
warn_unused_result

Provide a dummy variable to keep the compiler happy.

Signed-off-by: Michael Wookey <redacted>
---
 fast-import.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 7ef9865..1386e75 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1744,10 +1744,11 @@ static int validate_raw_date(const char *src,
char *result, int maxlen)
 {
      const char *orig_src = src;
      char *endp;
+     unsigned long int unused;

      errno = 0;

-     strtoul(src, &endp, 10);
+     unused = strtoul(src, &endp, 10);
Isn't this typically done by casting the expression to (void)?
I originally tried that - the compiler still complains.
Otherwise a clever compiler has every right to complain "the variable
unused is assigned but never used."
 I get no other warnings, so does that make gcc less than clever? ;-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help