linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamil Dudka <kdudka@redhat.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Josh Triplett <josh@joshtriplett.org>,
	Pavel Roskin <proski@gnu.org>,
	linux-sparse@vger.kernel.org
Subject: Re: Sparse crash when mixing int and enum in ternary operator
Date: Mon, 29 Mar 2010 21:23:40 +0200	[thread overview]
Message-ID: <201003292123.40443.kdudka@redhat.com> (raw)
In-Reply-To: <70318cbf1003291148w6b338b25v6801c3ec146af0f9@mail.gmail.com>

On Mon March 29 2010 20:48:38 Christopher Li wrote:
> On Mon, Mar 29, 2010 at 11:17 AM, Kamil Dudka <kdudka@redhat.com> wrote:
> > On Mon March 29 2010 20:05:08 Christopher Li wrote:
> >> Using enum namespace for member "namespace" has benefit here. It is
> >> clear that which set of value it belongs to. E.g. if you assign
> >> SYM_NODE into "namespace" member it *looks* is obvious wrong.
> > 
> > We are able to catch assignment of SYM_NODE to 'enum namespace'.  But we
> > are not able to catch (SYM_NODE | SYM_ENUM) to 'enum namespace', so that
> > the patch makes no difference.  Or am I missing anything?
> 
> I am refering to your patch in other email:
> 
> struct symbol_op {
> -          enum keyword type;
> +         int type;
> 
> That is worse. Because you make type as plain int, I can assign NS_KEYWORD

Have you tried it with sparse without my patch applied?  You indeed can assign 
NS_KEYWORD to 'enum keyword' and sparse is silent ;-)

> there and you wouldn't able to catch any thing right? So you make the enum
> so strict that
> we can't use it any more.
> 
> Currently the compiler might not able to catch it. But it look obvious
> wrong to human
> eye if you assign other class of enum there.

Type-info makes sense for compilers, analyzers, etc.  If you treat it as 
plain-text information for humans with no underlying support of that tools, 
it's equal to Hungarian notation IMO.

> > I don't think the code looks worse, nevertheless respect your attitude.
> 
> See my previous comment.
> 
> I just want to make sense of this thing. Currently I see a lot of down
> sides, forcing people to do more explicit cast or avoid using the enum
> type completely. What is the up side again?
> 
> Remember, too much warning can be a bad thing as well. It makes people
> don't want
> to use the tool or just turn off the warning completely. When I run sparse
> over its own source code, I consider those warning useless because I don't
> have a better
> way to fix it. I think the source code is fine as it is.

Sure, I don't object it anyhow.  As a C++ programmer I've certainly different 
attitude to type safety, thus biased.  I believe kernel developers would more 
likely agree with your point of view.

> BTW, I have move the enum warning to a new branch:
> 
> http://git.kernel.org/?p=devel/sparse/sparse.enum-warning.git;a=summary
> 
> Some people might find it useful in special occasions. I want to heard
> about it.

Looks great, though it really wasn't my intention to fork anything :-)

Kamil

  reply	other threads:[~2010-03-29 19:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09  1:24 Sparse crash when mixing int and enum in ternary operator Pavel Roskin
2010-03-09  5:43 ` Christopher Li
2010-03-09 13:46   ` Kamil Dudka
2010-03-09 18:26     ` Pavel Roskin
2010-03-09 18:35     ` Pavel Roskin
2010-03-09 19:06       ` Kamil Dudka
2010-03-09 19:15         ` Josh Triplett
2010-03-09 20:11           ` Pavel Roskin
2010-03-09 20:29             ` Kamil Dudka
2010-03-09 23:30               ` Kamil Dudka
2010-03-10  1:09                 ` Pavel Roskin
2010-03-10 16:05                   ` Kamil Dudka
2010-03-10 20:27                     ` Pavel Roskin
2010-03-10 20:44                       ` Kamil Dudka
2010-03-10 21:03                       ` Kamil Dudka
2010-03-10 21:56                     ` Christopher Li
2010-03-13 17:22                       ` Kamil Dudka
2010-03-21 15:27                         ` Kamil Dudka
2010-03-24 10:07                           ` Christopher Li
2010-03-24 10:51                             ` Kamil Dudka
2010-03-27  9:16                             ` Kamil Dudka
2010-03-27  9:29                               ` Josh Triplett
2010-03-27  9:53                                 ` [PATCH] eliminate insane conversions from int to enum Kamil Dudka
2010-03-29 18:11                                   ` Christopher Li
2010-03-29 18:05                                 ` Sparse crash when mixing int and enum in ternary operator Christopher Li
2010-03-29 18:17                                   ` Kamil Dudka
2010-03-29 18:48                                     ` Christopher Li
2010-03-29 19:23                                       ` Kamil Dudka [this message]
2010-03-30  5:29                                         ` Pavel Roskin
2010-03-29 21:26                                   ` Josh Triplett

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=201003292123.40443.kdudka@redhat.com \
    --to=kdudka@redhat.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=proski@gnu.org \
    --cc=sparse@chrisli.org \
    /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).