linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joey Pabalinas <joeypabalinas@gmail.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Joey Pabalinas <joeypabalinas@gmail.com>,
	linux-sparse@vger.kernel.org, Kees Cook <keescook@chromium.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Martin Uecker <Martin.Uecker@med.uni-goettingen.de>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Christopher Li <sparse@chrisli.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] add -Wpointer-arith sparse flag to toggle sizeof(void) warnings
Date: Mon, 9 Apr 2018 12:51:01 -1000	[thread overview]
Message-ID: <20180409225101.uzztpdv6bbjmlwwr@gmail.com> (raw)
In-Reply-To: <20180408074823.fgrmtrjzzjb7dlt2@ltop.local>

[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]

On Sun, Apr 08, 2018 at 09:48:24AM +0200, Luc Van Oostenryck wrote:
> With the warning disabled by default (for the moment), I had to adapt
> the testsuite with:

Ah, so should I include that change in the patch itself when I make a V3?

> > +Warn about anything that depends on the \fBsizeof\fR a function type or of void.
> 
> Maybe it would be useful to add something along the line of "like directly using
> the sizeof operator on void or doing pointer arithmetic on a void pointer" ?

I actually just took the explanation straight from the GCC man page
since I figured the explanation should match (as the flag itself is
basicallt copied).

But I do sort of like your wording of it more, so if no one else sees
any reasons to _not_ to diverge from GCC's wording here I have no problem
changing that.

> > +Although non-standard (and somewhat illogical), constructs such as \fBsizeof(void)\fR
> > +are often useful when the intent is to operate on an expression without evaluating
> > +it, e.g. in the following integer constant expression predicate:
> > +.nf
> > +#define __is_constexpr(x) \\
> > +	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
> > +.fi
> 
> I think that pointer arithmetic is much more useful than taking the size of void
> (being able to take the size of *any* thing is somewhere in the middle, IMO).
> But in all case, I don't think this part should belong to the man page.

Also have no problem eliding this section if no one else has any
good arguments for keeping it.

-- 
Cheers,
Joey Pabalinas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-04-09 22:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07 21:58 [PATCH v2] add -Wpointer-arith sparse flag to toggle sizeof(void) warnings Joey Pabalinas
2018-04-07 22:05 ` Linus Torvalds
2018-04-08  7:48 ` Luc Van Oostenryck
2018-04-09 22:51   ` Joey Pabalinas [this message]
2018-04-10  0:59     ` Joey Pabalinas

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180409225101.uzztpdv6bbjmlwwr@gmail.com \
    --to=joeypabalinas@gmail.com \
    --cc=Martin.Uecker@med.uni-goettingen.de \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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.
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 NNTP newsgroup(s).