Skip to contentSkip to conversation

drm: arm: replace snprintf in show functions with sysfs_emit

PATCH New Qing Wang 1 participant 1 message Oct 15, 2021

Subsystems (3)
lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 drm: arm: replace snprintf in show functions with sysfs_emit

show() must not use snprintf() when formatting the value to be returned to user space.

Fix the following coccicheck warning:
drivers/gpu/drm/arm/malidp_drv.c:657:8-16: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---
 drivers/gpu/drm/arm/malidp_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/arm/malidp_drv.c +1 -1
index de59f33..d1af23f 100644
@@ -654,7 +654,7 @@ static ssize_t core_id_show(struct device *dev, struct device_attribute *attr,
 	struct drm_device *drm = dev_get_drvdata(dev);
 	struct malidp_drm *malidp = drm->dev_private;
 
-	return snprintf(buf, PAGE_SIZE, "%08x\n", malidp->core_id);
+	return sysfs_emit(buf, "%08x\n", malidp->core_id);
 }
 
 static DEVICE_ATTR_RO(core_id);
Signature · 1 line
2.7.4