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

Re: Covierty Integration / Improvement

From
Theodore Ts'o <tytso@mit.edu>
Date
Apr 6, 2022, 17:55 UTC
Message-ID
<Yk3UAz3sn9KhMnyf@mit.edu>
In-Reply-To
<nycvar.QRO.7.76.6.2204061620110.379@tvgsbejvaqbjf.bet>
On Wed, Apr 06, 2022 at 05:08:37PM +0200, Johannes Schindelin wrote:
Show 6 quoted lines
> I have fixed Git for Windows' Coverity build and started to sift through
> the 154 new defects reported as of v2.36.0-rc0.
> 
> Sadly, there is now a new class of overwhelming false positives: Coverity
> claims that "strbuf_addstr does not [NUL-]terminate", which is of course
> false.

It should be possible to suppress this by uploading a Coverity model file. See[1] for more details:

[1] https://community.synopsys.com/s/article/practical-example-of-coverity-function-model

I've suppressed a similar issue by using the attribute __nonstring, but I don't think that will work for git, because strbuf->buf really *is* a NUL-terminated string, where as in ext4 we have some fields which are designed to be NUL padded, but it is *not* guaranteed to be NUL-terminated:

#ifndef __nonstring #ifdef __has_attribute #if __has_attribute(__nonstring__) #define __nonstring __attribute__((__nonstring__)) #else #define __nonstring #endif /* __has_attribute(__nonstring__) */ #else # define __nonstring #endif /* __has_attribute */ #endif /* __nonstring */

struct ext2_super_block {
       ...
/*068*/	__u8	s_uuid[16] __nonstring;		/* 128-bit uuid for volume */
/*078*/	__u8	s_volume_name[EXT2_LABEL_LEN] __nonstring;	/* volume name */
       ...
};
(This is needed to suppress warnings by Clang as well.)

Using __nonstring will result in attempts to use s_volume_name in "C" string context to give a warning, which is why this isn't right for strbuf->buf.

Cheers,
						- Ted
Previous: Johannes SchindelinNext: Junio C Hamano
Message 8 of 13 in “Covierty Integration / Improvement”
  1. Markus VervierApr 1, 2022
  2. Junio C HamanoApr 3, 2022
  3. Theodore Ts'oApr 3, 2022
  4. Ævar Arnfjörð BjarmasonApr 4, 2022
  5. Johannes SchindelinApr 5, 2022
  6. Johannes SchindelinApr 5, 2022
  7. Johannes SchindelinApr 6, 2022
  8. Theodore Ts'oApr 6, 2022
  9. Junio C HamanoApr 6, 2022
  10. Johannes SchindelinApr 7, 2022
  11. Markus VervierApr 7, 2022
  12. Johannes SchindelinApr 7, 2022
  13. Derek ZimmerMay 10, 2022

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.