OSDN Git Service

drm/amdkfd: Fix GCC 10 compiler warning
authorFelix Kuehling <Felix.Kuehling@amd.com>
Fri, 22 May 2020 19:57:51 +0000 (15:57 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 28 May 2020 21:46:20 +0000 (17:46 -0400)
commit83a13ef5902aeedbd84ab282c835059c2cae5783
treefad7120054c10bbb3d7d41edc5a3272b916a43b4
parentb0f8a6d5ef0e5d37176e4ce8e297bfffb7438503
drm/amdkfd: Fix GCC 10 compiler warning

GCC 10 was complaining about how we append data to a buffer using snprintf:

drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c: In function ‘perf_show’:
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:214:3: warning: ‘snprintf’ argument 4 overlaps destination object ‘buf’ [-Wrestrict]
  214 |   snprintf(buffer, PAGE_SIZE, "%s"fmt, buffer, __VA_ARGS__)
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch fixes the warnings and makes the sysfs code more efficient
by remembering the offset in the buffer between append operations.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Acked-by: Aaron Liu <aaron.liu@amd.com>
Tested-by: Aaron Liu <aaron.liu@amd.com>
Reviewed-by: Amber Lin <Amber.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_topology.c