Subject: Re: [RFC iproute2-next 2/4] rdma: Add support for rdma monitor

From: Stephen Hemminger <[email-masked]>
Date: Sun, 1 Sep 2024 08:44:31 -0700

On Sun, 1 Sep 2024 03:54:54 +0300
Michael Guralnik <[email-masked]> wrote:

Suggest these minor changes.

> +static const char *event_type_to_str(uint8_t etype)
> +{
> +	static const char *const event_types_str[] = { "[REGISTER]",
> +						       "[UNREGISTER]",
> +						       "[NETDEV_ATTACH]",
> +						       "[NETDEV_DETACH]" };

Break array initialization into:

	static const char *const event_types_str[] = {
			"[REGISTER]",
			"[UNREGISTER]"

> +	if (etype < ARRAY_SIZE(event_types_str))
> +		return event_types_str[etype];
> +
> +	return "[UNKNOWN]";

Might be useful to use snprintf to static buffer and print the hex value
for unknown events.

> +}