diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-04 04:10:17 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-04 04:10:17 +0000 |
commit | bfc3d82256c45fb1e6e04ca85fac8a65b34b72a1 (patch) | |
tree | efe5bed86f389cec7e7e4f73b12b58783327e4b2 /miscutils/hdparm.c | |
parent | 681023650e69f6e4fa959c5c6f0480d4a0edf906 (diff) | |
download | busybox-w32-bfc3d82256c45fb1e6e04ca85fac8a65b34b72a1.tar.gz busybox-w32-bfc3d82256c45fb1e6e04ca85fac8a65b34b72a1.tar.bz2 busybox-w32-bfc3d82256c45fb1e6e04ca85fac8a65b34b72a1.zip |
ifconfig: code shrink
adjtimex: code shrink
libbb: move nth_string function into libbb
hdparm: nth_string was here
text data bss dec hex filename
730013 10334 12032 752379 b7afb busybox_old
730093 10134 12032 752259 b7a83 busybox_unstripped
Diffstat (limited to 'miscutils/hdparm.c')
-rw-r--r-- | miscutils/hdparm.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index c8129d791..93b1aacb3 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -491,15 +491,6 @@ static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t * | |||
491 | return err_dma; | 491 | return err_dma; |
492 | } | 492 | } |
493 | 493 | ||
494 | static const char *nth_str(const char *strings, int n) | ||
495 | { | ||
496 | while (n) { | ||
497 | n--; | ||
498 | strings += strlen(strings) + 1; | ||
499 | } | ||
500 | return strings; | ||
501 | } | ||
502 | |||
503 | static const char pkt_str[] ALIGN1 = | 494 | static const char pkt_str[] ALIGN1 = |
504 | "Direct-access device" "\0" /* word 0, bits 12-8 = 00 */ | 495 | "Direct-access device" "\0" /* word 0, bits 12-8 = 00 */ |
505 | "Sequential-access device" "\0" /* word 0, bits 12-8 = 01 */ | 496 | "Sequential-access device" "\0" /* word 0, bits 12-8 = 01 */ |
@@ -710,7 +701,7 @@ static void identify(uint16_t *val) | |||
710 | } else if (!(val[GEN_CONFIG] & NOT_ATAPI)) { | 701 | } else if (!(val[GEN_CONFIG] & NOT_ATAPI)) { |
711 | dev = ATAPI_DEV; | 702 | dev = ATAPI_DEV; |
712 | eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT; | 703 | eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT; |
713 | printf("ATAPI %s, with ", eqpt <= 0xf ? nth_str(pkt_str, eqpt) : "unknown"); | 704 | printf("ATAPI %s, with ", eqpt <= 0xf ? nth_string(pkt_str, eqpt) : "unknown"); |
714 | like_std = 3; | 705 | like_std = 3; |
715 | } else | 706 | } else |
716 | /* "Unknown device type:\n\tbits 15&14 of general configuration word 0 both set to 1.\n" */ | 707 | /* "Unknown device type:\n\tbits 15&14 of general configuration word 0 both set to 1.\n" */ |
@@ -748,7 +739,7 @@ static void identify(uint16_t *val) | |||
748 | if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) { | 739 | if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) { |
749 | if (like_std < 3) like_std = 3; | 740 | if (like_std < 3) like_std = 3; |
750 | std = actual_ver[val[MINOR]]; | 741 | std = actual_ver[val[MINOR]]; |
751 | if (std) printf("\n\tUsed: %s ", nth_str(minor_str, val[MINOR])); | 742 | if (std) printf("\n\tUsed: %s ", nth_string(minor_str, val[MINOR])); |
752 | 743 | ||
753 | } | 744 | } |
754 | /* looks like when they up-issue the std, they obsolete one; | 745 | /* looks like when they up-issue the std, they obsolete one; |
@@ -847,7 +838,7 @@ static void identify(uint16_t *val) | |||
847 | jj = val[GEN_CONFIG] >> 1; | 838 | jj = val[GEN_CONFIG] >> 1; |
848 | for (ii = 1; ii < 15; ii++) { | 839 | for (ii = 1; ii < 15; ii++) { |
849 | if (jj & 0x0001) | 840 | if (jj & 0x0001) |
850 | printf("\t%s\n", nth_str(ata1_cfg_str, ii)); | 841 | printf("\t%s\n", nth_string(ata1_cfg_str, ii)); |
851 | jj >>=1; | 842 | jj >>=1; |
852 | } | 843 | } |
853 | } | 844 | } |
@@ -1070,7 +1061,7 @@ static void identify(uint16_t *val) | |||
1070 | jj = val[CMDS_SUPP_0]; | 1061 | jj = val[CMDS_SUPP_0]; |
1071 | kk = val[CMDS_EN_0]; | 1062 | kk = val[CMDS_EN_0]; |
1072 | for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) { | 1063 | for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) { |
1073 | const char *feat_str = nth_str(cmd_feat_str, ii); | 1064 | const char *feat_str = nth_string(cmd_feat_str, ii); |
1074 | if ((jj & 0x8000) && (*feat_str != '\0')) { | 1065 | if ((jj & 0x8000) && (*feat_str != '\0')) { |
1075 | printf("\t%s\t%s\n", (kk & 0x8000) ? " *" : "", feat_str); | 1066 | printf("\t%s\t%s\n", (kk & 0x8000) ? " *" : "", feat_str); |
1076 | } | 1067 | } |
@@ -1088,7 +1079,7 @@ static void identify(uint16_t *val) | |||
1088 | } | 1079 | } |
1089 | /* Removable Media Status Notification feature set */ | 1080 | /* Removable Media Status Notification feature set */ |
1090 | if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP) | 1081 | if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP) |
1091 | printf("\t%s supported\n", nth_str(cmd_feat_str, 27)); | 1082 | printf("\t%s supported\n", nth_string(cmd_feat_str, 27)); |
1092 | 1083 | ||
1093 | /* security */ | 1084 | /* security */ |
1094 | if ((eqpt != CDROM) && (like_std > 3) | 1085 | if ((eqpt != CDROM) && (like_std > 3) |
@@ -1100,7 +1091,7 @@ static void identify(uint16_t *val) | |||
1100 | jj = val[SECU_STATUS]; | 1091 | jj = val[SECU_STATUS]; |
1101 | if (jj) { | 1092 | if (jj) { |
1102 | for (ii = 0; ii < NUM_SECU_STR; ii++) { | 1093 | for (ii = 0; ii < NUM_SECU_STR; ii++) { |
1103 | printf("\t%s\t%s\n", (!(jj & 0x0001)) ? "not" : "", nth_str(secu_str, ii)); | 1094 | printf("\t%s\t%s\n", (!(jj & 0x0001)) ? "not" : "", nth_string(secu_str, ii)); |
1104 | jj >>=1; | 1095 | jj >>=1; |
1105 | } | 1096 | } |
1106 | if (val[SECU_STATUS] & SECU_ENABLED) { | 1097 | if (val[SECU_STATUS] & SECU_ENABLED) { |
@@ -1182,13 +1173,13 @@ static void dump_identity(const struct hd_driveid *id) | |||
1182 | id->model, id->fw_rev, id->serial_no); | 1173 | id->model, id->fw_rev, id->serial_no); |
1183 | for (i = 0; i <= 15; i++) { | 1174 | for (i = 0; i <= 15; i++) { |
1184 | if (id->config & (1<<i)) | 1175 | if (id->config & (1<<i)) |
1185 | printf(" %s", nth_str(cfg_str, i)); | 1176 | printf(" %s", nth_string(cfg_str, i)); |
1186 | } | 1177 | } |
1187 | printf(" }\n RawCHS=%u/%u/%u, TrkSize=%u, SectSize=%u, ECCbytes=%u\n" | 1178 | printf(" }\n RawCHS=%u/%u/%u, TrkSize=%u, SectSize=%u, ECCbytes=%u\n" |
1188 | " BuffType=(%u) %s, BuffSize=%ukB, MaxMultSect=%u", | 1179 | " BuffType=(%u) %s, BuffSize=%ukB, MaxMultSect=%u", |
1189 | id->cyls, id->heads, id->sectors, id->track_bytes, | 1180 | id->cyls, id->heads, id->sectors, id->track_bytes, |
1190 | id->sector_bytes, id->ecc_bytes, | 1181 | id->sector_bytes, id->ecc_bytes, |
1191 | id->buf_type, nth_str(BuffType, (id->buf_type > 3) ? 0 : id->buf_type), | 1182 | id->buf_type, nth_string(BuffType, (id->buf_type > 3) ? 0 : id->buf_type), |
1192 | id->buf_size/2, id->max_multsect); | 1183 | id->buf_size/2, id->max_multsect); |
1193 | if (id->max_multsect) { | 1184 | if (id->max_multsect) { |
1194 | printf(", MultSect="); | 1185 | printf(", MultSect="); |
@@ -1294,7 +1285,7 @@ static void dump_identity(const struct hd_driveid *id) | |||
1294 | if ((id->minor_rev_num && id->minor_rev_num <= 31) | 1285 | if ((id->minor_rev_num && id->minor_rev_num <= 31) |
1295 | || (id->major_rev_num && id->minor_rev_num <= 31) | 1286 | || (id->major_rev_num && id->minor_rev_num <= 31) |
1296 | ) { | 1287 | ) { |
1297 | printf("\n Drive conforms to: %s: ", (id->minor_rev_num <= 31) ? nth_str(minor_str, id->minor_rev_num) : "unknown"); | 1288 | printf("\n Drive conforms to: %s: ", (id->minor_rev_num <= 31) ? nth_string(minor_str, id->minor_rev_num) : "unknown"); |
1298 | if (id->major_rev_num != 0x0000 && /* NOVAL_0 */ | 1289 | if (id->major_rev_num != 0x0000 && /* NOVAL_0 */ |
1299 | id->major_rev_num != 0xFFFF) { /* NOVAL_1 */ | 1290 | id->major_rev_num != 0xFFFF) { /* NOVAL_1 */ |
1300 | for (i = 0; i <= 15; i++) { | 1291 | for (i = 0; i <= 15; i++) { |