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 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
--
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]