diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-12 22:10:34 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2007-01-12 22:10:34 +0000 |
commit | d3bcc434bbc51143284e0108521b97f961c144d2 (patch) | |
tree | 09708579e18a033c6722c5194c46116705f47b83 /libbb | |
parent | 0a0339cfc16667f8f41a0cb0cfe4c50543e9c251 (diff) | |
download | busybox-w32-d3bcc434bbc51143284e0108521b97f961c144d2.tar.gz busybox-w32-d3bcc434bbc51143284e0108521b97f961c144d2.tar.bz2 busybox-w32-d3bcc434bbc51143284e0108521b97f961c144d2.zip |
random small size optimizations
git-svn-id: svn://busybox.net/trunk/busybox@17263 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/messages.c | 1 | ||||
-rw-r--r-- | libbb/read.c | 2 | ||||
-rw-r--r-- | libbb/xfuncs.c | 13 |
3 files changed, 15 insertions, 1 deletions
diff --git a/libbb/messages.c b/libbb/messages.c index c640faf5b..6c3d2f608 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -28,6 +28,7 @@ const char bb_msg_standard_input[] = "standard input"; | |||
28 | const char bb_msg_standard_output[] = "standard output"; | 28 | const char bb_msg_standard_output[] = "standard output"; |
29 | 29 | ||
30 | const char bb_str_default[] = "default"; | 30 | const char bb_str_default[] = "default"; |
31 | const char bb_hexdigits_upcase[] = "0123456789ABCDEF"; | ||
31 | 32 | ||
32 | const char bb_path_passwd_file[] = "/etc/passwd"; | 33 | const char bb_path_passwd_file[] = "/etc/passwd"; |
33 | const char bb_path_shadow_file[] = "/etc/shadow"; | 34 | const char bb_path_shadow_file[] = "/etc/shadow"; |
diff --git a/libbb/read.c b/libbb/read.c index 50e0354ad..861828da1 100644 --- a/libbb/read.c +++ b/libbb/read.c | |||
@@ -88,7 +88,7 @@ char *reads(int fd, char *buffer, size_t size) | |||
88 | *p++ = '\0'; | 88 | *p++ = '\0'; |
89 | // avoid incorrect (unsigned) widening | 89 | // avoid incorrect (unsigned) widening |
90 | offset = (off_t)(p-buffer) - (off_t)size; | 90 | offset = (off_t)(p-buffer) - (off_t)size; |
91 | // set fd position the right after the \n | 91 | // set fd position right after '\n' |
92 | if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1) | 92 | if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1) |
93 | return NULL; | 93 | return NULL; |
94 | } | 94 | } |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 827cbe870..207537929 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -333,6 +333,19 @@ char *itoa(int n) | |||
333 | return local_buf; | 333 | return local_buf; |
334 | } | 334 | } |
335 | 335 | ||
336 | // Emit a string of hex representation of bytes | ||
337 | char *bin2hex(char *p, const char *cp, int count) | ||
338 | { | ||
339 | while (count) { | ||
340 | unsigned char c = *cp++; | ||
341 | /* put lowercase hex digits */ | ||
342 | *p++ = 0x10 | bb_hexdigits_upcase[c >> 4]; | ||
343 | *p++ = 0x10 | bb_hexdigits_upcase[c & 0xf]; | ||
344 | count--; | ||
345 | } | ||
346 | return p; | ||
347 | } | ||
348 | |||
336 | // Die with an error message if we can't set gid. (Because resource limits may | 349 | // Die with an error message if we can't set gid. (Because resource limits may |
337 | // limit this user to a given number of processes, and if that fills up the | 350 | // limit this user to a given number of processes, and if that fills up the |
338 | // setgid() will fail and we'll _still_be_root_, which is bad.) | 351 | // setgid() will fail and we'll _still_be_root_, which is bad.) |