git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Aug 5, 2016, 21:02 UTC
Message-ID
<20160805210222.a2rvlmioim4psbhw@sigill.intra.peff.net>
In-Reply-To
<1470147137-17498-6-git-send-email-git@jeffhostetler.com>
On Tue, Aug 02, 2016 at 10:12:14AM -0400, Jeff Hostetler wrote:
Show 27 quoted lines
> +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
Previous: Jeff HostetlerNext: Junio C Hamano
Message 14 of 31 in “status: V2 porcelain status”
  1. 0/8 status: V2 porcelain statusJeff Hostetler, Aug 2, 2016
  2. 2/8 status: cleanup API to wt_status_printJeff Hostetler, Aug 2, 2016
  3. Junio C HamanoAug 3, 2016
  4. Jeff HostetlerAug 4, 2016
  5. 3/8 status: support --porcelain[=<version>]Jeff Hostetler, Aug 2, 2016
  6. Junio C HamanoAug 3, 2016
  7. 8/8 status: tests for --porcelain=v2Jeff Hostetler, Aug 2, 2016
  8. Junio C HamanoAug 5, 2016
  9. Jeff HostetlerAug 5, 2016
  10. 6/8 status: print branch info with --porcelain=v2 --branchJeff Hostetler, Aug 2, 2016
  11. Junio C HamanoAug 5, 2016
  12. Jeff HostetlerAug 5, 2016
  13. 5/8 status: print per-file porcelain v2 status dataJeff Hostetler, Aug 2, 2016
  14. Jeff KingAug 5, 2016
  15. Junio C HamanoAug 5, 2016
  16. Jeff KingAug 5, 2016
  17. Junio C HamanoAug 5, 2016
  18. Stefan BellerAug 5, 2016
  19. Stefan BellerAug 5, 2016
  20. Jeff HostetlerAug 5, 2016
  21. 7/8 git-status.txt: describe --porcelain=v2 formatJeff Hostetler, Aug 2, 2016
  22. Junio C HamanoAug 5, 2016
  23. Jeff HostetlerAug 5, 2016
  24. 1/8 status: rename long-format print routinesJeff Hostetler, Aug 2, 2016
  25. Junio C HamanoAug 3, 2016
  26. Jeff HostetlerAug 4, 2016
  27. 4/8 status: per-file data collection for --porcelain=v2Jeff Hostetler, Aug 2, 2016
  28. Johannes SchindelinAug 3, 2016
  29. Junio C HamanoAug 3, 2016
  30. Johannes SchindelinAug 3, 2016
  31. Junio C HamanoAug 3, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.