Re: [PATCH 12/15] mke2fs: add some error checks into PRS()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010-11-30 (í), 13:46 +0100, Lukas Czerner:
> On Mon, 29 Nov 2010, Namhyung Kim wrote:
> 
> > Check return value of some functions and exit if unhandled error occurred.
> > 
> > Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
> > ---
> >  misc/mke2fs.c |   26 ++++++++++++++++++++++----
> >  1 files changed, 22 insertions(+), 4 deletions(-)
> > 
> > diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> > index b88decf..6e2092d 100644
> > --- a/misc/mke2fs.c
> > +++ b/misc/mke2fs.c
> > @@ -1108,6 +1108,10 @@ static void PRS(int argc, char *argv[])
> >  	if (oldpath)
> >  		pathlen += strlen(oldpath);
> >  	newpath = malloc(pathlen);
> > +	if (!newpath) {
> > +		fprintf(stderr, _("Couldn't allocate memory for new PATH.\n"));
> > +		exit(1);
> > +	}
> >  	strcpy(newpath, PATH_SET);
> >  
> >  	/* Update our PATH to include /sbin  */
> > @@ -1138,14 +1142,28 @@ static void PRS(int argc, char *argv[])
> >  	profile_set_syntax_err_cb(syntax_err_report);
> >  	retval = profile_init(config_fn, &profile);
> >  	if (retval == ENOENT) {
> > -		profile_init(default_files, &profile);
> > -		profile_set_default(profile, mke2fs_default_profile);
> > +		retval = profile_init(default_files, &profile);
> > +		if (retval)
> > +			goto profile_error;
> > +		retval = profile_set_default(profile, mke2fs_default_profile);
> > +		if (retval)
> > +			goto profile_error;
> > +	} else {
> 
> Maybe use "else if (retval)" since profile_init(config_fn, &profile);
> might exit successfully (return 0) ?
> 

Right! Will resend v2, thanks.

-- 
Regards,
Namhyung Kim


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux