[dpdk-dev] [PATCH 2/2] eal: fix service core index validity

Stephen Hemminger stephen at networkplumber.org
Wed Apr 21 04:33:17 CEST 2021


On Wed, 21 Apr 2021 09:17:17 +0800
"Min Hu (Connor)" <humin29 at huawei.com> wrote:

>  		idx = strtoul(corelist, &end, 10);
>  		if (errno || end == NULL)
>  			return -1;
> +		if (idx < 0 || idx >= RTE_MAX_LCORE)

Wondered at first how strtoul() could ever return an negative value but then
noticed that idx is int here.

The code that does would be clearer and safer if the variables were an unsigned
type. idx, min, max should be the same type everywhere.

Looks like the original code was written in old C style of "all the world's an int"


More information about the dev mailing list