aboutsummaryrefslogtreecommitdiff
path: root/miscutils/hdparm.c
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-04-29 19:11:24 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-04-29 19:11:24 +0000
commit481be4b942c2d90be19dc384d18b95468add8973 (patch)
tree7732bbfd5004836baacb4b5a4ae1fd8051377cc8 /miscutils/hdparm.c
parentd06510ea219ae99ff68c0b962caf916731c52c2b (diff)
downloadbusybox-w32-481be4b942c2d90be19dc384d18b95468add8973.tar.gz
busybox-w32-481be4b942c2d90be19dc384d18b95468add8973.tar.bz2
busybox-w32-481be4b942c2d90be19dc384d18b95468add8973.zip
Remove some unused code pointed out by Tito, plus a slightly more graceful
way of handling endianness. git-svn-id: svn://busybox.net/trunk/busybox@14971 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'miscutils/hdparm.c')
-rw-r--r--miscutils/hdparm.c42
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. */
633static void identify(uint16_t *id_supplied, const char *devname) 633static 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 */