sleep(i);
}
-static void check_if_min_and_set_val(uint16_t a, uint16_t b)
+static uint16_t check_if_min_and_set_val(uint16_t a, uint16_t b)
{
if( a < b)
a = b;
+ return a;
}
-static void check_if_maj_and_set_val(uint16_t a, uint16_t b)
+static uint16_t check_if_maj_and_set_val(uint16_t a, uint16_t b)
{
if( a > b)
a = b;
+ return a;
}
-static
-unsigned long int set_flag(char *p, char max)
+static unsigned long int set_flag(char *p, char max)
{
if (*p >= '0' && *p <= max )
return 1;
{
if(val[MINOR] && (val[MINOR] <= MINOR_MAX))
{
- check_if_min_and_set_val( like_std, 3);
+ like_std=check_if_min_and_set_val(like_std, 3);
std = actual_ver[val[MINOR]];
if_printf(std,"\n\tUsed: %s ",minor_str[val[MINOR]]);
like_std = ii;
kk = like_std >4 ? like_std-4: 0;
}
- check_if_maj_and_set_val(min_std, ii);
+ min_std=check_if_maj_and_set_val(min_std, ii);
}
jj <<= 1;
}
- check_if_min_and_set_val( like_std, 3);
+ like_std=check_if_min_and_set_val(like_std, 3);
}
/* Figure out what standard the device is using if it hasn't told
* us. If we know the std, check if the device is using any of
* the words from the next level up. It happens.
*/
- check_if_min_and_set_val( like_std, std);
+ like_std=check_if_min_and_set_val(like_std, std);
if(((std == 5) || (!std && (like_std < 6))) &&
((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
{
unsigned char args[4] = {WIN_SETFEATURES,0,0,0};
no_scsi();
- check_if_min_and_set_val(apmmode,1);
- check_if_maj_and_set_val(apmmode,255);
+ apmmode=check_if_min_and_set_val(apmmode,1);
+ apmmode=check_if_maj_and_set_val(apmmode,255);
if_printf(get_apmmode," setting APM level to");
if (apmmode==255)
{
}
#endif
+static void missing_arg(int arg, char c, char* add)
+{
+ if (!arg)
+ bb_error_msg("-%c: missing value %s", c, (add!=NULL)? add :"");
+}
+
/* our main() routine: */
int hdparm_main(int argc, char **argv)
{
- const char * const bb_msg_missing_value ="missing value";
char c, *p;
- /*int neg;*/
++argv;
if (!--argc)
if (!*p && argc && isalnum(**argv))
p = *argv++, --argc;
p=GET_NUMBER(p,&set_standby,&standby_requested);
- if (!set_standby)
- bb_error_msg("-S: %s", bb_msg_missing_value);
+ missing_arg(set_standby, c, NULL);
break;
case 'D':
if (!*p && argc && isalnum(**argv))
p = *argv++, --argc;
p=GET_NUMBER(p,&set_defects,&defects);
- if (!set_defects)
- bb_error_msg("-D: %s", bb_msg_missing_value);
+ missing_arg(set_defects, c, NULL);
break;
case 'P':
get_prefetch = noisy;
if (!*p && argc && isalnum(**argv))
p = *argv++, --argc;
p=GET_NUMBER(p,&set_prefetch,&prefetch);
- if (!set_prefetch)
- bb_error_msg("-P: %s", bb_msg_missing_value);
+ missing_arg(set_prefetch, c, NULL);
break;
case 'X':
if (!*p && argc && isalnum(**argv))
p = *argv++, --argc;
p=GET_STRING(p,&set_xfermode,&xfermode_requested);
- if (!set_xfermode)
- bb_error_msg("-X: %s", bb_msg_missing_value);
+ missing_arg(set_xfermode, c, NULL);
break;
case 'K':
if((set_dkeep = set_flag(p,'1'))==1)
dkeep = *p++ - '0';
else
- bb_error_msg("-K: %s (0/1)", bb_msg_missing_value);
+ goto missing_arg_error;
break;
case 'A':
if((set_lookahead = set_flag(p,'1'))==1)
lookahead = *p++ - '0';
else
- bb_error_msg("-A: %s (0/1)", bb_msg_missing_value);
+ goto missing_arg_error;
break;
case 'L':
if((set_doorlock = set_flag(p,'1'))==1)
doorlock = *p++ - '0';
else
- bb_error_msg("-L: %s (0/1)", bb_msg_missing_value);
+ goto missing_arg_error;
break;
case 'W':
if((set_wcache = set_flag(p,'1'))==1)
wcache = *p++ - '0';
else
- bb_error_msg("-W: %s (0/1)", bb_msg_missing_value);
+missing_arg_error:
+ missing_arg(1, c, "(0/1)");
break;
case 'C':
if (!*p && argc && isdigit(**argv))
p = *argv++, --argc;
if(! p)
- goto error; /* "expected hwif_nr" */
+ goto expected_hwif_error; /* "expected hwif_nr" */
sscanf(p++, "%i", &hwif);
if (!*p && argc && isdigit(**argv))
p = *argv++, --argc;
if(! p)
- goto error; /* "expected hwif_data" */
+ goto expected_hwif_error; /* "expected hwif_data" */
sscanf(p++, "%i", &hwif_data);
if (argc && isdigit(**argv))
p = *argv++, --argc;
else
- goto error; /* "expected hwif_ctrl" */
+ goto expected_hwif_error; /* "expected hwif_ctrl" */
sscanf(p, "%i", &hwif_ctrl);
if (argc && isdigit(**argv))
p = *argv++, --argc;
else
-error:
+expected_hwif_error:
bb_error_msg_and_die("expected hwif value"); /* "expected hwif_irq" */
sscanf(p, "%i", &hwif_irq);
if((perform_tristate = set_flag(p,'1'))==1)
tristate = *p++ - '0';
else
- bb_error_msg("-x: %s (0/1)", bb_msg_missing_value);
+ missing_arg(1, c, "(0/1)");
break;
#endif /* CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF */
if (!*p && argc && isalnum(**argv))
p = *argv++, --argc;
p=GET_NUMBER(p,&set_apmmode,&apmmode);
- if (!set_apmmode)
- bb_error_msg("-B: %s (1-255)", bb_msg_missing_value);
+ missing_arg(set_apmmode, c, "(1-255)");
break;
case 't':
do_timings = 1;