[PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf

Alex Deucher alexdeucher at gmail.com
Fri Jan 12 14:57:23 UTC 2024


On Wed, Jan 10, 2024 at 12:39 PM Jani Nikula <jani.nikula at intel.com> wrote:
>
> This will trade the W=1 warning -Wformat-overflow to
> -Wformat-truncation. This lets us enable -Wformat-overflow subsystem
> wide.
>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Pan, Xinhui <Xinhui.Pan at amd.com>
> Cc: amd-gfx at lists.freedesktop.org
> Signed-off-by: Jani Nikula <jani.nikula at intel.com>

Acked-by: Alex Deucher <alexander.deucher at amd.com>

Feel free to take this via whichever tree makes sense.

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index b9674c57c436..82b4b2019fca 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> @@ -329,7 +329,8 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
>
>         ring->eop_gpu_addr = kiq->eop_gpu_addr;
>         ring->no_scheduler = true;
> -       sprintf(ring->name, "kiq_%d.%d.%d.%d", xcc_id, ring->me, ring->pipe, ring->queue);
> +       snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
> +                xcc_id, ring->me, ring->pipe, ring->queue);
>         r = amdgpu_ring_init(adev, ring, 1024, irq, AMDGPU_CP_KIQ_IRQ_DRIVER0,
>                              AMDGPU_RING_PRIO_DEFAULT, NULL);
>         if (r)
> --
> 2.39.2
>


More information about the amd-gfx mailing list