[PATCH v14] app/procinfo: display eventdev xstats

Stephen Hemminger stephen at networkplumber.org
Thu May 18 00:45:44 CEST 2023


On Wed, 17 May 2023 17:37:24 -0500
Abdullah Sevincer <abdullah.sevincer at intel.com> wrote:

> +static int
> +parse_eventdev_dump_xstats_params(char *list)
> +{
> +	uint8_t evdev_id;
> +	evdev_id = (uint8_t)atoi(list);
> +
> +	if (evdev_id >= RTE_EVENT_MAX_DEVS) {
> +		printf("Invalid eventdev id, id should be between 0 - %d\n", RTE_EVENT_MAX_DEVS-1);
> +		return -EINVAL;
> +	}

The cast will cause truncation of large values, so this might be a nop.
If you really want to check, then something like:

	unsigned long evdev_id;
	char *endp;

	evdev_id = strtoul(list, &endp, 0);
	if (!*list || !*endp || evdev_id >= RTE_EVENT_MAX_DEVS) {
	    fprintf(stderr, "Invalid eventdev id: %s\n", list);
	    return -EINVAL;
	}


More information about the dev mailing list