Thread (19 messages) flat view 19 messages, 5 authors, 2016-08-05

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

From: Jeff King <hidden>
Date: 2016-08-05 21:02:32

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help