[MIPS] Fix uninitialized variable in inet/getnetgrent_r.c
Commit Message
I got seven build failures on MIPS using the new -Werror flag. Here is a fix
for one of the build failures. I did get a good build with all these fixes but
I haven't done a complete testsuite run with these fixes. I hoping that this
fix is simple enough that building is a sufficient test.
The failure was:
getnetgrent_r.c: In function '__internal_getnetgrent_r':
getnetgrent_r.c:298:14: error: 'fct' may be used uninitialized in this function [-Werror=maybe-uninitialized]
status = DL_CALL_FCT (*fct, (datap, buffer, buflen, &errno));
^
cc1: all warnings being treated as errors
I looked at the code and I don't think we can actually use an uninitialized
fct variable (due to the use of the no_more variable) but the compiler doesn't
seem to be able to figure that out. This fix is to just initialize fct to
NULL.
OK to checkin?
Steve Ellcey
sellcey@imgtec.com
2014-12-10 Steve Ellcey <sellcey@imgtec.com>
* inet/getnetgrent_r.c: Initialize fct.
Comments
On Wed, 10 Dec 2014, Steve Ellcey wrote:
> I looked at the code and I don't think we can actually use an uninitialized
> fct variable (due to the use of the no_more variable) but the compiler doesn't
> seem to be able to figure that out. This fix is to just initialize fct to
> NULL.
As previously discussed, we don't want to add such initializations to
quiet warnings.
In this case, it looks like moving the while loop inside the "if (!
no_more)" ought to make it obvious to the compiler that fct can't be used
uninitialized.
@@ -268,7 +268,7 @@ __internal_getnetgrent_r (char **hostp, char **userp, char **domainp,
struct __netgrent *datap,
char *buffer, size_t buflen, int *errnop)
{
- enum nss_status (*fct) (struct __netgrent *, char *, size_t, int *);
+ enum nss_status (*fct) (struct __netgrent *, char *, size_t, int *) = NULL;
/* Initialize status to return if no more functions are found. */
enum nss_status status = NSS_STATUS_NOTFOUND;