Re: [PATCH v4 5/8] status: print per-file porcelain v2 status data
- From
- Jeff Hostetler <git@jeffhostetler.com>
- Date
- Aug 5, 2016, 21:27 UTC
- Message-ID
- <57A504C0.1060808@jeffhostetler.com>
- In-Reply-To
- <20160805210222.a2rvlmioim4psbhw@sigill.intra.peff.net>
On 08/05/2016 05:02 PM, Jeff King wrote:
Show 43 quoted lines
> On Tue, Aug 02, 2016 at 10:12:14AM -0400, Jeff Hostetler wrote:
>
>> +static void wt_porcelain_v2_print_unmerged_entry(
>> + struct string_list_item *it,
>> + struct wt_status *s)
>> +{
>> + struct wt_status_change_data *d = it->util;
>> + const struct cache_entry *ce;
>> + struct strbuf buf_current = STRBUF_INIT;
>> + const char *path_current = NULL;
>> + int pos, stage, sum;
>> + struct {
>> + int mode;
>> + struct object_id oid;
>> + } stages[3];
>> + char *key;
>> [...]
>> + switch (d->stagemask) {
>> + case 1: key = "DD"; break; /* both deleted */
>> + case 2: key = "AU"; break; /* added by us */
>> + case 3: key = "UD"; break; /* deleted by them */
>> + case 4: key = "UA"; break; /* added by them */
>> + case 5: key = "DU"; break; /* deleted by us */
>> + case 6: key = "AA"; break; /* both added */
>> + 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.
>
> -Peff
>got it. thanks! Jeff