[libvirt] [PATCHv2] maint: Kill usage of atoi()

Peter Krempa pkrempa at redhat.com
Fri Nov 15 09:47:40 UTC 2013


On 11/14/13 22:53, Eric Blake wrote:
> On 11/14/2013 02:22 PM, Peter Krempa wrote:
> 
>>>> +
>>>> +exclude_file_name_regexp--sc_prohibit_atoi= \
>>>> +	^examples/.*\.[ch]$$
>>>
>>> Drop this hunk.  None of our examples/* use atoi to begin with, so
>>> there's no reason to exclude them from the syntax check.
>>>
>>> ACK with those fixes.
>>>
>>
>> This isn't true unfortunately:
> 
> Huh, wonder what grep I did that missed that fact?
> 
>>
>> ~/libvirt $ git grep atoi examples/
>> examples/domsuspend/suspend.c:        id = atoi(argv[1]);
>>
>> and I wanted to avoid changing that file. But if you insist I can tune
>> that one too.
> 
> Yes, it's worth fixing, because our examples should never teach people
> to use bad coding practices.  atoi() is broken by design, and strtol(),
> while more awkward to use, is just as portably present as atoi().
> 

Well, the file is a bad example by itself. The first issue would be that
it doesn't work. It tries to suspend(pause) a VM using the RO connection.

That file should be refactored as a whole piece instead of trying to
polish parts that won't even work.

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131115/1ddc3965/attachment-0001.sig>


More information about the libvir-list mailing list