Re: [PATCH v4 5/8] status: print per-file porcelain v2 status data

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

 



On Fri, Aug 05, 2016 at 02:09:48PM -0700, Junio C Hamano wrote:

> On Fri, Aug 5, 2016 at 2:02 PM, Jeff King <peff@xxxxxxxx> wrote:
> > On Tue, Aug 02, 2016 at 10:12:14AM -0400, Jeff Hostetler wrote:
> >> +     switch (d->stagemask) {
> >> +     case 1: key = "DD"; break; /* both deleted */
> >> + ...
> >> +     case 7: key = "UU"; break; /* both modified */
> >> +     }
> >> [...]
> >> +     fprintf(s->fp, "%c %s %s %06o %06o %06o %06o %s %s %s %s%c",
> >> +                     unmerged_prefix, key, submodule_token,
> >
> > Coverity complains that "key" can be uninitialized here. I think it's
> > wrong, and just doesn't know that d->stagemask is constrained to 1-7.
> >
> > But perhaps it is worth adding a:
> >
> >   default:
> >         die("BUG: unhandled unmerged status %x", d->stagemask);
> >
> > to the end of the switch. That would shut up Coverity, and give us a
> > better indication if our constraint is violated.
> 
> This is pure curiosity but I wonder if Coverity shuts up if we
> instead switched on (d->stagemask & 07). Your "default: BUG"
> suggestion is what we should use as a real fix, of course.

I suspect yes. It's pretty clever about analyzing the flow and placing
constraints on values (though in this case "& 07" includes "0", which is
not handled in the switch).

Unfortunately it is hard for me to test a one-off, as running it locally
is a complete pain. Stefan set it up long ago to pull "pu" and email out
the results from their central servers, so I just scan those emails for
things that look like real issues.

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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]