static void print_flag_on_off(unsigned long get_arg, const char *s, unsigned long arg)
{
-
- if (get_arg)
- {
+ if (get_arg) {
printf(" setting %s to %ld", s, arg);
on_off(arg);
}
{
if (ioctl(fd, request, &argp) != 0)
bb_perror_msg(" %s", string);
- else
- {
+ else {
printf(" %s\t= %2ld", str, (unsigned long) argp);
on_off((unsigned long) argp);
}
#ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY
static void print_ascii(uint16_t *p, uint8_t length);
-static void xprint_ascii(uint16_t *val ,int i, char * string, int n)
+static void xprint_ascii(uint16_t *val ,int i, const char *string, int n)
{
- if (val[i])
- {
- printf("\t%-20s",string);
+ if (val[i]) {
+ printf("\t%-20s", string);
print_ascii(&val[i], n);
}
}
#endif
-/* end of busybox specific stuff */
+/* end of busybox specific stuff */
#ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY
static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t *have_mode)
printf("%c%c",(char)0x00ff&((*p)>>8),(char)(*p)&0x00ff);
p++;
}
- printf("\n");
+ puts("");
}
// Parse 512 byte disk identification block and print much crap.
chksum &= 0xff;
/* check if we recognise the device type */
- printf("\n");
+ puts("");
if (!(val[GEN_CONFIG] & NOT_ATA))
{
dev = ATA_DEV;
}
else
/*"Unknown device type:\n\tbits 15&14 of general configuration word 0 both set to 1.\n"*/
- bb_error_msg_and_die("Unknown device type");
+ bb_error_msg_and_die("unknown device type");
printf("%sremovable media\n", !(val[GEN_CONFIG] & MEDIA_REMOVABLE) ? "non-" : "");
/* Info from the specific configuration word says whether or not the
else if (like_std > std)
printf("& some of %u\n",like_std);
else
- printf("\n");
+ puts("");
}
else
{
if (bbbig > 1000)
printf("(%"PRIu64" GB)\n", bbbig/1000);
else
- printf("\n");
+ puts("");
}
/* hw support of commands (capabilities) */
if ((like_std > 3) && ((val[CAPAB_1] & VALID) == VALID_VAL))
printf(", %s device specific minimum\n",(val[CAPAB_1] & MIN_STANDBY_TIMER)?"with":"no");
else
- printf("\n");
+ puts("");
}
printf("\tR/W multiple sector transfer: ");
if ((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER))
printf("\tOverlap support:");
if (val[PKT_REL]) printf(" %uus to release bus.",val[PKT_REL]);
if (val[SVC_NBSY]) printf(" %uus to clear BSY after SERVICE cmd.",val[SVC_NBSY]);
- printf("\n");
+ puts("");
}
}
err_dma += mode_loop(jj,kk,'u',&have_mode);
}
if (err_dma || !have_mode) printf("(?)");
- printf("\n");
+ puts("");
if ((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP))
printf("\t\tInterleaved DMA support\n");
printf("\t\tCycle time:");
if (val[DMA_TIME_MIN]) printf(" min=%uns",val[DMA_TIME_MIN]);
if (val[DMA_TIME_NORM]) printf(" recommended=%uns",val[DMA_TIME_NORM]);
- printf("\n");
+ puts("");
}
}
if (jj & 0x0001) printf("pio%d ",ii);
jj >>=1;
}
- printf("\n");
+ puts("");
}
else if (((min_std < 5) || (eqpt == CDROM)) && (val[PIO_MODE] & MODE) )
{
for (ii = 0; ii <= val[PIO_MODE]>>8; ii++)
printf("pio%d ",ii);
- printf("\n");
+ puts("");
}
else
printf("unknown\n");
printf("\t\tCycle time:");
if (val[PIO_NO_FLOW]) printf(" no flow control=%uns", val[PIO_NO_FLOW]);
if (val[PIO_FLOW]) printf(" IORDY flow control=%uns", val[PIO_FLOW]);
- printf("\n");
+ puts("");
}
}
printf("\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 ");
- printf("\n");
+ puts("");
}
}
else
printf("off");
}
- printf("\n");
+ puts("");
if (!(id->field_valid&1))
printf(" (maybe):");
}
#endif /* HDIO_DRIVE_CMD */
-static void print_flag(unsigned long flag, char *s, unsigned long value)
+static void print_flag(unsigned long flag, const char *s, unsigned long value)
{
if (flag)
printf(" setting %s to %ld\n", s, value);
#ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY
static int fromhex(unsigned char c)
{
- if (c >= 'a' && c <= 'f')
- return 10 + (c - 'a');
- if (c >= '0' && c <= '9')
+ if (isdigit(c))
return (c - '0');
+ if (c >= 'a' && c <= 'f')
+ return (c - ('a' - 10));
bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c);
}
static void identify_from_stdin(void)
{
uint16_t sbuf[256];
- unsigned char buf[1280], *b = (unsigned char *)buf;
- int i, count = read(0, buf, 1280);
+ unsigned char buf[1280];
+ unsigned char *b = (unsigned char *)buf;
+ int i;
- if (count != 1280)
- bb_error_msg_and_die("read(%d bytes) failed (rc=%d)", 1280, count);
+ xread(0, buf, 1280);
// Convert the newline-separated hex data into an identify block.
- for (i = 0; i<256; i++)
- {
+ for (i = 0; i<256; i++) {
int j;
- for(j=0;j<4;j++) sbuf[i] = (sbuf[i] <<4) + fromhex(*(b++));
+ for (j = 0; j < 4; j++)
+ sbuf[i] = (sbuf[i] << 4) + fromhex(*(b++));
}
// Parse the data.
/*-------------------------------------*/
/* our main() routine: */
+int hdparm_main(int argc, char **argv) ATTRIBUTE_NORETURN;;
int hdparm_main(int argc, char **argv) ATTRIBUTE_NORETURN;
+int hdparm_main(int argc, char **argv);
int hdparm_main(int argc, char **argv)
{
int c;