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

Re: [PATCH 5/7] vcs-svn: fix cppcheck warning

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 24, 2012, 14:20 UTC
Message-ID
<20120524142058.GA3732@burratino>
In-Reply-To
<1337868259-45626-6-git-send-email-davidbarr@google.com>
Hi,
First, thanks much for this series!  I especially like patch #4.
David Barr wrote:
> [vcs-svn/fast_export.c:211]: (warning) Using sizeof with a numeric constant
> as function argument might not be what you intended.
[...]
> -		assert(!signed_add_overflows(preimage.max_off, 1));
> +		assert(!signed_add_overflows(preimage.max_off, (off_t) 1));

I think this is due to a typo in the compat-util.h compatibility layer you are using. In git.git there is

	#define signed_add_overflows(a, b) \
	    ((b) > maximum_signed_value_of_type(a) - (a))

so the sizeof() operator is applied to preimage.max_off and all is well. By contrast, in svn-dump-fast-export.git it says

	#define signed_add_overflows(a, b) \
		((a) > maximum_signed_value_of_type(b) - (b))

Though the comment describing signed_add_overflows() does say that "a" and "b" should have the same type, I like being able to ask if signed_add_overflows(n, 1) in a non-fussy way that does not introduce subtle bugs when the type of "n" changes, so I'd prefer not to take this patch.

Hope that helps, Jonathan

Previous: David BarrNext: David Michael Barr
Message 9 of 14 in “vcs-svn: housekeeping”
  1. 0/7 vcs-svn: housekeepingDavid Barr, May 24, 2012
  2. 1/7 vcs-svn: prefer constcmp to prefixcmpDavid Barr, May 24, 2012
  3. 2/7 vcs-svn: prefer strstr over memmemDavid Barr, May 24, 2012
  4. 3/7 vcs-svn: fix signedness warningsDavid Barr, May 24, 2012
  5. Jonathan NiederMay 24, 2012
  6. David Michael BarrMay 31, 2012
  7. 4/7 vcs-svn: drop no-op reset methodsDavid Barr, May 24, 2012
  8. 5/7 vcs-svn: fix cppcheck warningDavid Barr, May 24, 2012
  9. Jonathan NiederMay 24, 2012
  10. David Michael BarrMay 31, 2012
  11. 6/7 vcs-svn: fix clang-analyzer errorDavid Barr, May 24, 2012
  12. 7/7 vcs-svn: fix clang-analyzer warningDavid Barr, May 24, 2012
  13. Jonathan NiederMay 24, 2012
  14. David Michael BarrMay 31, 2012

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.