From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Lars Schneider <larsxschneider@gmail.com>,
GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH] usage: add NORETURN to BUG() function definitions
Date: Tue, 23 May 2017 21:47:52 +0100 [thread overview]
Message-ID: <84e547c2-8a5b-225c-1363-361e091821f4@ramsayjones.plus.com> (raw)
In-Reply-To: <xmqqpof0memv.fsf@gitster.mtv.corp.google.com>
On 23/05/17 04:32, Junio C Hamano wrote:
> Interesting. One thing that I found somewhat suboptimal is that we
> do not get signalled by non-zero exit.
Warnings don't lead to non-zero exit, but similarly to -Werror, you can
provide a -Wsparse-error to turn warnings into errors:
$ make builtin/worktree.sp
SP builtin/worktree.c
builtin/worktree.c:539:38: warning: Using plain integer as NULL pointer
$
$ make SPARSE_FLAGS=-Wsparse-error builtin/worktree.sp
SP builtin/worktree.c
builtin/worktree.c:539:38: error: Using plain integer as NULL pointer
Makefile:2370: recipe for target 'builtin/worktree.sp' failed
make: *** [builtin/worktree.sp] Error 1
$
Unfortunately, that does not help too much because, as I mentioned before,
one warning is actually a sparse problem (and you can't turn it off):
$ make pack-revindex.sp
SP pack-revindex.c
pack-revindex.c:64:23: warning: memset with byte count of 262144
$
This is caused by sparse _unconditionally_ complaining about the byte count
used in calls to memset(), memcpy(), copy_to_user() and copy_from_user().
In addition, the byte count limits are hard-coded (v <= 0 || v > 100000).
About a decade ago, I wrote a patch to enable/set the limit value from the
command line, but didn't get around to sending the patch upstream. :-D
[There is actually another problem warning, if you build with NO_REGEX=1].
Since cgcc was intended to be used as proxy for gcc, you might think you
could use CC=cgcc on a regular build, but that has problems of it's own:
$ make clean >/dev/null 2>&1 # on 'pu' branch, build output in 'pout'
$ make CC=cgcc >pout1 2>&1
$ diff pout pout1
99a100
> pack-revindex.c:64:23: warning: memset with byte count of 262144
199a201
> imap-send.c:1439:9: warning: expression using sizeof on a function
200a203,207
> http.c:675:9: warning: expression using sizeof on a function
> http.c:1676:25: warning: expression using sizeof on a function
> http.c:1681:25: warning: expression using sizeof on a function
> http.c:2082:9: warning: expression using sizeof on a function
> http.c:2249:9: warning: expression using sizeof on a function
219a227
> http-walker.c:377:9: warning: expression using sizeof on a function
222a231,233
> http-push.c:189:9: warning: expression using sizeof on a function
> http-push.c:200:9: warning: expression using sizeof on a function
> http-push.c:202:9: warning: expression using sizeof on a function
228a240,243
> remote-curl.c:524:9: warning: expression using sizeof on a function
> remote-curl.c:605:17: warning: expression using sizeof on a function
> remote-curl.c:608:17: warning: expression using sizeof on a function
> remote-curl.c:676:9: warning: expression using sizeof on a function
374a390
> builtin/worktree.c:539:38: warning: Using plain integer as NULL pointer
...
$
See commit 9371322a60 (sparse: suppress some "using sizeof on a function"
warnings, 06-10-2013) for an explanation of the additional warnings.
I chose the SPARSE_FLAGS method to suppress those warnings, precisely
because I don't build git that way. (git grep -n SPARSE_FLAGS).
So, using CC='cgcc -Wsparse-error' as it stands isn't much help:
$ make clean >/dev/null 2>&1
$ make CC='cgcc -Wsparse-error'
GIT_VERSION = 2.13.0.530.g896b4ae59
* new build flags
CC credential-store.o
* new link flags
CC common-main.o
...
CC pack-objects.o
CC pack-revindex.o
pack-revindex.c:64:23: error: memset with byte count of 262144
Makefile:2036: recipe for target 'pack-revindex.o' failed
make: *** [pack-revindex.o] Error 1
$
> Otherwise it would make a
> good addition to the "Static Analysis" task in .travis.yml file.
Unfortunately, some additional work required. :-P
ATB,
Ramsay Jones
next prev parent reply other threads:[~2017-05-23 20:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-21 22:25 [PATCH] usage: add NORETURN to BUG() function definitions Ramsay Jones
2017-05-22 1:43 ` Junio C Hamano
2017-05-22 2:13 ` Ramsay Jones
2017-05-22 2:35 ` Junio C Hamano
2017-05-22 2:46 ` Junio C Hamano
2017-05-22 14:02 ` Ramsay Jones
2017-05-23 3:32 ` Junio C Hamano
2017-05-23 20:47 ` Ramsay Jones [this message]
2017-05-22 11:19 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84e547c2-8a5b-225c-1363-361e091821f4@ramsayjones.plus.com \
--to=ramsay@ramsayjones.plus.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=larsxschneider@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).