aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-16 10:37:49 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-16 10:37:49 +0000
commita0319ba936236433e6b8c3a96e890c3531effbc9 (patch)
tree491305edf82994ef5a2f7ce915b91481bd63c6ef
parent6a2f7f41cf7c544d6abce958f89c873b24f79b18 (diff)
downloadbusybox-w32-a0319ba936236433e6b8c3a96e890c3531effbc9.tar.gz
busybox-w32-a0319ba936236433e6b8c3a96e890c3531effbc9.tar.bz2
busybox-w32-a0319ba936236433e6b8c3a96e890c3531effbc9.zip
hdparm: shrink rodata by ~250 bytes
-rw-r--r--coreutils/dos2unix.c2
-rw-r--r--libbb/getopt32.c2
-rw-r--r--miscutils/hdparm.c77
3 files changed, 26 insertions, 55 deletions
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c
index 00688aac2..1bfdf0cde 100644
--- a/coreutils/dos2unix.c
+++ b/coreutils/dos2unix.c
@@ -91,7 +91,7 @@ int dos2unix_main(int argc, char **argv)
91 } 91 }
92 92
93 /* -u convert to unix, -d convert to dos */ 93 /* -u convert to unix, -d convert to dos */
94 opt_complementary = "u--d:d--u"; /* mutally exclusive */ 94 opt_complementary = "u--d:d--u"; /* mutually exclusive */
95 o = getopt32(argc, argv, "du"); 95 o = getopt32(argc, argv, "du");
96 96
97 /* Do the conversion requested by an argument else do the default 97 /* Do the conversion requested by an argument else do the default
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index c09956940..3e1299fc3 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -211,7 +211,7 @@ Special characters:
211 211
212 For example: 212 For example:
213 The cut applet must have only one type of list specified, so 213 The cut applet must have only one type of list specified, so
214 -b, -c and -f are mutally exclusive and should raise an error 214 -b, -c and -f are mutually exclusive and should raise an error
215 if specified together. In this case you must set 215 if specified together. In this case you must set
216 opt_complementary = "b--cf:c--bf:f--bc". If two of the 216 opt_complementary = "b--cf:c--bf:f--bc". If two of the
217 mutually exclusive options are found, getopt32 will call 217 mutually exclusive options are found, getopt32 will call
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index c47cc4e9d..b3c240835 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -1416,62 +1416,33 @@ static void interpret_standby(unsigned standby)
1416 printf(")\n"); 1416 printf(")\n");
1417} 1417}
1418 1418
1419struct xfermode_entry { 1419static const uint8_t xfermode_val[] ALIGN1 = {
1420 int val; 1420 8, 9, 10, 11, 12, 13, 14, 15,
1421 const char *name; 1421 16, 17, 18, 19, 20, 21, 22, 23,
1422 32, 33, 34, 35, 36, 37, 38, 39,
1423 64, 65, 66, 67, 68, 69, 70, 71
1422}; 1424};
1423 1425/* NB: we save size by _not_ storing terninating NUL! */
1424static const struct xfermode_entry xfermode_table[] = { 1426static const char xfermode_name[][5] ALIGN1 = {
1425 { 8, "pio0" }, 1427 "pio0", "pio1", "pio2", "pio3", "pio4", "pio5", "pio6", "pio7",
1426 { 9, "pio1" }, 1428 "sdma0","sdma1","sdma2","sdma3","sdma4","sdma5","sdma6","sdma7",
1427 { 10, "pio2" }, 1429 "mdma0","mdma1","mdma2","mdma3","mdma4","mdma5","mdma6","mdma7",
1428 { 11, "pio3" }, 1430 "udma0","udma1","udma2","udma3","udma4","udma5","udma6","udma7"
1429 { 12, "pio4" },
1430 { 13, "pio5" },
1431 { 14, "pio6" },
1432 { 15, "pio7" },
1433 { 16, "sdma0" },
1434 { 17, "sdma1" },
1435 { 18, "sdma2" },
1436 { 19, "sdma3" },
1437 { 20, "sdma4" },
1438 { 21, "sdma5" },
1439 { 22, "sdma6" },
1440 { 23, "sdma7" },
1441 { 32, "mdma0" },
1442 { 33, "mdma1" },
1443 { 34, "mdma2" },
1444 { 35, "mdma3" },
1445 { 36, "mdma4" },
1446 { 37, "mdma5" },
1447 { 38, "mdma6" },
1448 { 39, "mdma7" },
1449 { 64, "udma0" },
1450 { 65, "udma1" },
1451 { 66, "udma2" },
1452 { 67, "udma3" },
1453 { 68, "udma4" },
1454 { 69, "udma5" },
1455 { 70, "udma6" },
1456 { 71, "udma7" },
1457 { 0, NULL }
1458}; 1431};
1459 1432
1460static int translate_xfermode(char * name) 1433static int translate_xfermode(const char *name)
1461{ 1434{
1462 const struct xfermode_entry *tmp; 1435 int val, i;
1463 char *endptr;
1464 int val = -1;
1465 1436
1466 for (tmp = xfermode_table; tmp->name != NULL; ++tmp) { 1437 for (i = 0; i < ARRAY_SIZE(xfermode_val); i++) {
1467 if (!strcmp(name, tmp->name)) 1438 if (!strncmp(name, xfermode_name[i], 5))
1468 return tmp->val; 1439 if (strlen(name) <= 5)
1440 return xfermode_val[i];
1469 } 1441 }
1470 1442 /* Negative numbers are invalid and are caught later */
1471 val = strtol(name, &endptr, 10); 1443 val = bb_strtoi(name, NULL, 10);
1472 if (*endptr == '\0') 1444 if (!errno)
1473 return val; 1445 return val;
1474
1475 return -1; 1446 return -1;
1476} 1447}
1477 1448
@@ -1483,13 +1454,13 @@ static void interpret_xfermode(unsigned xfermode)
1483 else if (xfermode == 1) 1454 else if (xfermode == 1)
1484 printf("default PIO mode, disable IORDY"); 1455 printf("default PIO mode, disable IORDY");
1485 else if (xfermode >= 8 && xfermode <= 15) 1456 else if (xfermode >= 8 && xfermode <= 15)
1486 printf("PIO flow control mode%u", xfermode-8); 1457 printf("PIO flow control mode%u", xfermode - 8);
1487 else if (xfermode >= 16 && xfermode <= 23) 1458 else if (xfermode >= 16 && xfermode <= 23)
1488 printf("singleword DMA mode%u", xfermode-16); 1459 printf("singleword DMA mode%u", xfermode - 16);
1489 else if (xfermode >= 32 && xfermode <= 39) 1460 else if (xfermode >= 32 && xfermode <= 39)
1490 printf("multiword DMA mode%u", xfermode-32); 1461 printf("multiword DMA mode%u", xfermode - 32);
1491 else if (xfermode >= 64 && xfermode <= 71) 1462 else if (xfermode >= 64 && xfermode <= 71)
1492 printf("UltraDMA mode%u", xfermode-64); 1463 printf("UltraDMA mode%u", xfermode - 64);
1493 else 1464 else
1494 printf("Unknown"); 1465 printf("Unknown");
1495 printf(")\n"); 1466 printf(")\n");