On Sat, Jan 31, 2026 at 04:53:09PM +0000, David Corvaglia wrote: > Replace sprintf with sysfs_emit in sysfs show() methods as outlined in > Documentation/filesystems/sysfs.rst. sysfs_emit is preferred to sprintf > in sysfs show() methods as it is safer with buffer handling. > > Signed-off-by: David Corvaglia <[email protected]>
Reviewed-by: Ido Schimmel <[email protected]> But the patch is introducing a few alignment issues and it would be good to fix them in v2. See below. [...] > @@ -87,7 +87,7 @@ static DEVICE_ATTR_RW(forward_delay); > static ssize_t hello_time_show(struct device *d, struct device_attribute > *attr, > char *buf) > { > - return sprintf(buf, "%lu\n", > + return sysfs_emit(buf, "%lu\n", > jiffies_to_clock_t(to_bridge(d)->hello_time)); Here > } > > @@ -108,7 +108,7 @@ static DEVICE_ATTR_RW(hello_time); > static ssize_t max_age_show(struct device *d, struct device_attribute *attr, > char *buf) > { > - return sprintf(buf, "%lu\n", > + return sysfs_emit(buf, "%lu\n", > jiffies_to_clock_t(to_bridge(d)->max_age)); Here > } > [...] > static int set_group_fwd_mask(struct net_bridge *br, unsigned long val, > @@ -200,7 +200,7 @@ static ssize_t priority_show(struct device *d, struct > device_attribute *attr, > char *buf) > { > struct net_bridge *br = to_bridge(d); > - return sprintf(buf, "%d\n", > + return sysfs_emit(buf, "%d\n", > (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); Here > } [...] > @@ -425,7 +425,7 @@ static ssize_t multicast_query_use_ifaddr_show(struct > device *d, > char *buf) > { > struct net_bridge *br = to_bridge(d); > - return sprintf(buf, "%d\n", > + return sysfs_emit(buf, "%d\n", > br_opt_get(br, BROPT_MULTICAST_QUERY_USE_IFADDR)); Here > } > @@ -583,7 +583,7 @@ static ssize_t multicast_last_member_interval_show( > struct device *d, struct device_attribute *attr, char *buf) > { > struct net_bridge *br = to_bridge(d); > - return sprintf(buf, "%lu\n", > + return sysfs_emit(buf, "%lu\n", > > jiffies_to_clock_t(br->multicast_ctx.multicast_last_member_interval)); Here > } > > @@ -606,7 +606,7 @@ static ssize_t multicast_membership_interval_show( > struct device *d, struct device_attribute *attr, char *buf) > { > struct net_bridge *br = to_bridge(d); > - return sprintf(buf, "%lu\n", > + return sysfs_emit(buf, "%lu\n", > > jiffies_to_clock_t(br->multicast_ctx.multicast_membership_interval)); Here > } > > @@ -630,7 +630,7 @@ static ssize_t multicast_querier_interval_show(struct > device *d, > char *buf) > { > struct net_bridge *br = to_bridge(d); > - return sprintf(buf, "%lu\n", > + return sysfs_emit(buf, "%lu\n", > > jiffies_to_clock_t(br->multicast_ctx.multicast_querier_interval)); Here > } > > @@ -654,7 +654,7 @@ static ssize_t multicast_query_interval_show(struct > device *d, > char *buf) > { > struct net_bridge *br = to_bridge(d); > - return sprintf(buf, "%lu\n", > + return sysfs_emit(buf, "%lu\n", > > jiffies_to_clock_t(br->multicast_ctx.multicast_query_interval)); Here > } [...] > @@ -727,7 +727,7 @@ static ssize_t multicast_stats_enabled_show(struct device > *d, > { > struct net_bridge *br = to_bridge(d); > > - return sprintf(buf, "%d\n", > + return sysfs_emit(buf, "%d\n", > br_opt_get(br, BROPT_MULTICAST_STATS_ENABLED)); Here > }
