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

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

 



On Tuesday 09 of March 2010 19:35:19 Pavel Roskin wrote:
> And that's where it happens (in the code being checked):
>
> static int do_alg_test(const char *alg, u32 type, u32 mask)
> {
>         return crypto_has_alg(alg, type, mask ?: CRYPTO_ALG_TYPE_MASK) ?
>                0 : -ENOENT;
> }

Thank you for the feedback!  Just a few words to explain what happened.  I 
didn't take the conditional operator into account at all while working on 
this.  Today's patch should not only solve the crash, but also extend the 
enum type analysis for expressions containing conditional operators, so far 
without any test cases ...  and yes, it caused yet another crash instead :-)

> 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?

Kamil
--
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