Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Possible unsafe use of strncat in sbin/sysctl/sysctl.c
Am 24.08.11 02:11, schrieb Johnny Billquist:
> On 2011-08-24 00:22, Marc Balmer wrote:
>> Am 24.08.11 00:08, schrieb Joerg Sonnenberger:
>>> On Tue, Aug 23, 2011 at 09:58:53PM +0000, David Holland wrote:
>>>> On Tue, Aug 23, 2011 at 11:52:11PM +0200, Marc Balmer wrote:
>>>> > (void)wait! That was a pure personal remark. I really don't
>>>> know where
>>>> > that (void)bla idiom comes from, and I obviously don't
>>>> (void)like it.
>>>>
>>>> It's an artifact of our stupid lint(1).
>>>
>>> Not really, it is used by other analyzers to mean "yes, I know this
>>> returns something, but I don't care". The major exception of course is
>>> that GCC broke it for the attributed usage -- half of the pain of
>>> dealing with modern glibc in this regard.
>>
>> But that is kind of, well, unneeded. A compiler can detect that I don't
>> use the return value by seeing that I don't use the return value.
>>
>> Why tell the compiler that I don't want to use the return value? It's a
>> stupid rule, to say the least.
>
> How do you distinguish between:
>
> "I ignore the return value of this function. I know this, I'm prefectly
> happy with that, and it is intentional."
>
> ...and...
>
> "I forgot to check the return value."
>
> ...otherwise?
>
> Both cases mean I don't use the return value. But in one case, this is
> ok, while in the other, it's a bug. Do your compiler know something I
> don't?
I think this is not a valid reasoning: What if I, to silence a tool,
choose to blindly insert (void), instead of checking the return value?
I can always create bugs, and spilling (void) all over only helps maybe
a tiniy fraction of them.
>
> Johnny
>
>>
>> Next thing will be adding a (really) and (maybe) statement to functions
>> which we really or maybe want to execute, and maybe (never) for
>> functions that we never call:
>>
>> int (really)
>> main(int argc, char *argc[])
>> {
>> }
>>
>>
>> int (maybe)
>> othermain(void)
>> {
>> }
>>
>> void (never)
>> dontdothisathome(void)
>> {
>> /* NOTREACHED */
>> }
>>
>
>
--
\~~~~~. The NetBSD Foundation
\~~~~~' Marc Balmer, Developer / Marketing
NetBSD
\ mbalmer%NetBSD.org@localhost http://www.NetBSD.org/
Home |
Main Index |
Thread Index |
Old Index