cmd/eeprom: fix data type issue for parse_numeric_param

This patch fixs parse_numeric_param issue on some platfrom which has
different sizes of int and long, like riscv64.

On riscv64, int is 4 bytes, but long is 8 bytes.

on this situation:
ulong addr = parse_numeric_param(argv[index]);

if argv[index] is "0x80000000", this "ulong addr" will be
0xffffffff80000000.

Signed-off-by: Jianlong.Huang <jianlong.huang@starfivetech.com>
Co-developed-by: Wei Fu <wefu@redhat.com>
Signed-off-by: Wei Fu <wefu@redhat.com>
This commit is contained in:
Jianlong.Huang 2021-10-27 09:17:57 +08:00 committed by Tekkaman Ninja
parent 4793fbc0f0
commit 803349d956

View file

@ -200,10 +200,10 @@ int eeprom_write(unsigned dev_addr, unsigned offset,
return ret;
}
static int parse_numeric_param(char *str)
static long parse_numeric_param(char *str)
{
char *endptr;
int value = simple_strtol(str, &endptr, 16);
long value = simple_strtol(str, &endptr, 16);
return (*endptr != '\0') ? -1 : value;
}