Re: [PATCH net-next v2] net: dsa: mv88e6xxx: control mdio bus-id truncation for long paths

From: Andrew Lunn
Date: Thu Apr 04 2024 - 10:30:11 EST


> + } else if (err >= MII_BUS_ID_SIZE) {
> + /* If generated bus id is truncated, names in sysfs
> + * may collide. Insert a special numeric suffix to mark
> + * truncation and avoid name collisions.
> + */
> + err = snprintf(NULL, 0, "...!-%d", trunc);
> + if (err < 0)
> + return err;

It took me a while to figure out what this was doing. Rather than err,
maybe add a new variable postfix_len, to give a clue that this is used
to determine how long the post fix is, and so how much needs to be
truncated from the end of the string to make room for it.

Andrew