Implement simple value check and feedback.
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
looks reasonable, but am unsure of all the possible cases for *end given garbage input
Factored out the set_nfs_read_size(), as the r305588 did miss the fact
we have not one but two versions of nfs_getrootfh() and we need to set
the nfs_read_size in both.
Since we can ignore the user provided value, reset the environment
with actually used value so we will not get the repeated messages about
bad value.
lib/libstand/nfs.c | ||
---|---|---|
228 ↗ | (On Diff #23192) | nfs_read_size is (int); while strtol() returns (long); cast accordingly. |
229 ↗ | (On Diff #23192) | Is it legal to check for non-zero errno? I thought errno in general is only set to a non-zero value of failure, but not set to zero on success. So, a previous failure would set errno to non-zero, and it would stay non-zero even if the getenv() succeeded. |
lib/libstand/nfs.c | ||
---|---|---|
229 ↗ | (On Diff #23192) | Right, but I'm not sure that's actually legal. I know in some contexts errno is actually a function-like macro or something wacky, so for example different threads don't stomp on it. Granted, that might not be relevant in the context of the bootloader. :-) In any case, the rule I learned is "never set errno to zero, only to non-zero on failure". |
lib/libstand/nfs.c | ||
---|---|---|
229 ↗ | (On Diff #23192) | Well yes, standalone boot is a special environment and as here we run as one big single threaded app, there is nothing to reset it for us and since libstand does not reset it either, we can have errno set anywhere else and not in strtol() so we can end up having errno == ERANGE from anywhere but strtol() itself:) |