diff options
| author | Rob Landley <rob@landley.net> | 2006-04-29 19:11:24 +0000 |
|---|---|---|
| committer | Rob Landley <rob@landley.net> | 2006-04-29 19:11:24 +0000 |
| commit | 5bc3f05a23ce7347c51c78c616c19f60bf3b805a (patch) | |
| tree | 7732bbfd5004836baacb4b5a4ae1fd8051377cc8 | |
| parent | a3e4f38f7b7218e3b6a6c406e5603bf6cfd00753 (diff) | |
| download | busybox-w32-5bc3f05a23ce7347c51c78c616c19f60bf3b805a.tar.gz busybox-w32-5bc3f05a23ce7347c51c78c616c19f60bf3b805a.tar.bz2 busybox-w32-5bc3f05a23ce7347c51c78c616c19f60bf3b805a.zip | |
Remove some unused code pointed out by Tito, plus a slightly more graceful
way of handling endianness.
| -rw-r--r-- | miscutils/hdparm.c | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 754f53201..258655689 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
| @@ -632,10 +632,8 @@ static void print_ascii(uint16_t *p, uint8_t length) { | |||
| 632 | intentional. */ | 632 | intentional. */ |
| 633 | static void identify(uint16_t *id_supplied, const char *devname) | 633 | static void identify(uint16_t *id_supplied, const char *devname) |
| 634 | { | 634 | { |
| 635 | 635 | uint16_t buf[256]; | |
| 636 | char *id_file = NULL; | 636 | uint16_t *val, ii, jj, kk; |
| 637 | FILE *fl; | ||
| 638 | uint16_t val[256], ii, jj, kk; | ||
| 639 | uint16_t like_std = 1, std = 0, min_std = 0xffff; | 637 | uint16_t like_std = 1, std = 0, min_std = 0xffff; |
| 640 | uint16_t dev = NO_DEV, eqpt = NO_DEV; | 638 | uint16_t dev = NO_DEV, eqpt = NO_DEV; |
| 641 | uint8_t have_mode = 0, err_dma = 0; | 639 | uint8_t have_mode = 0, err_dma = 0; |
| @@ -643,37 +641,11 @@ static void identify(uint16_t *id_supplied, const char *devname) | |||
| 643 | uint32_t ll, mm, nn, oo; | 641 | uint32_t ll, mm, nn, oo; |
| 644 | uint64_t bbbig; /* (:) */ | 642 | uint64_t bbbig; /* (:) */ |
| 645 | 643 | ||
| 646 | if (id_supplied) | 644 | if (BB_BIG_ENDIAN) { |
| 647 | { | 645 | swab(id_supplied, buf, sizeof(buf)); |
| 648 | #if __BYTE_ORDER == __BIG_ENDIAN | 646 | val = buf; |
| 649 | swab(id_supplied, val, sizeof(val)); | 647 | } else val = id_supplied; |
| 650 | #else | 648 | |
| 651 | memcpy(val, id_supplied, sizeof(val)); | ||
| 652 | #endif | ||
| 653 | } | ||
| 654 | else | ||
| 655 | { | ||
| 656 | /* open the file, read in all the info and close it */ | ||
| 657 | if (devname == NULL) | ||
| 658 | fl = stdin; | ||
| 659 | else { | ||
| 660 | id_file = bb_xasprintf("/proc/ide/%s/identify", devname); | ||
| 661 | fl = bb_xfopen(id_file, "r"); | ||
| 662 | } | ||
| 663 | /* calculate checksum over all bytes */ | ||
| 664 | for(ii = GEN_CONFIG; ii<=INTEGRITY; ii++) | ||
| 665 | { | ||
| 666 | unsigned int scratch; | ||
| 667 | if(1 != fscanf(fl,"%04x",&scratch)) | ||
| 668 | break; | ||
| 669 | val[ii] = (uint16_t)scratch; | ||
| 670 | chksum += val[ii] + (val[ii] >> 8); | ||
| 671 | } | ||
| 672 | bb_fclose_nonstdin(fl); | ||
| 673 | if (ENABLE_FEATURE_CLEAN_UP) free(id_file); | ||
| 674 | if(ii < (INTEGRITY+1)) | ||
| 675 | bb_error_msg_and_die("Input file wrong format or length"); | ||
| 676 | } | ||
| 677 | chksum &= 0xff; | 649 | chksum &= 0xff; |
| 678 | 650 | ||
| 679 | /* check if we recognise the device type */ | 651 | /* check if we recognise the device type */ |
