-----Original Message-----
From: Alex Deucher <alexdeucher@xxxxxxxxx>
Sent: Monday, January 9, 2023 10:04
To: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@xxxxxxx>
Cc: Wentland, Harry <Harry.Wentland@xxxxxxx>; Deucher, Alexander
<Alexander.Deucher@xxxxxxx>; Koenig, Christian
<Christian.Koenig@xxxxxxx>; amd-gfx@xxxxxxxxxxxxxxxxxxxxx; Limonciello,
Mario <Mario.Limonciello@xxxxxxx>
Subject: Re: [PATCH v2] drm/amd/amdgpu: Fix an uninitialized variable
On Mon, Jan 9, 2023 at 10:58 AM Srinivasan Shanmugam
<srinivasan.shanmugam@xxxxxxx> wrote:
CC drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.o
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c:217:71: error: variable 'i' is
uninitialized when used here [-Werror,-Wuninitialized]
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s%d.bin",
ucode_prefix, i);
^
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c:207:16: note: initialize the
variable 'i' to silence this warning
int err = 0, i;
^
= 0
As suggested by Christian, buggy
"snprintf(fw_name, sizeof(fw_name), "amdgpu/%s%d.bin", ucode_prefix,
i);"
shouldn't be "i" in the first place, but rather using "instance",
because for instance greater than 0, we want to have different
sdma firmware for different instance we add the instance number.
Remove setting err to 0 as well. This is considered very bad coding style.
Cc: Christian König <christian.koenig@xxxxxxx>
Cc: Mario Limonciello <mario.limonciello@xxxxxxx>
Cc: Alex Deucher <alexander.deucher@xxxxxxx>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@xxxxxxx>
Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx>