If argc is not < 3, it must be >= 3.
If argc >= 3, argv[2] cannot be NULL.
Fixes: 9de612ae4ded ("cmd: adc: Add support for storing ADC result in env variable")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- char *varname = NULL;
struct udevice *dev;
unsigned int data;
int ret, uV, val;
if (argc < 3)
return CMD_RET_USAGE;
- if (argc >= 3)
- varname = argv[2];
-
ret = adc_channel_single_shot(argv[1], simple_strtol(argv[2], NULL, 0),
&data);
if (ret) {
printf("%u\n", data);
}
- if (varname)
- env_set_ulong(varname, val);
+ env_set_ulong(argv[2], val);
return CMD_RET_SUCCESS;
}