Farrell Aultman wrote: > The code assumed that when strol is successful, that it will set > errno to zero. This is not the case, at least under uClinux.
It's not the case in general, POSIX doesn't require it to be set to zero. > The man page does not indicate this either. What can happen is that > errno is already set to non-zero before strol is called, then strol > is successful but since strol doesn't reset errno to zero, the next > line thinks that strol failed. That's right. The correct way to call strtol in general, if you're checking errno after, is to set errno to zero before. Since reading errno can be slow (in threaded programs), you might want to check if the result from strtol is LONG_MIN or LONG_MAX before checking errno. -- Jamie
