Re: Sparse parsing question: string literal

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

 



On Sun, Aug 20, 2017 at 12:31 PM, Derek M Jones <derek@xxxxxxxxxxxx> wrote:
>
>
> It's a question of intent.
>
> sizeof(function_name) was written, but was
> sizeof(function_name()) intended?

The case I saw was for as part of the structure initialization.
It want to store the generic object and its size.
So it has { .... , function_name, sizeof(function_name), .... }
some thing like that.

For that usage I am pretty sure it is sizeof(&function_name).

But you are right the other way to guess the intend can be
sizeof(function_name()).


>
> Of course sizeof(&function_name) may have been written, but
> sizeof(&function_name()) was intended.  But that & is an
> unusually thing to include in a function call, which makes it
> less likely that () were accidentally omitted.
>
> Is it reasonable to require people to add & to signal,
> yes I really do mean pointer to function?  The indignity
> if having to type that extra character!
>
> I'm inclined towards generating warnings, since there is a
> way of making the warning to go away, e.g., add & or ().

OK, that make sense. The warning should stay.

Thanks

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