Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/where.c:193: error: 'chosen' may be used uninitialized in this function #28

Closed
GoogleCodeExporter opened this issue May 26, 2015 · 9 comments

Comments

@GoogleCodeExporter
Copy link

Answering the following questions is a big help:

1. What version of distcc are you using (e.g. "2.7.1")?  
svn revision 622

2. What platform are you running on (e.g. "Red Hat 8.0", "HP-UX 11.11")?
Gentoo, x86-64, gcc-4.3.2, glibc-2.8, python-2.5.2

3. What were you trying to do (e.g. "install distcc", "build Mozilla")?
svn co distcc; ./autogen.sh; CFLAGS="-O3 -fomit-frame-pointer -pipe"
./configure; make

4. What went wrong?
(snip)
gcc -DHAVE_CONFIG_H -D_GNU_SOURCE -DSYSCONFDIR="\"/usr/local/etc\""
-DPKGDATADIR="\"/usr/local/share/distcc\"" -Isrc -I"./src" -I"./lzo" 
-Werror -O3 -fomit-frame-pointer -pipe -MD -W -Wall -Wimplicit
-Wuninitialized -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings
-Waggregate-return -Wstrict-prototypes -Wmissing-prototypes
-Wnested-externs -Wmissing-declarations -D_REENTRANT    -o src/where.o -c
src/where.c
cc1: warnings being treated as errors
src/where.c: In function 'dcc_lock_local_cpp':
src/where.c:193: error: 'chosen' may be used uninitialized in this function
make: *** [src/where.o] Error 1

FYI: http://bugs.gentoo.org/show_bug.cgi?id=244847

attached a patch.

Original issue reported on code.google.com by mat...@gmail.com on 29 Oct 2008 at 4:32

Attachments:

@GoogleCodeExporter
Copy link
Author

I don't think the patch really addresses the underlying issue.
It just replaces a possible use of an uninitialized variable
with a possible dereference of a null pointer.
It fixes the build error, but doesn't fix the possible run-time error.

Original comment by fergus.h...@gmail.com on 2 Dec 2008 at 6:49

@GoogleCodeExporter
Copy link
Author

Original comment by fergus.h...@gmail.com on 8 Dec 2008 at 11:39

  • Added labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Surely this is simply fixed by making the call to dcc_note_state() conditional 
on ret == 0?  I would initialize chosen to NULL too, just as good practice.

Original comment by jeremy.w...@gmail.com on 25 Sep 2010 at 1:37

@GoogleCodeExporter
Copy link
Author

hi,
I guess I can post similar issue here when I try to make distcc on my iMac:

Darwin bjchenys-iMac 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 
PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64

gcc version 4.2.1 Python 2.7.1

bjchenys-iMac:distcc bjcheny$ make
echo "path: $PATH"
path: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
./config.status
config.status: creating Makefile
config.status: creating popt/.stamp-conf
config.status: creating lzo/.stamp-conf
config.status: creating pump
config.status: creating src/config.h
config.status: src/config.h is unchanged
touch src/config.h.stamp
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_THREAD_SAFE  -o 
src/hosts.o -c src/hosts.c
cc1: warnings being treated as errors
src/hosts.c: In function 'dcc_parse_hosts':
src/hosts.c:562: warning: implicit declaration of function 'strndup'
src/hosts.c:562: warning: incompatible implicit declaration of built-in 
function 'strndup'
make: *** [src/hosts.o] Error 1

I wonder any progress/patch or general solution for this kind of issue?

Regards

Original comment by compan...@gmail.com on 30 May 2012 at 12:34

@GoogleCodeExporter
Copy link
Author

Forget to add I use to get code:
svn checkout http://distcc.googlecode.com/svn/trunk/ distcc-read-only

Original comment by compan...@gmail.com on 30 May 2012 at 12:37

@GoogleCodeExporter
Copy link
Author

The general work-around for compiler warnings is to configure with 
"--disable-Werror".

Original comment by fergus.h...@gmail.com on 30 May 2012 at 3:43

@GoogleCodeExporter
Copy link
Author

> src/where.c: In function 'dcc_lock_local_cpp':
> src/where.c:193: error: 'chosen' may be used uninitialized in this function
> make: *** [src/where.o] Error 1

The error only occurs when using "-O3".

> Surely this is simply fixed by making the call to
> dcc_note_state() conditional on ret == 0?

Any reason not to apply this fix?  It makes sense.

Original comment by mand...@gmail.com on 8 May 2013 at 2:49

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

The proposed fix of making the call to dcc_note_state() conditional on ret == 0 
sounds good to me.

Original comment by fer...@google.com on 8 May 2013 at 3:56

@GoogleCodeExporter
Copy link
Author

This issue was closed by revision r779.

Original comment by mand...@gmail.com on 10 May 2013 at 2:36

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant