Re: Sparse crash when mixing int and enum in ternary operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 21, 2010 at 8:27 AM, Kamil Dudka <kdudka@xxxxxxxxxx> wrote:
> On Saturday 13 of March 2010 18:22:48 Kamil Dudka wrote:
>> I was unsuscessfully looking for an implementation of stack within sparse.
>> So that I used the implicit one instead.  I know it's pretty bad idea, but
>> I am not aware of any easy way to handle it better.
>
> I could probably use a list instead.  Nevertheless the evaluation of EXPR_COND
> also works recursively on the runtime stack - see evaluate_expression() and
> evaluate_conditional_expression().  So that I don't think it's an actual
> problem here.
>
> Let me know if the patch needs some additional improvements.


Hi Kamil,

I take a look at the new patch. BTW, you don't need to do assert(0),
you can use die() for that.

Currently if I run sparse over the parse.c, it will generate a lot of
new warnings.

$ ./sparse -D__x86_64__=1 parse.c
parse.c:1564:67: warning: conversion of
parse.c:1564:67:     int to
parse.c:1564:67:     int enum namespace
expression.h:202:76: warning: conversion of
expression.h:202:76:     int to
expression.h:202:76:     int enum namespace
expression.h:202:76: warning: conversion of
expression.h:202:76:     int to
expression.h:202:76:     int enum namespace
parse.c:182:30: warning: conversion of
parse.c:182:30:     int to
parse.c:182:30:     int enum keyword
parse.c:208:30: warning: conversion of
parse.c:208:30:     int to
parse.c:208:30:     int enum keyword
parse.c:215:30: warning: conversion of
parse.c:215:30:     int to
parse.c:215:30:     int enum keyword
parse.c:235:30: warning: conversion of
parse.c:235:30:     int to
parse.c:235:30:     int enum keyword
parse.c:482:12: warning: symbol 'ignored_attributes' was not declared.
Should it be static?
parse.c:619:22: warning: conversion of
parse.c:619:22:     int to
parse.c:619:22:     int enum statement_type
parse.c:1426:61: warning: conversion of
parse.c:1426:61:     int to
parse.c:1426:61:     int enum namespace
expression.h:202:76: warning: conversion of
expression.h:202:76:     int to
expression.h:202:76:     int enum namespace
parse.c:1533:67: warning: conversion of
parse.c:1533:67:     int to
parse.c:1533:67:     int enum namespace
expression.h:202:76: warning: conversion of
expression.h:202:76:     int to
expression.h:202:76:     int enum namespace
expression.h:202:76: warning: conversion of
expression.h:202:76:     int to
expression.h:202:76:     int enum namespace
expression.h:202:76: warning: conversion of
expression.h:202:76:     int to
expression.h:202:76:     int enum namespace


That is just too much. Most of the warning is coming from enum or operation.
e.g.
.type = KW_SPECIFIER | KW_SHORT,
lookup_keyword(token->ident, NS_KEYWORD | NS_TYPEDEF);

I think those source are fine. Force enum cast there make the source code
lworse. We can add special case for enum OR enum, more special cases.
But where is the end?

It comes down to we try to treat enum as a different type than int. It seems
works for the simple case. But in real world, people do use enum as int type
and expect enum can mix with int.

At this point I am leaning towards moving this enum warning to a topic branch.
Let the people who want to use it play with it first. It currently
give too many warning.
If people do feel that warning is useful, even bette, it catch some real bugs. I
will consider merge it again.

You obvious spend a lot of time on this. I feel bad about pushing it back too.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux