diff options
| author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-06-07 00:27:25 +0000 |
|---|---|---|
| committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-06-07 00:27:25 +0000 |
| commit | eb2f4484e50baf8f152b53ce14c1ceb5eb70ee4e (patch) | |
| tree | 6e81da9d85a76e0d01366b5eeb415d848bb4a997 /miscutils | |
| parent | 402a994239dba6e9b2c07a210ffc264efb32e259 (diff) | |
| download | busybox-w32-eb2f4484e50baf8f152b53ce14c1ceb5eb70ee4e.tar.gz busybox-w32-eb2f4484e50baf8f152b53ce14c1ceb5eb70ee4e.tar.bz2 busybox-w32-eb2f4484e50baf8f152b53ce14c1ceb5eb70ee4e.zip | |
Callers to identify() converted the endianness of the buffer. So did
identify(). This meant big endian systems had a NUXI problem. Removed
the redundant conversion from the callers, and made some in-passing cleanups
while I was there.
git-svn-id: svn://busybox.net/trunk/busybox@15301 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/hdparm.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 24962dd25..5ac7bdcb7 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
| @@ -565,10 +565,8 @@ static void print_ascii(uint16_t *p, uint8_t length) { | |||
| 565 | printf("\n"); | 565 | printf("\n"); |
| 566 | } | 566 | } |
| 567 | 567 | ||
| 568 | /* identify() is the only extern function used across two source files. The | 568 | // Parse 512 byte disk identification block and print much crap. |
| 569 | others, though, were declared in hdparm.c with global scope; since other | 569 | |
| 570 | functions in that file have static (file) scope, I assume the difference is | ||
| 571 | intentional. */ | ||
| 572 | static void identify(uint16_t *id_supplied) | 570 | static void identify(uint16_t *id_supplied) |
| 573 | { | 571 | { |
| 574 | uint16_t buf[256]; | 572 | uint16_t buf[256]; |
| @@ -581,6 +579,8 @@ static void identify(uint16_t *id_supplied) | |||
| 581 | uint64_t bbbig; /* (:) */ | 579 | uint64_t bbbig; /* (:) */ |
| 582 | const char *strng; | 580 | const char *strng; |
| 583 | 581 | ||
| 582 | // Adjust for endianness if necessary. | ||
| 583 | |||
| 584 | if (BB_BIG_ENDIAN) { | 584 | if (BB_BIG_ENDIAN) { |
| 585 | swab(id_supplied, buf, sizeof(buf)); | 585 | swab(id_supplied, buf, sizeof(buf)); |
| 586 | val = buf; | 586 | val = buf; |
| @@ -1997,16 +1997,12 @@ static void process_dev(char *devname) | |||
| 1997 | if (get_IDentity) | 1997 | if (get_IDentity) |
| 1998 | { | 1998 | { |
| 1999 | unsigned char args1[4+512]; /* = { ... } will eat 0.5k of rodata! */ | 1999 | unsigned char args1[4+512]; /* = { ... } will eat 0.5k of rodata! */ |
| 2000 | unsigned i; | ||
| 2001 | 2000 | ||
| 2002 | memset(args1, 0, sizeof(args1)); | 2001 | memset(args1, 0, sizeof(args1)); |
| 2003 | args1[0] = WIN_IDENTIFY; | 2002 | args1[0] = WIN_IDENTIFY; |
| 2004 | args1[3] = 1; | 2003 | args1[3] = 1; |
| 2005 | if (!bb_ioctl_alt(fd, HDIO_DRIVE_CMD, args1, WIN_PIDENTIFY, "HDIO_DRIVE_CMD(identify)")) { | 2004 | if (!bb_ioctl_alt(fd, HDIO_DRIVE_CMD, args1, WIN_PIDENTIFY, "HDIO_DRIVE_CMD(identify)")) |
| 2006 | uint16_t *ptr = (uint16_t *)args1; | 2005 | identify((void *)(args1 + 4)); |
| 2007 | for (i=0; i<sizeof(args1)/2; i++) ptr[i] = SWAP_LE16(ptr[i]); | ||
| 2008 | identify((void *)(ptr+2)); | ||
| 2009 | } | ||
| 2010 | } | 2006 | } |
| 2011 | #endif | 2007 | #endif |
| 2012 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF | 2008 | #ifdef CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF |
| @@ -2053,19 +2049,23 @@ static int fromhex(unsigned char c) | |||
| 2053 | 2049 | ||
| 2054 | static void identify_from_stdin(void) | 2050 | static void identify_from_stdin(void) |
| 2055 | { | 2051 | { |
| 2056 | uint16_t sbuf[800]; | 2052 | uint16_t sbuf[256]; |
| 2057 | unsigned char buf[1600], *b = (unsigned char *)buf; | 2053 | unsigned char buf[1280], *b = (unsigned char *)buf; |
| 2058 | int i, count = read(0, buf, 1280); | 2054 | int i, count = read(0, buf, 1280); |
| 2059 | 2055 | ||
| 2060 | if (count != 1280) | 2056 | if (count != 1280) |
| 2061 | bb_error_msg_and_die("read(%d bytes) failed (rc=%d)", 1280, count); | 2057 | bb_error_msg_and_die("read(%d bytes) failed (rc=%d)", 1280, count); |
| 2062 | 2058 | ||
| 2063 | for (i = 0; count >= 4; ++i) | 2059 | // Convert the newline-separated hex data into an identify block. |
| 2060 | |||
| 2061 | for (i = 0; i<256; i++) | ||
| 2064 | { | 2062 | { |
| 2065 | sbuf[i] = SWAP_LE16((fromhex(b[0]) << 12) | (fromhex(b[1]) << 8) | (fromhex(b[2]) << 4) | fromhex(b[3])); | 2063 | int j; |
| 2066 | b += 5; | 2064 | for(j=0;j<4;j++) sbuf[i] = (sbuf[i] <<4) + fromhex(*(b++)); |
| 2067 | count -= 5; | ||
| 2068 | } | 2065 | } |
| 2066 | |||
| 2067 | // Parse the data. | ||
| 2068 | |||
| 2069 | identify(sbuf); | 2069 | identify(sbuf); |
| 2070 | } | 2070 | } |
| 2071 | #endif | 2071 | #endif |
