← Commit list

0753f4a15

Rob Landley
Rob Landley
2006-06-07
SOURCE BUG Duration: 51s

Subject

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.

SOURCE BUG

This commit was genuinely broken at the time (not related to our build system): scripts/config/mkconfigs.c (2005-08-01 - 2006-10-05 arasi) uretilen bbconfigopts.h icine .config satirlarini kacissiz, ham newline'larla gömüyordu - gecerli C degildi, busybox'un kendi bb_mkdep araci bile parse edemiyordu (7d219aab7 ile duzeltildi, mkconfigs shell scripte cevrildi)

→ Bu hatanin tam hikayesini ve duzeltme diffini gor

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

miscutils/hdparm.c+16 -16
@@ -565,10 +565,8 @@ static void print_ascii(uint16_t *p, uint8_t length) {
printf("\n");
}
-/* identify() is the only extern function used across two source files. The
- others, though, were declared in hdparm.c with global scope; since other
- functions in that file have static (file) scope, I assume the difference is
- intentional. */
+// Parse 512 byte disk identification block and print much crap.
+
static void identify(uint16_t *id_supplied)
{
uint16_t buf[256];
@@ -581,6 +579,8 @@ static void identify(uint16_t *id_supplied)
uint64_t bbbig; /* (:) */
const char *strng;
+ // Adjust for endianness if necessary.
+
if (BB_BIG_ENDIAN) {
swab(id_supplied, buf, sizeof(buf));
val = buf;
@@ -1997,16 +1997,12 @@ static void process_dev(char *devname)
if (get_IDentity)
{
unsigned char args1[4+512]; /* = { ... } will eat 0.5k of rodata! */
- unsigned i;
memset(args1, 0, sizeof(args1));
args1[0] = WIN_IDENTIFY;
args1[3] = 1;
- if (!bb_ioctl_alt(fd, HDIO_DRIVE_CMD, args1, WIN_PIDENTIFY, "HDIO_DRIVE_CMD(identify)")) {
- uint16_t *ptr = (uint16_t *)args1;
- for (i=0; i<sizeof(args1)/2; i++) ptr[i] = SWAP_LE16(ptr[i]);
- identify((void *)(ptr+2));
- }
+ if (!bb_ioctl_alt(fd, HDIO_DRIVE_CMD, args1, WIN_PIDENTIFY, "HDIO_DRIVE_CMD(identify)"))
+ identify((void *)(args1 + 4));
}
#endif
#ifdef CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF
@@ -2053,19 +2049,23 @@ static int fromhex(unsigned char c)
static void identify_from_stdin(void)
{
- uint16_t sbuf[800];
- unsigned char buf[1600], *b = (unsigned char *)buf;
+ uint16_t sbuf[256];
+ unsigned char buf[1280], *b = (unsigned char *)buf;
int i, count = read(0, buf, 1280);
if (count != 1280)
bb_error_msg_and_die("read(%d bytes) failed (rc=%d)", 1280, count);
- for (i = 0; count >= 4; ++i)
+ // Convert the newline-separated hex data into an identify block.
+
+ for (i = 0; i<256; i++)
{
- sbuf[i] = SWAP_LE16((fromhex(b[0]) << 12) | (fromhex(b[1]) << 8) | (fromhex(b[2]) << 4) | fromhex(b[3]));
- b += 5;
- count -= 5;
+ int j;
+ for(j=0;j<4;j++) sbuf[i] = (sbuf[i] <<4) + fromhex(*(b++));
}
+
+ // Parse the data.
+
identify(sbuf);
}
#endif