[PATCH] Fix string to integer conversion

Swen Schillig SCHILLIG at de.ibm.com
Mon Feb 25 13:00:34 UTC 2019

I guess I misunderstood your comment below

>The patchset introduces an additional error check in the callers in some places where only the return error is checked,
>causing an error log message or even a failure in the caller.
>The problem is, according to POSIX/SUS, strtoul and friends are not *required* to set errno to EINVAL "in case no conversion was >performed". The implementation of strtoul[l]_err() doesn't set it, it just returns the errno from strtoul.
The POSIX standard says that errno doesn't need to be set if an error occured but we can be sure that IF IT WAS SET 
then we do have an error...and nothing else is implemented with the new functions.
We do NOT flag an error if there wasn't one.

>If strtoul[l]_err() returns an error, it must be reliable. While this could be addressed by returning EINVAL for the "no conversion >was performed" case, it still leaves us with a strange API.

How should we detect an error if not via errno ?
If we decide errno is not good enough for us and we should scan the provided string and the results ourselves,
then we may as well develop our own conversion routine.
But I believe that would be overkill and as far as I remember it was NOT wanted to introduce a new behaviour.

What we have at hand is by far better than what was there, but it is, like all code, not perfect. 
Mit freundlichen Grüßen / Best Regards  
Swen Schillig  

 Spectrum Scale Development  
IBM Systems & Technology Group  
Email: schillig at de.ibm.com  
IBM Deutschland Research & Development GmbH  
Am Weiher 24  
65451 Kelsterbach  

More information about the samba-technical mailing list