From: Michael Wookey <hidden> Date: 2016-06-15 22:47:20
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(-)
From: Michael Wookey <hidden> Date: 2016-06-15 22:47:20
2009/9/1 Alex Riesen [off-list ref]:
On Mon, Aug 31, 2009 at 14:29, Sverre Rabbelier[off-list ref] wrote:
quoted
On Mon, Aug 31, 2009 at 04:21, Michael Wookey[off-list ref] wrote:
quoted
Provide a dummy variable to keep the compiler happy.
Should we not instead check the value?
Why? It is endp (end of the parsed number) we're interested in.
Good point, perhaps the commit message should mention why we don't
bother checking the return value. Something like this maybe?
-- >8 --
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
The return value of strtoul() isn't used because we are only interested
in what is placed into endp. As such, provide a dummy variable to keep
the compiler happy.
Signed-off-by: Michael Wookey <redacted>
-- >8 --
From: Junio C Hamano <hidden> Date: 2016-06-15 22:47:20
Michael Wookey [off-list ref] writes:
quoted hunk
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(-)
@@ -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)?
Otherwise a clever compiler has every right to complain "the variable
unused is assigned but never used."
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(-)
From: Stephen Boyd <hidden> Date: 2016-06-15 22:47:20
Michael Wookey wrote:
2009/9/1 Junio C Hamano [off-list ref]:
quoted
Isn't this typically done by casting the expression to (void)?
I originally tried that - the compiler still complains.
quoted
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? ;-)
I noticed this warning recently too when I upgraded my box and a flurry
of fwrite() unused warnings came up. Looks like ubuntu patches that
issue[1] by arguing it's a valid programming style to
fwrite/fflush/ferror. Perhaps this programming style could follow a
similar reasoning?
It gets better though. Commit c55fae4 (fast-import.c: stricter strtoul
check, silence compiler warning, 2008-12-21) made this change already.
Then commit eb3a9dd (Remove unused function scope local variables,
2009-03-07) came by and removed it. Unless the definition of strtoul
drops the attribute I fear we'll keep going back and forth.
-- Footnotes --
[1] https://lists.ubuntu.com/archives/ubuntu-devel/2009-March/027832.html
From: Alex Riesen <hidden> Date: 2016-06-15 22:47:20
On Tue, Sep 1, 2009 at 01:55, Michael Wookey[off-list ref] wrote:
quoted
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? ;-)
It only does what it is instructed to do: the function is annotated with
warn_unused_result attribute. What really is annoying is someones
choice of the functions to annotate.