drm/amdgpu/vcn: fix unitialized variable warnings
Subsystems (2)
PATCH 1/1 drm/amdgpu/vcn: fix unitialized variable warnings
Init r to 0 to avoid returning an uninitialized value if we never enter the loop. This case should never be hit in practive, but returning 0 doesn't hurt.
The same fix is applied to the 4 places using the same pattern.
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1 -1
@@ -298,7 +298,7 @@ static int vcn_v3_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, j, r; +int i, j, r =0 ;if (amdgpu_sriov_vf (adev)) { r =vcn_v3_0_start_sriov (adev);
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1 -1
@@ -253,7 +253,7 @@ static int vcn_v4_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;if (amdgpu_sriov_vf (adev)) { r =vcn_v4_0_start_sriov (adev);
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +1 -1
@@ -221,7 +221,7 @@ static int vcn_v4_0_5_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c +1 -1
@@ -187,7 +187,7 @@ static int vcn_v5_0_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))
Signature · 1 line
2.41.0
Quoted 3 lines · Pierre-Eric Pelloux-Prayer
Init r to 0 to avoid returning an uninitialized value if we never enter the loop. This case should never be hit in practive, but
s/practive/practice/
Quoted 1 line
returning 0 doesn't hurt.
s/returning/initializing to/
With that fixed,
Quoted 66 lines
The same fix is applied to the 4 places using the same pattern.
Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1
-1@@ -298,7 +298,7 @@ static int vcn_v3_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, j, r; +int i, j, r =0 ;if (amdgpu_sriov_vf (adev)) { r =vcn_v3_0_start_sriov (adev);drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1
-1@@ -253,7 +253,7 @@ static int vcn_v4_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;if (amdgpu_sriov_vf (adev)) { r =vcn_v4_0_start_sriov (adev);drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +1
-1@@ -221,7 +221,7 @@ static int vcn_v4_0_5_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c +1
-2@@ -187,7 +187,7 @@ static int vcn_v5_0_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i)) --2.41.0
Am 18.04.24 um 20:07 schrieb Pierre-Eric Pelloux-Prayer:
Quoted 19 lines
Init r to 0 to avoid returning an uninitialized value if we never enter the loop. This case should never be hit in practive, but returning 0 doesn't hurt.
The same fix is applied to the 4 places using the same pattern.
Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c | 2 +- drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c static int vcn_v3_0_hw_init(void *handle) · line 301
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +1
-1@@ -298,7 +298,7 @@ static int vcn_v3_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, j, r; +int i, j, r =0 ;
That is usually considered bad coding style.
Better insert a "return 0;" directly before the done label.
Regards,
Christian.
Quoted 42 lines
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +0
-0if (amdgpu_sriov_vf (adev)) { r =vcn_v3_0_start_sriov (adev);drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1
-1@@ -253,7 +253,7 @@ static int vcn_v4_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;if (amdgpu_sriov_vf (adev)) { r =vcn_v4_0_start_sriov (adev);drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c +1
-1@@ -221,7 +221,7 @@ static int vcn_v4_0_5_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c +1
-1@@ -187,7 +187,7 @@ static int vcn_v5_0_0_hw_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct amdgpu_ring *ring; -int i, r; +int i, r =0 ;for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) {if (adev->vcn.harvest_config & (1 << i))