* [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf
[not found] <cover.1704908087.git.jani.nikula@intel.com>
@ 2024-01-10 17:39 ` Jani Nikula
2024-01-12 4:09 ` kernel test robot
2024-01-12 14:57 ` Alex Deucher
0 siblings, 2 replies; 5+ messages in thread
From: Jani Nikula @ 2024-01-10 17:39 UTC (permalink / raw)
To: dri-devel
Cc: jani.nikula, intel-gfx, Xinhui, amd-gfx, Alex Deucher,
Christian König, Pan
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@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Pan, Xinhui <Xinhui.Pan@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf
2024-01-10 17:39 ` [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf Jani Nikula
@ 2024-01-12 4:09 ` kernel test robot
2024-01-12 9:07 ` Jani Nikula
2024-01-12 14:57 ` Alex Deucher
1 sibling, 1 reply; 5+ messages in thread
From: kernel test robot @ 2024-01-12 4:09 UTC (permalink / raw)
To: Jani Nikula, dri-devel
Cc: Pan, jani.nikula, intel-gfx, Xinhui, amd-gfx, oe-kbuild-all,
Alex Deucher, Christian König
Hi Jani,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.7 next-20240111]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jani-Nikula/drm-nouveau-acr-ga102-remove-unused-but-set-variable/20240111-014206
base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link: https://lore.kernel.org/r/fea7a52924f98b1ac24f4a7e6ba21d7754422430.1704908087.git.jani.nikula%40intel.com
patch subject: [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf
config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20240112/202401121126.i9VGrvMb-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240112/202401121126.i9VGrvMb-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401121126.i9VGrvMb-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: In function 'amdgpu_gfx_kiq_init_ring':
>> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:61: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 8 [-Wformat-truncation=]
332 | snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
| ^~
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:50: note: directive argument in the range [0, 2147483647]
332 | snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
| ^~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:9: note: 'snprintf' output between 12 and 41 bytes into a destination of size 16
332 | snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333 | xcc_id, ring->me, ring->pipe, ring->queue);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +332 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
306
307 int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
308 struct amdgpu_ring *ring,
309 struct amdgpu_irq_src *irq, int xcc_id)
310 {
311 struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
312 int r = 0;
313
314 spin_lock_init(&kiq->ring_lock);
315
316 ring->adev = NULL;
317 ring->ring_obj = NULL;
318 ring->use_doorbell = true;
319 ring->xcc_id = xcc_id;
320 ring->vm_hub = AMDGPU_GFXHUB(xcc_id);
321 ring->doorbell_index =
322 (adev->doorbell_index.kiq +
323 xcc_id * adev->doorbell_index.xcc_doorbell_range)
324 << 1;
325
326 r = amdgpu_gfx_kiq_acquire(adev, ring, xcc_id);
327 if (r)
328 return r;
329
330 ring->eop_gpu_addr = kiq->eop_gpu_addr;
331 ring->no_scheduler = true;
> 332 snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
333 xcc_id, ring->me, ring->pipe, ring->queue);
334 r = amdgpu_ring_init(adev, ring, 1024, irq, AMDGPU_CP_KIQ_IRQ_DRIVER0,
335 AMDGPU_RING_PRIO_DEFAULT, NULL);
336 if (r)
337 dev_warn(adev->dev, "(%d) failed to init kiq ring\n", r);
338
339 return r;
340 }
341
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf
2024-01-12 4:09 ` kernel test robot
@ 2024-01-12 9:07 ` Jani Nikula
0 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2024-01-12 9:07 UTC (permalink / raw)
To: kernel test robot, dri-devel
Cc: Pan, intel-gfx, Xinhui, amd-gfx, oe-kbuild-all, Alex Deucher,
Christian König
On Fri, 12 Jan 2024, kernel test robot <lkp@intel.com> wrote:
> Hi Jani,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on drm-misc/drm-misc-next]
> [also build test WARNING on drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.7 next-20240111]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Jani-Nikula/drm-nouveau-acr-ga102-remove-unused-but-set-variable/20240111-014206
> base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
> patch link: https://lore.kernel.org/r/fea7a52924f98b1ac24f4a7e6ba21d7754422430.1704908087.git.jani.nikula%40intel.com
> patch subject: [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf
> config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20240112/202401121126.i9VGrvMb-lkp@intel.com/config)
> compiler: sparc64-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240112/202401121126.i9VGrvMb-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202401121126.i9VGrvMb-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: In function 'amdgpu_gfx_kiq_init_ring':
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:61: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 8 [-Wformat-truncation=]
> 332 | snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
> | ^~
> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:50: note: directive argument in the range [0, 2147483647]
> 332 | snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
> | ^~~~~~~~~~~~~~~~~
> drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:9: note: 'snprintf' output between 12 and 41 bytes into a destination of size 16
> 332 | snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 333 | xcc_id, ring->me, ring->pipe, ring->queue);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As the commit message says,
This will trade the W=1 warning -Wformat-overflow to
-Wformat-truncation. This lets us enable -Wformat-overflow subsystem
wide.
BR,
Jani.
>
>
> vim +332 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
>
> 306
> 307 int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev,
> 308 struct amdgpu_ring *ring,
> 309 struct amdgpu_irq_src *irq, int xcc_id)
> 310 {
> 311 struct amdgpu_kiq *kiq = &adev->gfx.kiq[xcc_id];
> 312 int r = 0;
> 313
> 314 spin_lock_init(&kiq->ring_lock);
> 315
> 316 ring->adev = NULL;
> 317 ring->ring_obj = NULL;
> 318 ring->use_doorbell = true;
> 319 ring->xcc_id = xcc_id;
> 320 ring->vm_hub = AMDGPU_GFXHUB(xcc_id);
> 321 ring->doorbell_index =
> 322 (adev->doorbell_index.kiq +
> 323 xcc_id * adev->doorbell_index.xcc_doorbell_range)
> 324 << 1;
> 325
> 326 r = amdgpu_gfx_kiq_acquire(adev, ring, xcc_id);
> 327 if (r)
> 328 return r;
> 329
> 330 ring->eop_gpu_addr = kiq->eop_gpu_addr;
> 331 ring->no_scheduler = true;
> > 332 snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
> 333 xcc_id, ring->me, ring->pipe, ring->queue);
> 334 r = amdgpu_ring_init(adev, ring, 1024, irq, AMDGPU_CP_KIQ_IRQ_DRIVER0,
> 335 AMDGPU_RING_PRIO_DEFAULT, NULL);
> 336 if (r)
> 337 dev_warn(adev->dev, "(%d) failed to init kiq ring\n", r);
> 338
> 339 return r;
> 340 }
> 341
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf
2024-01-10 17:39 ` [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf Jani Nikula
2024-01-12 4:09 ` kernel test robot
@ 2024-01-12 14:57 ` Alex Deucher
2024-01-31 12:48 ` Jani Nikula
1 sibling, 1 reply; 5+ messages in thread
From: Alex Deucher @ 2024-01-12 14:57 UTC (permalink / raw)
To: Jani Nikula
Cc: Pan, intel-gfx, Xinhui, amd-gfx, dri-devel, Alex Deucher,
Christian König
On Wed, Jan 10, 2024 at 12:39 PM Jani Nikula <jani.nikula@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@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Pan, Xinhui <Xinhui.Pan@amd.com>
> Cc: amd-gfx@lists.freedesktop.org
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Alex Deucher <alexander.deucher@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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf
2024-01-12 14:57 ` Alex Deucher
@ 2024-01-31 12:48 ` Jani Nikula
0 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2024-01-31 12:48 UTC (permalink / raw)
To: Alex Deucher
Cc: dri-devel, intel-gfx, Xinhui, amd-gfx, Alex Deucher,
Christian König, Pan
On Fri, 12 Jan 2024, Alex Deucher <alexdeucher@gmail.com> wrote:
> On Wed, Jan 10, 2024 at 12:39 PM Jani Nikula <jani.nikula@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@amd.com>
>> Cc: Christian König <christian.koenig@amd.com>
>> Cc: Pan, Xinhui <Xinhui.Pan@amd.com>
>> Cc: amd-gfx@lists.freedesktop.org
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>
> Acked-by: Alex Deucher <alexander.deucher@amd.com>
>
> Feel free to take this via whichever tree makes sense.
Thanks, pushed this one patch to drm-misc-next as prep work.
BR,
Jani.
>
> 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
>>
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-01 14:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1704908087.git.jani.nikula@intel.com>
2024-01-10 17:39 ` [PATCH 3/6] drm/amdgpu: prefer snprintf over sprintf Jani Nikula
2024-01-12 4:09 ` kernel test robot
2024-01-12 9:07 ` Jani Nikula
2024-01-12 14:57 ` Alex Deucher
2024-01-31 12:48 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox