On Sun, Sep 27, 2009 at 11:15 AM, Guenter Knauf <[email protected]> wrote:
> Hi,
> Jie Gao schrieb:
>
>> That error is now gone. But I've found more errors:
>>
>> /bin/bash /usr/local/src/httpd-2.2.14/srclib/apr/libtool --silent
>> --mode=compile /opt/SUNWspro/bin/cc -g -fast -DHAVE_CONFIG_H -DSOLARIS2=10
>> -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_LARGEFILE64_SOURCE -I./include
>> -I/usr/local/src/httpd-2.2.14/srclib/apr/include/arch/unix
>> -I./include/arch/unix
>> -I/usr/local/src/httpd-2.2.14/srclib/apr/include/arch/unix
>> -I/usr/local/src/httpd-2.2.14/srclib/apr/include -o shmem/unix/shm.lo -c
>> shmem/unix/shm.c && touch shmem/unix/shm.lo
>> "shmem/unix/shm.c", line 87: warning: statement not reached
>> "shmem/unix/shm.c", line 218: warning: statement not reached
>> "shmem/unix/shm.c", line 365: warning: statement not reached
>> "shmem/unix/shm.c", line 424: warning: statement not reached
>> "shmem/unix/shm.c", line 455: warning: statement not reached
>> "shmem/unix/shm.c", line 573: warning: statement not reached
>>
> this seems to be a problem of the way how we have arranged the conditionals
> in shm.c; f.e. provided we have:
> #define APR_USE_SHMEM_MMAP_SHM 1
>
> in the compiler sees in shm.c:
>
> ...
> else {
> #if APR_USE_SHMEM_MMAP_SHM
> if (munmap(m->base, m->realsize) == -1) {
> return errno;
> }
> if (shm_unlink(m->filename) == -1) {
> return errno;
> }
> return APR_SUCCESS;
> #endif
> }
>
> return APR_ENOTIMPL;
>
> so the compiler is right here: inside the conditional we allways return
> already either with errno or APR_SUCCESS, thus:
> return APR_ENOTIMPL;
> is never reached ......
>
> I think we must change the conditionals into a chain of:
> #if COND_1
> ...
> #elif COND_2
> ...
> #elif COND_3
> ...
> #else
> return APR_ENOTIMPL;
> #endif
>
> thoughts?
>
> We get "warning: statement not reached" in more places with Sun Studio:
util_script.c, core_filters.c, rotatelogs.c, and possibly other modules I
don't normally build.
I don't think we would find it natural to make the code changes required to
snuff it out completely, and people not using Sun Studio will occasionally
write code that results in the warning popping up in a new place.
This cflag will suppress it:
-erroff=E_STATEMENT_NOT_REACHED
I see doc about putting /*NOTREACHED*/ in the code, but maybe that only
works when invoking lint directly. (I didn't get it to work.) There's
possibly a way to do it with a pragma as well.
IMO we should just let it be; users/developers can set CFLAGS to suppress it
if desired.
(Perhaps non-suppressing Sun Studio users among the developers will notice
when a new one crops up and evaluate whether or not it is a real problem;
perhaps other compilers will warn in scenarios where it is more likely?)