diff options
author | Rasmus Villemoes <rasmus.villemoes@prevas.dk> | 2018-09-12 16:06:37 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-10-31 11:28:37 +0100 |
commit | 656ca7bdd992f6aabbdd5cadbac5241f6e1971a1 (patch) | |
tree | f2948b0bab0043df0eced761ad1d2499b0a37fca | |
parent | 571e525a141a2de87b9c2ced485745e96418d921 (diff) | |
download | busybox-w32-656ca7bdd992f6aabbdd5cadbac5241f6e1971a1.tar.gz busybox-w32-656ca7bdd992f6aabbdd5cadbac5241f6e1971a1.tar.bz2 busybox-w32-656ca7bdd992f6aabbdd5cadbac5241f6e1971a1.zip |
libbb/u_signal_names.c: don't check errno after bb_strtou
Since we're comparing the return value to a smallish integer anyway, we
might as well use that bb_strtou() returns UINT_MAX for malformed
input. Referencing errno is kinda bloaty on glibc.
While NSIG is not in POSIX, we do already rely on it being defined,
compile-time const and smallish, since arrays in struct globals_misc are
defined in terms of it.
function old new delta
get_signum 312 286 -26
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/u_signal_names.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c index 866ca85fd..f7d598c7a 100644 --- a/libbb/u_signal_names.c +++ b/libbb/u_signal_names.c | |||
@@ -153,8 +153,12 @@ int FAST_FUNC get_signum(const char *name) | |||
153 | { | 153 | { |
154 | unsigned i; | 154 | unsigned i; |
155 | 155 | ||
156 | /* bb_strtou returns UINT_MAX on error. NSIG is smaller | ||
157 | * than UINT_MAX on any sane Unix. Hence no need | ||
158 | * to check errno after bb_strtou(). | ||
159 | */ | ||
156 | i = bb_strtou(name, NULL, 10); | 160 | i = bb_strtou(name, NULL, 10); |
157 | if (!errno && i < NSIG) /* for shells, we allow 0 too */ | 161 | if (i < NSIG) /* for shells, we allow 0 too */ |
158 | return i; | 162 | return i; |
159 | if (strncasecmp(name, "SIG", 3) == 0) | 163 | if (strncasecmp(name, "SIG", 3) == 0) |
160 | name += 3; | 164 | name += 3; |
@@ -204,7 +208,7 @@ int FAST_FUNC get_signum(const char *name) | |||
204 | return sigrtmin; | 208 | return sigrtmin; |
205 | if (name[5] == '+') { | 209 | if (name[5] == '+') { |
206 | i = bb_strtou(name + 6, NULL, 10); | 210 | i = bb_strtou(name + 6, NULL, 10); |
207 | if (!errno && i <= sigrtmax - sigrtmin) | 211 | if (i <= sigrtmax - sigrtmin) |
208 | return sigrtmin + i; | 212 | return sigrtmin + i; |
209 | } | 213 | } |
210 | } | 214 | } |
@@ -213,7 +217,7 @@ int FAST_FUNC get_signum(const char *name) | |||
213 | return sigrtmax; | 217 | return sigrtmax; |
214 | if (name[5] == '-') { | 218 | if (name[5] == '-') { |
215 | i = bb_strtou(name + 6, NULL, 10); | 219 | i = bb_strtou(name + 6, NULL, 10); |
216 | if (!errno && i <= sigrtmax - sigrtmin) | 220 | if (i <= sigrtmax - sigrtmin) |
217 | return sigrtmax - i; | 221 | return sigrtmax - i; |
218 | } | 222 | } |
219 | } | 223 | } |