diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-12 22:10:34 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-12 22:10:34 +0000 |
commit | 3a34d0c08a77ee48edc3f4353cc49b95aba85c2f (patch) | |
tree | 09708579e18a033c6722c5194c46116705f47b83 /miscutils/hdparm.c | |
parent | 21b080daa8c180a43d10d6b3dee47134ef21e581 (diff) | |
download | busybox-w32-3a34d0c08a77ee48edc3f4353cc49b95aba85c2f.tar.gz busybox-w32-3a34d0c08a77ee48edc3f4353cc49b95aba85c2f.tar.bz2 busybox-w32-3a34d0c08a77ee48edc3f4353cc49b95aba85c2f.zip |
random small size optimizations
Diffstat (limited to 'miscutils/hdparm.c')
-rw-r--r-- | miscutils/hdparm.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 16485b900..e60e642d6 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -2025,28 +2025,28 @@ static void process_dev(char *devname) | |||
2025 | #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY | 2025 | #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY |
2026 | static int fromhex(unsigned char c) | 2026 | static int fromhex(unsigned char c) |
2027 | { | 2027 | { |
2028 | if (c >= 'a' && c <= 'f') | 2028 | if (isdigit(c)) |
2029 | return 10 + (c - 'a'); | ||
2030 | if (c >= '0' && c <= '9') | ||
2031 | return (c - '0'); | 2029 | return (c - '0'); |
2030 | if (c >= 'a' && c <= 'f') | ||
2031 | return (c - ('a' - 10)); | ||
2032 | bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c); | 2032 | bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c); |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | static void identify_from_stdin(void) | 2035 | static void identify_from_stdin(void) |
2036 | { | 2036 | { |
2037 | uint16_t sbuf[256]; | 2037 | uint16_t sbuf[256]; |
2038 | unsigned char buf[1280], *b = (unsigned char *)buf; | 2038 | unsigned char buf[1280]; |
2039 | int i, count = read(0, buf, 1280); | 2039 | unsigned char *b = (unsigned char *)buf; |
2040 | int i; | ||
2040 | 2041 | ||
2041 | if (count != 1280) | 2042 | xread(0, buf, 1280); |
2042 | bb_error_msg_and_die("read(%d bytes) failed (rc=%d)", 1280, count); | ||
2043 | 2043 | ||
2044 | // Convert the newline-separated hex data into an identify block. | 2044 | // Convert the newline-separated hex data into an identify block. |
2045 | 2045 | ||
2046 | for (i = 0; i<256; i++) { | 2046 | for (i = 0; i<256; i++) { |
2047 | int j; | 2047 | int j; |
2048 | for (j = 0; j < 4; j++) | 2048 | for (j = 0; j < 4; j++) |
2049 | sbuf[i] = (sbuf[i] <<4) + fromhex(*(b++)); | 2049 | sbuf[i] = (sbuf[i] << 4) + fromhex(*(b++)); |
2050 | } | 2050 | } |
2051 | 2051 | ||
2052 | // Parse the data. | 2052 | // Parse the data. |