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

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

 



On Tue, 2010-03-09 at 11:15 -0800, Josh Triplett wrote:
> On Tue, Mar 09, 2010 at 08:06:23PM +0100, Kamil Dudka wrote:
> > On Tuesday 09 of March 2010 19:35:19 Pavel Roskin wrote:
> > > I removed the outside conditional, and sparse would still crash on this:
> > >
> > > crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK);
> > >
> > > but not on this:
> > >
> > > crypto_has_alg(alg, type, mask ? mask: CRYPTO_ALG_TYPE_MASK);
> > >
> > > Apparently, the "?:" notation is confusing sparse now.
> > 
> > To be frank, I've never seen that notation before.  From what I understand, 
> > the variants above should be equivalent with each other, right?
> 
> Yes, except that the first variant would not evaluate "mask" twice, even
> if it consisted of an expression with side effects.  See
> http://gcc.gnu.org/onlinedocs/gcc/Conditionals.html .
> 
> (When I go to look up something in the GCC manual, more often than not I
> end up in Chapter 6, "Extensions to the C Language Family". :) )

Ironically, the fix for :? may benefit from that operator:

do_warn_for_enum_conversions(expr->cond_true ?: expr->conditional, type);
do_warn_for_enum_conversions(expr->cond_false ?: expr->conditional, type);

At least I was able to run sparse on the whole kernel (wireless-testing,
which is based on 2.6.34-rc1) without crashing or reporting anything
strange.

Actually, omitting the false conditional appears to be invalid.

-- 
Regards,
Pavel Roskin
--
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