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

Stephen Hemminger
2024-09-01T15:44:33Z

On Sun, 1 Sep 2024 03:54:54 +0300
Michael Guralnik <michaelgur@nvidia.com> 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.

> +}