diff options
author | Denis Vlasenko | 2007-01-12 22:10:34 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-01-12 22:10:34 +0000 |
commit | 3a34d0c08a77ee48edc3f4353cc49b95aba85c2f (patch) | |
tree | 09708579e18a033c6722c5194c46116705f47b83 /miscutils | |
parent | 21b080daa8c180a43d10d6b3dee47134ef21e581 (diff) | |
download | busybox-3a34d0c08a77ee48edc3f4353cc49b95aba85c2f.zip busybox-3a34d0c08a77ee48edc3f4353cc49b95aba85c2f.tar.gz |
random small size optimizations
Diffstat (limited to 'miscutils')
-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 16485b9..e60e642 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c @@ -2025,28 +2025,28 @@ static void process_dev(char *devname) #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY static int fromhex(unsigned char c) { - if (c >= 'a' && c <= 'f') - return 10 + (c - 'a'); - if (c >= '0' && c <= '9') + if (isdigit(c)) return (c - '0'); + if (c >= 'a' && c <= 'f') + return (c - ('a' - 10)); bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c); } static void identify_from_stdin(void) { uint16_t sbuf[256]; - unsigned char buf[1280], *b = (unsigned char *)buf; - int i, count = read(0, buf, 1280); + unsigned char buf[1280]; + unsigned char *b = (unsigned char *)buf; + int i; - if (count != 1280) - bb_error_msg_and_die("read(%d bytes) failed (rc=%d)", 1280, count); + xread(0, buf, 1280); // Convert the newline-separated hex data into an identify block. for (i = 0; i<256; i++) { int j; for (j = 0; j < 4; j++) - sbuf[i] = (sbuf[i] <<4) + fromhex(*(b++)); + sbuf[i] = (sbuf[i] << 4) + fromhex(*(b++)); } // Parse the data. |