Skip to contentSkip to conversation

drm/amdgpu/display: initialize the variable 'i'

PATCH Applied Souptick Joarder 5 participants 9 messages Feb 22, 2021 – Feb 23, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu/display: initialize the variable 'i'

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:
warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:
note: initialize the variable 'i' to silence this warning
           int i;
                ^
                 = 0

1 warning generated.

Initialize the variable 'i'.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index a22a53d..e96d3d9 100644
@@ -9717,7 +9717,7 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 					struct edid *edid)
 {
-	int i;
+	int i = 0;
 	struct detailed_timing *timing;
 	struct detailed_non_pixel *data;
 	struct detailed_data_monitor_range *range;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 10 lines · Souptick Joarder
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:
warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:
note: initialize the variable 'i' to silence this warning
           int i;
                ^
                 = 0
Quoted 3 lines

1 warning generated.

Initialize the variable 'i'.

Hm, I see this variable already initialized in the loop:

    for (i = 0; i < 4; i++) {

This is the branch agd5f/drm-next.

Quoted 20 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
index a22a53d..e96d3d9 100644
@@ -9717,7 +9717,7 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 					struct edid *edid)
 {
-	int i;
+	int i = 0;
 	struct detailed_timing *timing;
 	struct detailed_non_pixel *data;
 	struct detailed_data_monitor_range *range;
--
Quoted 1 line

1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 14 lines · Simon Ser
Quoted 12 lines · Souptick Joarder
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:
warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:
note: initialize the variable 'i' to silence this warning
           int i;
                ^
                 = 0

1 warning generated.

Quoted 7 lines
Quoted 1 line

Initialize the variable 'i'.

Hm, I see this variable already initialized in the loop:

    for (i = 0; i < 4; i++) {

This is the branch agd5f/drm-next.

That is in the

	if (amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT
		|| amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_EDP) {

branch not the

	} else if (edid && amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {

branch, where i is indeed used uninitialized like clang complains about.

I am not at all familiar with the code so I cannot say if this fix is the proper one but it is definitely a legitimate issue.

Cheers,
Nathan

Quoted 6 lines
Quoted 6 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 14 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
index a22a53d..e96d3d9 100644
@@ -9717,7 +9717,7 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 					struct edid *edid)
 {
-	int i;
+	int i = 0;
 	struct detailed_timing *timing;
 	struct detailed_non_pixel *data;
 	struct detailed_data_monitor_range *range;
--
Quoted 1 line

1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
Quoted 28 lines · Nathan Chancellor
Quoted 14 lines · Simon Ser
Quoted 12 lines · Souptick Joarder
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:
warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:
note: initialize the variable 'i' to silence this warning
           int i;
                ^
                 = 0

1 warning generated.

Quoted 7 lines
Quoted 1 line

Initialize the variable 'i'.

Hm, I see this variable already initialized in the loop:

    for (i = 0; i < 4; i++) {

This is the branch agd5f/drm-next.

That is in the

	if (amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT
		|| amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_EDP) {
Quoted 8 lines

branch not the

	} else if (edid && amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {

branch, where i is indeed used uninitialized like clang complains about.

I am not at all familiar with the code so I cannot say if this fix is the proper one but it is definitely a legitimate issue.

I think you have an outdated branch. In my checkout, i is not used in the first branch, and is initialized in the second one.

https://cgit.freedesktop.org/~agd5f/linux/tree/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c?h=drm-next#n9700
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw
Quoted 36 lines · Simon Ser
Quoted 34 lines · Nathan Chancellor
Quoted 14 lines · Simon Ser
Quoted 12 lines · Souptick Joarder
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:
warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:
note: initialize the variable 'i' to silence this warning
           int i;
                ^
                 = 0

1 warning generated.

Quoted 7 lines
Quoted 1 line

Initialize the variable 'i'.

Hm, I see this variable already initialized in the loop:

    for (i = 0; i < 4; i++) {

This is the branch agd5f/drm-next.

That is in the

	if (amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT
		|| amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_EDP) {

branch not the

	} else if (edid && amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {

branch, where i is indeed used uninitialized like clang complains about.

Quoted 7 lines
Quoted 2 lines

I am not at all familiar with the code so I cannot say if this fix is the proper one but it is definitely a legitimate issue.

I think you have an outdated branch. In my checkout, i is not used in the first branch, and is initialized in the second one.

https://cgit.freedesktop.org/~agd5f/linux/tree/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c?h=drm-next#n9700

That branch is the outdated one:

https://git.kernel.org/linus/a897913a819191550ab2fa2784d3c3ada3a096d3

Please see:

https://gitlab.freedesktop.org/agd5f/linux/-/blob/amd-staging-drm-next/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c#L9854

It was introduced by commit f9b4f20c4777 ("drm/amd/display: Add Freesync HDMI support to DM").

Cheers,
Nathan
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw
In reply to Simon Ser

I think Alex moved to gitlab for his branches

Quoted 46 lines · Simon Ser
Quoted 2 lines · Nathan Chancellor
Quoted 1 line · Simon Ser

On Monday, February 22nd, 2021 at 8:25 PM, Souptick Joarder <

Quoted 2 lines · [email protected]> wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

note: initialize the variable 'i' to silence this warning

           int i;
                ^
                 = 0

1 warning generated.

Initialize the variable 'i'.

Hm, I see this variable already initialized in the loop:

Quoted 7 lines
Quoted 3 lines
    for (i = 0; i < 4; i++) {

This is the branch agd5f/drm-next.

That is in the

      if (amdgpu_dm_connector->dc_sink->sink_signal ==

SIGNAL_TYPE_DISPLAY_PORT

Quoted 1 line
              || amdgpu_dm_connector->dc_sink->sink_signal ==

SIGNAL_TYPE_EDP) {

Quoted 4 lines

branch not the

      } else if (edid && amdgpu_dm_connector->dc_sink->sink_signal ==

SIGNAL_TYPE_HDMI_TYPE_A) {

Quoted 5 lines

branch, where i is indeed used uninitialized like clang complains about.

I am not at all familiar with the code so I cannot say if this fix is the proper one but it is definitely a legitimate issue.

Quoted 7 lines

I think you have an outdated branch. In my checkout, i is not used in the first
branch, and is initialized in the second one.

https://cgit.freedesktop.org/~agd5f/linux/tree/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c?h=drm-next#n9700

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw

yeah, fdo ran out of disk space so I moved to gitlab:
https://gitlab.freedesktop.org/agd5f/linux/-/commits/drm-next

Alex

Quoted 47 lines · Bas Nieuwenhuizen

I think Alex moved to gitlab for his branches

Quoted 43 lines · Simon Ser
Quoted 28 lines · Nathan Chancellor
Quoted 14 lines · Simon Ser
Quoted 12 lines · Souptick Joarder
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:
warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:
note: initialize the variable 'i' to silence this warning
           int i;
                ^
                 = 0

1 warning generated.

Quoted 7 lines
Quoted 1 line

Initialize the variable 'i'.

Hm, I see this variable already initialized in the loop:

    for (i = 0; i < 4; i++) {

This is the branch agd5f/drm-next.

That is in the

      if (amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT
              || amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_EDP) {
Quoted 8 lines

branch not the

      } else if (edid && amdgpu_dm_connector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {

branch, where i is indeed used uninitialized like clang complains about.

I am not at all familiar with the code so I cannot say if this fix is the proper one but it is definitely a legitimate issue.

I think you have an outdated branch. In my checkout, i is not used in the first branch, and is initialized in the second one.

Quoted 6 lines
Quoted 1 line

https://cgit.freedesktop.org/~agd5f/linux/tree/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c?h=drm-next#n9700

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Applied
#8 lore raw
In reply to Souptick Joarder
Quoted 11 lines · Souptick Joarder
Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9804:38:
warning: variable 'i' is uninitialized when used here [-Wuninitialized]

                           timing  = &edid->detailed_timings[i];
                                                             ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:9714:7:
note: initialize the variable 'i' to silence this warning
           int i;
                ^
                 = 0
Quoted 6 lines

1 warning generated.

Initialize the variable 'i'.

Applied. Thanks!

Alex

Quoted 20 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -2
index a22a53d..e96d3d9 100644
@@ -9717,7 +9717,7 @@ static bool parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
                                        struct edid *edid)
 {
-       int i;
+       int i = 0;
        struct detailed_timing *timing;
        struct detailed_non_pixel *data;
        struct detailed_data_monitor_range *range;
--

1.9.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx