Re: [dev] fsbm

From: <k0ga_AT_shike2.com>
Date: Fri, 7 Nov 2014 11:40:03 +0100

>> > * Use strtonum() or estrtol() from sbase instead of atoi().
>>
>> I agree here if the string comes from the user. If the string
>> is an internal string then there is no problem with atoi.
>
> It is generally unlikely that the string has been validated to
> be an integer before getting to atoi(). With atoi() you cannot
> distinguish between an invalid integer and 0.

There are a lot of cases where it is validated, for example
if you used first a regular expression to filter lines. There
are also a lot of uses where doesn't mind the difference
between 0 and no integer (for example sort -n). There
are also a lot of cases where 0 is not a valid value.

> Generally speaking, it should never be used.

'should never be used' is not a very general sentence.

But, ok. This is a personal taste (this and the other question
about strlcpy), and I don't want to begin a war.

Regards,
Received on Fri Nov 07 2014 - 11:40:03 CET

This archive was generated by hypermail 2.3.0 : Fri Nov 07 2014 - 11:48:08 CET