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

Greg Hudson ghudson at mit.edu
Wed Aug 23 11:14:21 EDT 2017


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.)


More information about the krbdev mailing list