pointless whitespace/comment fixes, no code changes
[oweals/busybox.git] / miscutils / hdparm.c
index 7afa9ff862bd4f6feef7946785e9d069ecb8e993..de5d68a0438876f4203b5595cf45c854fd6ebe33 100644 (file)
@@ -59,7 +59,7 @@
 #define ADV_PIO_MODES          64  /* advanced PIO modes supported */
                                    /* multiword DMA xfer cycle time: */
 #define DMA_TIME_MIN           65  /*   - minimum */
-#define DMA_TIME_NORM          66  /*   - manufacturer's recommended   */
+#define DMA_TIME_NORM          66  /*   - manufacturer's recommended */
                                    /* minimum PIO xfer cycle time: */
 #define PIO_NO_FLOW            67  /*   - without flow control */
 #define PIO_FLOW               68  /*   - with IORDY flow control */
@@ -82,7 +82,7 @@
 #define ENH_ERASE_TIME         90  /*   - enhanced */
 #define ADV_PWR                        91  /* current advanced power management level
                                       in low byte, 0x40 in high byte. */
-#define PSWD_CODE              92  /* master password revision code    */
+#define PSWD_CODE              92  /* master password revision code */
 #define HWRST_RSLT             93  /* hardware reset result */
 #define ACOUSTIC               94  /* acoustic mgmt values ( >= ATA-6) */
 #define LBA_LSB                        100 /* LBA: maximum.  Currently only 48 */
@@ -678,7 +678,7 @@ static const char secu_str[] ALIGN1 =
 ;
 
 // Parse 512 byte disk identification block and print much crap.
-static void identify(uint16_t *val) ATTRIBUTE_NORETURN;
+static void identify(uint16_t *val) NORETURN;
 static void identify(uint16_t *val)
 {
        uint16_t ii, jj, kk;
@@ -1108,7 +1108,7 @@ static void identify(uint16_t *val)
                jj =  val[ERASE_TIME]     & ERASE_BITS;
                kk =  val[ENH_ERASE_TIME] & ERASE_BITS;
                if (jj || kk) {
-                       printf("\t");
+                       bb_putchar('\t');
                        if (jj) printf("%umin for %sSECURITY ERASE UNIT. ", jj==ERASE_BITS ? 508 : jj<<1, "");
                        if (kk) printf("%umin for %sSECURITY ERASE UNIT. ", kk==ERASE_BITS ? 508 : kk<<1, "ENHANCED ");
                        bb_putchar('\n');
@@ -1228,54 +1228,46 @@ static void dump_identity(const struct hd_driveid *id)
                if (id->tPIO >= 2) printf("pio2 ");
        }
        if (id->field_valid & 2) {
-               if (id->eide_pio_modes & 1) printf("pio3 ");
-               if (id->eide_pio_modes & 2) printf("pio4 ");
-               if (id->eide_pio_modes &~3) printf("pio? ");
+               static const masks_labels_t pio_modes = {
+                       .masks = { 1, 2, ~3 },
+                       .labels = "pio3 \0""pio4 \0""pio? \0",
+               };
+               print_flags(&pio_modes, id->eide_pio_modes);
        }
        if (id->capability & 1) {
                if (id->dma_1word | id->dma_mword) {
+                       static const int dma_wmode_masks[] = { 0x100, 1, 0x200, 2, 0x400, 4, 0xf800, 0xf8 };
                        printf("\n DMA modes:  ");
-                       if (id->dma_1word & 0x100) printf("*");
-                       if (id->dma_1word & 1) printf("sdma0 ");
-                       if (id->dma_1word & 0x200) printf("*");
-                       if (id->dma_1word & 2) printf("sdma1 ");
-                       if (id->dma_1word & 0x400) printf("*");
-                       if (id->dma_1word & 4) printf("sdma2 ");
-                       if (id->dma_1word & 0xf800) printf("*");
-                       if (id->dma_1word & 0xf8) printf("sdma? ");
-                       if (id->dma_mword & 0x100) printf("*");
-                       if (id->dma_mword & 1) printf("mdma0 ");
-                       if (id->dma_mword & 0x200) printf("*");
-                       if (id->dma_mword & 2) printf("mdma1 ");
-                       if (id->dma_mword & 0x400) printf("*");
-                       if (id->dma_mword & 4) printf("mdma2 ");
-                       if (id->dma_mword & 0xf800) printf("*");
-                       if (id->dma_mword & 0xf8) printf("mdma? ");
+                       print_flags_separated(dma_wmode_masks,
+                               "*\0""sdma0 \0""*\0""sdma1 \0""*\0""sdma2 \0""*\0""sdma? \0",
+                               id->dma_1word, NULL);
+                       print_flags_separated(dma_wmode_masks,
+                               "*\0""mdma0\0""*\0""mdma1\0""*\0""mdma2\0""*\0""mdma?\0",
+                               id->dma_mword, NULL);
                }
        }
        if (((id->capability & 8) || (id->field_valid & 2)) && id->field_valid & 4) {
+               static const masks_labels_t ultra_modes1 = {
+                       .masks = { 0x100, 0x001, 0x200, 0x002, 0x400, 0x004 },
+                       .labels = "*\0""udma0 \0""*\0""udma1 \0""*\0""udma2 \0",
+               };
+
                printf("\n UDMA modes: ");
-               if (id->dma_ultra & 0x100) printf("*");
-               if (id->dma_ultra & 0x001) printf("udma0 ");
-               if (id->dma_ultra & 0x200) printf("*");
-               if (id->dma_ultra & 0x002) printf("udma1 ");
-               if (id->dma_ultra & 0x400) printf("*");
-               if (id->dma_ultra & 0x004) printf("udma2 ");
+               print_flags(&ultra_modes1, id->dma_ultra);
 #ifdef __NEW_HD_DRIVE_ID
                if (id->hw_config & 0x2000) {
 #else /* !__NEW_HD_DRIVE_ID */
                if (id->word93 & 0x2000) {
 #endif /* __NEW_HD_DRIVE_ID */
-                       if (id->dma_ultra & 0x0800) printf("*");
-                       if (id->dma_ultra & 0x0008) printf("udma3 ");
-                       if (id->dma_ultra & 0x1000) printf("*");
-                       if (id->dma_ultra & 0x0010) printf("udma4 ");
-                       if (id->dma_ultra & 0x2000) printf("*");
-                       if (id->dma_ultra & 0x0020) printf("udma5 ");
-                       if (id->dma_ultra & 0x4000) printf("*");
-                       if (id->dma_ultra & 0x0040) printf("udma6 ");
-                       if (id->dma_ultra & 0x8000) printf("*");
-                       if (id->dma_ultra & 0x0080) printf("udma7 ");
+                       static const masks_labels_t ultra_modes2 = {
+                               .masks = { 0x0800, 0x0008, 0x1000, 0x0010,
+                                       0x2000, 0x0020, 0x4000, 0x0040,
+                                       0x8000, 0x0080 },
+                               .labels = "*\0""udma3 \0""*\0""udma4 \0"
+                                       "*\0""udma5 \0""*\0""udma6 \0"
+                                       "*\0""udma7 \0"
+                       };
+                       print_flags(&ultra_modes2, id->dma_ultra);
                }
        }
        printf("\n AdvancedPM=%s", (!(id_regs[83] & 8)) ? "no" : "yes");
@@ -1767,7 +1759,7 @@ static void process_dev(char *devname)
                }
        }
        if (get_unmask) {
-               if(!ioctl_or_warn(fd, HDIO_GET_UNMASKINTR, &parm))
+               if (!ioctl_or_warn(fd, HDIO_GET_UNMASKINTR, &parm))
                        print_value_on_off("unmaskirq", parm);
        }
 
