tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Reuse strtonum(3) and reallocarray(3) from OpenBSD



On Dec 28,  4:06am, n54%gmx.com@localhost ("Kamil Rytarowski") wrote:
-- Subject: Re: Reuse strtonum(3) and reallocarray(3) from OpenBSD

| We can ignore return values, but the duplication still occurs as there is possibility to check for an event in two distinct ways. For me API should be designed without such possibilities.

It is not exactly duplication but, sure please suggest something better.

| 1 - wrong base go for EINVAL as default for strtol(3)-like funs
| 2 - wrong range there is ERANGE always (you was right about it before)
| 3 - partial conversion hmmm I consider having it for fullstrtoi(3) as valid, but not for the original strtoi(3)

Ok.

| > Suffers from the original strtol() problem, if lo == INTMAX_MIN or
| > hi == INTMAX_MAX, so we've come full cycle.
| > christos
| > 
| 
| No it doesn't suffer. When abstracting information we always lost information.
| For those who want to see difference between overflow (ERANGE) and out of range (ERANGE)
| there is strtol(3) intended.
| 
| My intention is not to make a orchestra function (that even by design must duplicate information),
| but to step by step make strtol(3) as simple as atoi(3).
| With this direction we lost information with every step, for those who need the details,
| there are strtoi(3) and strtol(3).
| 
| No full cycle, I see how we make progress! And I started to disliking strtonum(3) seeing what we have now ;-)

It is full circle; you can't tell the difference between an INTMAX_MAX
return that was clipped and one that was not without setting errno
to 0 before calling your new function.

christos


Home | Main Index | Thread Index | Old Index