On AIX with GCC 6.3.0, a "maybe-unitialized" variable generates an error.

REIX, Tony tony.reix at atos.net
Wed Aug 23 11:31:24 EDT 2017


Hi Greg,

Thanks for the alternative patch.
I've tested it. That's perfect.
I've attached the new patch to this email.

I was comfortable with github. No more. So please fill PRs.

BTW, here are the warnings I see still with localaddr.c .
That does not block me. However that may show some hidden issue. But I have very very small knowledge of krb5. Just porting it.

gcc -maix64 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -DHAVE_CONFIG_H -DLIBDIR=\"/opt/freeware/lib64\" -DBINDIR=\"/opt/freeware/bin\" -DSBINDIR=\"/opt/freeware/sbin\" -I../../../include -I../../../include -I../../../util/profile -DKRB5_DEPRECATED=1 -DKRB5_PRIVATE  -DSYSV -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX51 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_ALL_SOURCE -DFUNCPROTO=15 -O -I/opt/freeware/include -D_THREAD_SAFE  -Wall -Wcast-align -Wshadow -Wmissing-prototypes -pedantic -Wno-format-zero-length -Woverflow -Wstrict-overflow -Wmissing-format-attribute -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-function -Wunused-label -Wunused-variable -Wunused-value -Wunknown-pragmas -Wsign-compare -Werror=uninitialized -Werror=pointer-arith -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=discarded-qualifiers -Werror=declaration-after-statement -Werror-implicit-function-declaration   -c localaddr.c
localaddr.c: In function 'krb5int_foreach_localaddr':
localaddr.c:978:35: warning: left-hand operand of comma expression has no effect [-Wunused-value]
         Tprintf (("interface %s\n", ifreq.ifr_name));
                                   ^
localaddr.c:83:28: note: in definition of macro 'Tprintf'
 # define Tprintf(X) (void) X
                            ^
localaddr.c:945:12: warning: unused variable 'size' [-Wunused-variable]
     size_t size, n, i, j;
            ^~~~
localaddr.c:943:12: warning: unused variable 'code' [-Wunused-variable]
     int s, code;
            ^~~~

Regards,

Cordialement,

Tony Reix

Bull - ATOS
IBM Coop Architect & Technical Leader
Office : +33 (0) 4 76 29 72 67
1 rue de Provence - 38432 Échirolles - France
www.atos.net

________________________________________
De : Greg Hudson [ghudson at mit.edu]
Envoyé : mercredi 23 août 2017 17:14
À : REIX, Tony; krbdev at mit.edu
Objet : Re: On AIX with GCC 6.3.0, a "maybe-unitialized" variable generates an error.

On 08/23/2017 09:28 AM, REIX, Tony wrote:
> On AIX with GCC 6.3.0, a "maybe-unitialized" variable generates an error.

> localaddr.c:1033:9: error: 'n' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>         for (i = 0; i + sizeof(struct ifreq) <= n; i+= ifreq_size(*ifr) ) {

It looks like n is supposed to be set by get_ifreq_array(), but this
particular version of gcc isn't smart enough to determine that
get_ifreq_array() always either sets *np or returns nonzero, perhaps
because of the case at line 892 where errno is used as a return value.
My preferred fix for this sort of problem is to make get_ifreq_array()
begin with:

    *bufp = NULL;
    *np = 0;

Does that make the error go away?

Thanks.

(As a side note, if you are comfortable using github, you could file
these patches as pull requests against https://github.com/krb5/krb5 .
Otherwise I will take care of filing PRs.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: krb5-1.15.1-maybe-uninitialized-for-krb5-community.patch
Type: text/x-patch
Size: 380 bytes
Desc: krb5-1.15.1-maybe-uninitialized-for-krb5-community.patch
Url : http://mailman.mit.edu/pipermail/krbdev/attachments/20170823/b43ed635/attachment.bin


More information about the krbdev mailing list