@@ -1785,25 +1777,25 @@ static void process_dev(char *devname)
 #endif
 #ifdef HDIO_GET_QDMA
        if (get_dma_q) {
-               if(!ioctl_or_warn(fd, HDIO_GET_QDMA, &parm))
+               if (!ioctl_or_warn(fd, HDIO_GET_QDMA, &parm))
                        print_value_on_off("queue_depth", parm);
        }
 #endif
        if (get_keep) {
-               if(!ioctl_or_warn(fd, HDIO_GET_KEEPSETTINGS, &parm))
+               if (!ioctl_or_warn(fd, HDIO_GET_KEEPSETTINGS, &parm))
                        print_value_on_off("keepsettings", parm);
        }
 
        if (get_nowerr) {
-               if(!ioctl_or_warn(fd, HDIO_GET_NOWERR, &parm))
+               if (!ioctl_or_warn(fd, HDIO_GET_NOWERR, &parm))
                        print_value_on_off("nowerr", parm);
        }
        if (get_readonly) {
-               if(!ioctl_or_warn(fd, BLKROGET, &parm))
+               if (!ioctl_or_warn(fd, BLKROGET, &parm))
                        print_value_on_off("readonly", parm);
        }
        if (get_readahead) {
-               if(!ioctl_or_warn(fd, BLKRAGET, &parm))
+               if (!ioctl_or_warn(fd, BLKRAGET, &parm))
                        print_value_on_off("readahead", parm);
        }
        if (get_geom) {
@@ -1916,7 +1908,7 @@ static int fromhex(unsigned char c)
        bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c);
 }
 
-static void identify_from_stdin(void) ATTRIBUTE_NORETURN;
+static void identify_from_stdin(void) NORETURN;
 static void identify_from_stdin(void)
 {
        uint16_t sbuf[256];
@@ -1924,7 +1916,7 @@ static void identify_from_stdin(void)
        unsigned char *b = (unsigned char *)buf;
        int i;
 
-       xread(0, buf, 1280);
+       xread(STDIN_FILENO, buf, 1280);
 
        // Convert the newline-separated hex data into an identify block.