OSDN Git Service

drm/amdgpu: replace snprintf in show functions with sysfs_emit
authorQing Wang <wangqing@vivo.com>
Fri, 15 Oct 2021 06:47:20 +0000 (23:47 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 20 Oct 2021 15:43:56 +0000 (11:43 -0400)
show() must not use snprintf() when formatting the value to be
returned to user space.

Fix the following coccicheck warning:
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c:427:
WARNING: use scnprintf or sprintf.

Signed-off-by: Qing Wang <wangqing@vivo.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c

index 0c3127f..920c4f6 100644 (file)
@@ -509,7 +509,7 @@ static ssize_t show_##name(struct device *dev,                              \
        struct drm_device *ddev = dev_get_drvdata(dev);                 \
        struct amdgpu_device *adev = drm_to_adev(ddev);                 \
                                                                        \
-       return snprintf(buf, PAGE_SIZE, "0x%08x\n", adev->field);       \
+       return sysfs_emit(buf, "0x%08x\n", adev->field);        \
 }                                                                      \
 static DEVICE_ATTR(name, mode, show_##name, NULL)