Re: Unitialized variable in mount.cifs error path
Steve French <[email protected]> Tue, 11 May 2010 10:09:55 -0500
| Newsgroups | gmane.linux.file-systems.cifs |
|---|---|
| Message-ID | <[email protected]> |
Your suggestion is fine with me. On Tue, May 11, 2010 at 8:13 AM, Jeff Layton <[email protected]> wrote: > On Fri, 7 May 2010 12:47:11 -0500 > Steve French <[email protected]> wrote: > >> diff --git a/mount.cifs.c b/mount.cifs.c >> index c4eb59a..124be27 100644 >> --- a/mount.cifs.c >> +++ b/mount.cifs.c >> @@ -559,7 +606,7 @@ static int open_cred_file(char *file_name, >> struct parsed_mount_info *parsed_info) >> { >> char *line_buf; >> - char *temp_val; >> + char *temp_val = NULL; >> FILE *fs = NULL; >> int i; >> const int line_buf_size = 4096; >> @@ -622,9 +669,10 @@ static int open_cred_file(char *file_name, >> break; >> case CRED_UNPARSEABLE: >> if (parsed_info->verboseflag) >> - fprintf(stderr, >> - "Credential formatted incorrectly: %s", >> - temp_val); >> + if (temp_val) >> + fprintf(stderr, >> + "Credential formatted incorrectly: %s", >> + temp_val); > > How about instead of the above, we do something like: > > fprintf(stderr, "Credential formatted incorrectly: %s\n", > temp_val ? temp_val : "(null)"); > > ...that way we get an error message even if temp_val is NULL. If that > sounds ok, I'll fix it and commit or you can just send a respun patch... > >> break; >> } >> } > > Thanks, > -- > Jeff Layton <[email protected]> > -- Thanks, Steve