On 03/08/2016 12:02 AM, Eric Blake wrote:
On 03/05/2016 11:13 AM, Max Reitz wrote:

+    index = atoi(child->name + 9);

Optional: Assert absence of an error:


Indeed, atoi() is worthless, because it cannot do error detection.

unsigned long index;
char *endptr;

index = strtoul(child->name + 9, &endptr, 10);
assert(index >= 0 && !*endptr);

Still incorrect; you aren't handling errno properly for detecting all
errors.  Even better is to use qemu_strtoul(), which already handles
proper error detection.


Will fix this in next version, thanks for pointing it out.

Thanks
        -Xie



Reply via email to