[dm-devel] [PATCH 07/21] libmultipath: use strbuf in parse_vpd_pg83()

Martin Wilck mwilck at suse.com
Tue Nov 30 22:04:36 UTC 2021


On Tue, 2021-11-30 at 14:29 -0600, Benjamin Marzinski wrote:
> On Tue, Nov 30, 2021 at 12:26:47PM +0100, Martin Wilck wrote:
> > On Mon, 2021-11-29 at 19:18 -0600, Benjamin Marzinski wrote:
> > > On Fri, Nov 19, 2021 at 12:13:24AM +0100, mwilck at suse.com wrote:
> > > > -               out[0] = '1';
> > > > -               len = 1;
> > > > -               while ((p = memchr(vpd, ' ', vpd_len))) {
> > > > +               if ((err = fill_strbuf(&buf, '1', 1)) < 0)
> > > > +                       return err;
> > > > +               while (vpd && (p = memchr(vpd, ' ', vpd_len)))
> > > > {
> > > 
> > > vpd should never be zero here unless it wraps around, which seems
> > > very
> > > unlikely.  Is this just to make coverity happy, or do you mean
> > > (*vpd)?
> > > 
> > 
> > Coverity likes arguments for memchr() to be NULL-checked
> > beforehand, 
> > but that wasn't the main reason.
> > 
> > See below, there's "vpd = p". And p can (and will sooner or later)
> > be
> > NULL, because memchr() returns NULL if it doesn't find anything.
> > 
> 
> Right, but don't you only execute this while loop if p isn't NULL?
> Not
> that it really matters. I'm fine with the code that way it is.

Ah, I misinterpreted your comment. This one was for coverity, IIRC;
to make it believe that it's legal to take *vpd.

Martin





More information about the dm-devel mailing list