-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove strtou[l]l_noneg(), replacing them by a2i() calls #895
Remove strtou[l]l_noneg(), replacing them by a2i() calls #895
Conversation
c21f32d
to
bce02f8
Compare
bce02f8
to
87dfdbd
Compare
ccf1910
to
5e0df30
Compare
5e0df30
to
143eda5
Compare
143eda5
to
d86f557
Compare
9391bf2
to
4015fd5
Compare
b23f9c0
to
4c75179
Compare
v2 changes:
|
4c75179
to
096cce6
Compare
v2b changes:
|
096cce6
to
8fb1abf
Compare
v2c changes:
|
8fb1abf
to
07e26fe
Compare
v2d changes:
|
07e26fe
to
eb1290d
Compare
v2e changes:
|
This comment was marked as resolved.
This comment was marked as resolved.
eb1290d
to
857f2e9
Compare
v2f changes:
|
857f2e9
to
80ad37b
Compare
80ad37b
to
110447b
Compare
@lamby |
110447b
to
fbe6d9b
Compare
} else { | ||
/* Valid */ | ||
return epoch; | ||
if (a2i(time_t, &epoch, source_date_epoch, NULL, 10, 0, fallback) == -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lamby Should we accept negative values? Why did this use strtoull(1) originally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm blocked until this questions is answered. Feel free to close it and merge the PR at your convenience
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the patches and the explanations.
time_t isn't necessarily unsigned (in fact, it's likely to be signed. Therefore, parse the number as the right type, via a2i(time_t, ...). Still, reject negative numbers, just to be cautious. It was done before (strtoull_noneg()), so it shouldn't be a problem. (However, strtoull_noneg() was only introduced recently, and before that we called strtoull(3), which silently accepted negative values.) Remove the limitation of ULONG_MAX, which seems arbitrary. It probably was written in times where 'time_t' had the same length of 'long', and this was thus a test that the value didn't overflow 'time_t'. Such a test is implicit in the a2i() call, so forget about it. Unify the error messages into a single one that provides all the info (except the value of 'fallback'). Link: <shadow-maint@cb610d5#r136407772> Reviewed-by: Iker Pedrosa <[email protected]> Cc: Chris Lamb <[email protected]> Cc: Serge Hallyn <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
…unction All call sites were replaced by a2i() recently. Reviewed-by: Iker Pedrosa <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
It is a simpler call, with more type safety. A consequence of this change is that the program now accepts numbers in bases 8 and 16. That's not a problem here, I think. Reviewed-by: Iker Pedrosa <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
…nction All call sites have been replaced by functions from "atoi/a2i.h" and "atoi/str2i.h" recently. Reviewed-by: Iker Pedrosa <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
fbe6d9b
to
15af2f3
Compare
Revisions:
v3
v3 changes:v3b
v3c
v3d