cn-uofbasel / ccn-lite

CCN-lite, a lightweight implementation of the CCNx protocol and its variations
ISC License
74 stars 63 forks source link

replace calls to atoi with strtol #319

Closed mfrey closed 5 years ago

mfrey commented 5 years ago

Description

The function atoi can invoke undefined behavior upon error. See also C11 7.22.1.2. The corresponding calls would be

/** atoi */
(int)strtol(nptr, (char **)NULL, 10)
/** atol */
strtol(nptr, (char **)NULL, 10)
/** atoll */
strtoll(nptr, (char **)NULL, 10)
blacksheeep commented 5 years ago

How many a calls of atoi are left in the code?

mfrey commented 5 years ago

How many a calls of atoi are left in the code?

$ git grep atoi | wc -l
42

Seems a reasonable task?

blacksheeep commented 5 years ago

I agree, that we have to replace atoi.

mfrey commented 5 years ago

I agree, that we have to replace atoi.

Same goes for atof.

$ git grep atof | wc -l
5