Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Dec 2015 11:32:10 +0800
From:      Marcelo Araujo <araujobsdport@gmail.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        Garrett Cooper <yaneurabeya@gmail.com>, luke <luke.tw@gmail.com>,  "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>,  "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>,  "src-committers@freebsd.org" <src-committers@freebsd.org>
Subject:   Re: svn commit: r292410 - head/usr.sbin/boot0cfg
Message-ID:  <CAOfEmZjBRZPXi3J6FyP8XBZu=6zrQvSY%2Bw-2oJbi-6zhagmYaQ@mail.gmail.com>
In-Reply-To: <3897533.TozUtTrSHk@ralph.baldwin.cx>
References:  <201512172042.tBHKg5bM091931@repo.freebsd.org> <30CD0290-06B9-4024-8EEE-F25090608D46@gmail.com> <CAOfEmZhiQVQ8dLrE8_UHqJLWJYD1S2x55sBHeBw2bwvOqGqsYw@mail.gmail.com> <3897533.TozUtTrSHk@ralph.baldwin.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
2015-12-19 1:50 GMT+08:00 John Baldwin <jhb@freebsd.org>:

> On Friday, December 18, 2015 02:17:16 PM Marcelo Araujo wrote:
> > 2015-12-18 13:53 GMT+08:00 Garrett Cooper <yaneurabeya@gmail.com>:
> >
> > >
> > > > On Dec 17, 2015, at 21:36, luke <luke.tw@gmail.com> wrote:
> > > >
> > > >> On Fri, Dec 18, 2015 at 4:42 AM, John Baldwin <jhb@freebsd.org>
> wrote:
> > > >> Author: jhb
> > > >> Date: Thu Dec 17 20:42:05 2015
> > > >> New Revision: 292410
> > > >> URL: https://svnweb.freebsd.org/changeset/base/292410
> > > >>
> > > >> Log:
> > > >>   Exit cleanly if malloc() fails to allocate a buffer for a copy of
> the
> > > >>   current MBR.
> > > >>
> > > >>   PR:           205322
> > > >>   Submitted by: Alexander Kuleshov <kuleshovmail@gmail.com>
> > > >>   MFC after:    1 week
> > > >>
> > > >> Modified:
> > > >>   head/usr.sbin/boot0cfg/boot0cfg.c
> > > >>
> > > >> Modified: head/usr.sbin/boot0cfg/boot0cfg.c
> > > >>
> > >
> ==============================================================================
> > > >> --- head/usr.sbin/boot0cfg/boot0cfg.c   Thu Dec 17 20:33:20 2015
> > > (r292409)
> > > >> +++ head/usr.sbin/boot0cfg/boot0cfg.c   Thu Dec 17 20:42:05 2015
> > > (r292410)
> > > >> @@ -337,6 +337,8 @@ read_mbr(const char *disk, u_int8_t **mb
> > > >>         return (mbr_size);
> > > >>      }
> > > >>      *mbr = malloc(sizeof(buf));
> > > >> +    if (mbr == NULL)
> > > >> +       errx(1, "%s: unable to allocate MBR buffer", disk);
> > > >>      memcpy(*mbr, buf, sizeof(buf));
> > > >>      close(fd);
> > >
> > >
> > > > Hi,
> > > >
> > > > Should the check be against *mbr  ?
> > > > +    if (*mbr == NULL)
> > > > +       errx(1, "%s: unable to allocate MBR buffer", disk);
> > >
> > > Yup!
> > >
> >
> > +1
> >
> > Could be write as:
> > if ((*mbr = malloc(sizeof(buf))) == NULL)
> >      errx(1, "%s: unable to allocate MBR buffer", disk);
>
> Yes, but I don't like side effects in conditionals.
>
> OTOH, changing away from that is how I fubar'd the original patch. :-/
>
>
Understandable reason, but all the rest of the code is using that style,
bde@ has mentioned about it too.

In other hand, the change is too small to have another ci to fix it.

Best,
-- 

-- 
Marcelo Araujo            (__)araujo@FreeBSD.org
\\\'',)http://www.FreeBSD.org <http://www.freebsd.org/>;   \/  \ ^
Power To Server.         .\. /_)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOfEmZjBRZPXi3J6FyP8XBZu=6zrQvSY%2Bw-2oJbi-6zhagmYaQ>