On Thu, Mar 25, 2010 at 11:17 AM, Liu Aleaxander <aleaxander@xxxxxxxxx> wrote: > Hi Yann, > > On Thu, Mar 25, 2010 at 5:05 AM, Yann Droneaud <yann@xxxxxxxxxxx> wrote: >> >> Le mercredi 24 mars 2010 à 14:38 +0800, Liu Aleaxander a écrit : >> >> > + if (offset) { >> > + int ret = 0; >> > + if (offset[0] == '0' && offset[1] == 'x') >> > + ret = sscanf(offset, "%llx", &off); >> > + else >> > + ret = sscanf(offset, "%llu", &off); >> > + if (ret != 1) >> > + usage(); >> > + } >> > >> >> Why not using strtoull(), which handle decimal, hexadecimal and octal >> for free ? >> > > Thanks for your good point. But I found that the strtoull can't > recognize the difference between non-digit case and zero number > case, since it will both returns 0. This is exactly why you should check the second value-result parameter of strtoul(). -- To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html