minaco2 / distcc

Automatically exported from code.google.com/p/distcc
GNU General Public License v2.0
0 stars 0 forks source link

compilation error: ignoring return value of ‘{read, asprintf, write, fgets, getcwd, getwd}’, declared with attribute warn_unused_result #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Answering the following questions is a big help:

1. What version of distcc are you using 3.1 (svn trunk rev. 709)

2. What platform are you running on

i686 GNU/Linux
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3

3. What were you trying to do
./autogen.sh && ./configure && make clean all

4. What went wrong?
the compiler gets some justified errors since the return value of certain
function are not checked...

5. If you have an example of a compiler invocation that failed, quote it, 

gcc -DHAVE_CONFIG_H -D_GNU_SOURCE -DSYSCONFDIR="\"/usr/local/etc\""
-DPKGDATADIR="\"/usr/local/share/distcc\"" -Isrc -I"./src" -I"./lzo"
-I"./popt" -Werror -g -O2 -MD -W -Wall -Wimplicit -Wshadow -Wpointer-arith
-Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes
-Wmissing-prototypes -Wnested-externs -Wmissing-declarations
-Wuninitialized -D_REENTRANT    -o src/util.o -c src/util.c
cc1: warnings being treated as errors
src/util.c: In function ‘dcc_get_disk_io_stats’:
src/util.c:665: error: ignoring return value of ‘fscanf’, declared with
attribute warn_unused_result
src/util.c:696: error: ignoring return value of ‘fgets’, declared with
attribute warn_unused_result
make: *** [src/util.o] Error 1

fixe me:
disable the use of -Werror compiler switch or check the return values of
yield functions...

Original issue reported on code.google.com by keller.eric on 4 Sep 2009 at 8:39

GoogleCodeExporter commented 9 years ago
here are the output of the configure script, and the call to make

Original comment by keller.eric on 4 Sep 2009 at 8:47

Attachments:

GoogleCodeExporter commented 9 years ago
configure with "--disable-Werror".

Original comment by fergus.h...@gmail.com on 4 Sep 2009 at 9:26

GoogleCodeExporter commented 9 years ago
I assume it won't be fixed then :) or should I send some patch?

Original comment by keller.eric on 4 Sep 2009 at 9:36

GoogleCodeExporter commented 9 years ago
By all means, please send a patch!

Original comment by fergus.h...@gmail.com on 4 Sep 2009 at 9:51

GoogleCodeExporter commented 9 years ago
Hi Fergus,

I have some question left about distcc coding norm:
- do you have any guide line concerning exception handling in the project?
- what's about perror and errno when a function encounters an error?
- do you use doxygen comment ? (well some part of the code is uncommented)

I will send you some patch as soon as I get a better idea how your project is 
managed!

Best regrads

Original comment by keller.eric on 7 Sep 2009 at 8:41

GoogleCodeExporter commented 9 years ago
another question concerning the header files... Is there a reason why not 
preventing
the multiple header includes?

for ex.: util.h
#ifndef UTIL_H_
# define UTIL_H_

...
# endif // !UTIL_H_

Original comment by keller.eric on 7 Sep 2009 at 9:40

GoogleCodeExporter commented 9 years ago
Distcc is written in C, not C++.
So exception handling is done with return values.
Most functions return zero on success or a code from exitcode.h on error, and 
such
errors are manually propagated up to the caller, taking care to deallocate any
dynamically allocated local variables in the error cases.

Errors should be logged with the logging functions used throughout distcc; I 
don't
recall the names off-hand, but you can find that easily by browsing through the
distcc sources.  Error messages should always include strerror(errno) in cases 
where
errno was set by the call that failed.

As for the lack of include guards in header files... AFAIK there is no good 
reason
for that.

Original comment by fergus.h...@gmail.com on 9 Sep 2009 at 2:39

GoogleCodeExporter commented 9 years ago
Just a comment that the solution suggested earlier in this thread of

   configure with "--disable-Werror".

is good enough for me, so if you're not planning to step up with a patch, I'll 
close
this issue.

Original comment by fergus.h...@gmail.com on 1 Dec 2009 at 4:41

GoogleCodeExporter commented 9 years ago

Original comment by fergus.h...@gmail.com on 2 Mar 2010 at 8:04

GoogleCodeExporter commented 9 years ago
For "make deb" this worked for me: make deb CFLAGS="-Wno-erro"

Original comment by leonboga...@gmail.com on 27 Oct 2010 at 8:50