Skip to contentSkip to conversation

drm/amd/display: Fix warning about overflow

PATCH In review Harry Wentland 4 participants 5 messages Oct 13, 2017 – Oct 16, 2017 3 messages not in the archive

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

PATCH v2 1/1 drm/amd/display: Fix warning about overflow

v2: convert value to bool using !!

---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +5 -5
index cb94e18cc455..43e9a9959288 100644
@@ -1042,13 +1042,13 @@ static enum bp_result get_embedded_panel_info_v2_1(
 	info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0;
 
 	info->lcd_timing.misc_info.H_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2);
 	info->lcd_timing.misc_info.V_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2);
 	info->lcd_timing.misc_info.COMPOSITE_SYNC =
-		lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC;
+		!!(lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC);
 	info->lcd_timing.misc_info.INTERLACE =
-		lvds->lcd_timing.miscinfo & ATOM_INTERLACE;
+		!!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE);
 
 	/* not provided by VBIOS*/
 	info->lcd_timing.misc_info.DOUBLE_CLOCK = 0;
@@ -1056,7 +1056,7 @@ static enum bp_result get_embedded_panel_info_v2_1(
 	info->ss_id = 0;
 
 	info->realtek_eDPToLVDS =
-			(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID ? 1:0);
+			!!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID);
 
 	return BP_RESULT_OK;
 }
Signature · 6 lines
2.14.1

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by Alex Deucher
#2 lore raw
Quoted 9 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Harry Wentland
Sent: Friday, October 13, 2017 3:03 PM
To: [email protected]; [email protected]; Daenzer, Michel; Koenig, Christian
Cc: Wentland, Harry
Subject: [PATCH v2] drm/amd/display: Fix warning about overflow

Quoted 3 lines

v2: convert value to bool using !!

Quoted 42 lines
---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +0 -0
index cb94e18cc455..43e9a9959288 100644
@@ -1042,13 +1042,13 @@ static enum bp_result

get_embedded_panel_info_v2_1(

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +4 -4
 	info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0;
 
 	info->lcd_timing.misc_info.H_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2);
 	info->lcd_timing.misc_info.V_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2);
 	info->lcd_timing.misc_info.COMPOSITE_SYNC =
-		lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC;
+		!!(lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC);
 	info->lcd_timing.misc_info.INTERLACE =
-		lvds->lcd_timing.miscinfo & ATOM_INTERLACE;
+		!!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE);
 
 	/* not provided by VBIOS*/
 	info->lcd_timing.misc_info.DOUBLE_CLOCK = 0;
@@ -1056,7 +1056,7 @@ static enum bp_result

get_embedded_panel_info_v2_1(

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +0 -1
 	info->ss_id = 0;
 
 	info->realtek_eDPToLVDS =
-			(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID ?

1:0);

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +1 -1
+			!!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID);
 
 	return BP_RESULT_OK;
 }
--

2.14.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

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB16526E196D98A738406709B7F7480-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

Reviewed-by
#4 lore raw

Am 13.10.2017 um 21:04 schrieb Deucher, Alexander:

Quoted 9 lines
Quoted 9 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Harry Wentland
Sent: Friday, October 13, 2017 3:03 PM
To: [email protected]; [email protected]; Daenzer, Michel; Koenig, Christian
Cc: Wentland, Harry
Subject: [PATCH v2] drm/amd/display: Fix warning about overflow

Quoted 4 lines
Quoted 3 lines

v2: convert value to bool using !!

Quoted 43 lines
Quoted 43 lines
---
  drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +0 -0
index cb94e18cc455..43e9a9959288 100644
@@ -1042,13 +1042,13 @@ static enum bp_result

get_embedded_panel_info_v2_1(
info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0;

info->lcd_timing.misc_info.H_REPLICATION_BY2 =

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +4 -4
-		lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2);
  	info->lcd_timing.misc_info.V_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2);
  	info->lcd_timing.misc_info.COMPOSITE_SYNC =
-		lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC;
+		!!(lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC);
  	info->lcd_timing.misc_info.INTERLACE =
-		lvds->lcd_timing.miscinfo & ATOM_INTERLACE;
+		!!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE);
 
  	/* not provided by VBIOS*/
  	info->lcd_timing.misc_info.DOUBLE_CLOCK = 0;
@@ -1056,7 +1056,7 @@ static enum bp_result

get_embedded_panel_info_v2_1(
info->ss_id = 0;

info->realtek_eDPToLVDS =

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +0 -1
-			(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID ?

1:0);

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +1 -1
+			!!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID);
 
  	return BP_RESULT_OK;
  }
--

2.14.1

Quoted 8 lines
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

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

Reviewed-by
#5 lore raw
In reply to a message not in the archive
Quoted 31 lines · Harry Wentland

v2: convert value to bool using !!

---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +4 -4
index cb94e18cc455..43e9a9959288 100644
@@ -1042,13 +1042,13 @@ static enum bp_result get_embedded_panel_info_v2_1(
 	info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0;
 
 	info->lcd_timing.misc_info.H_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2);
 	info->lcd_timing.misc_info.V_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2);
 	info->lcd_timing.misc_info.COMPOSITE_SYNC =
-		lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC;
+		!!(lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC);
 	info->lcd_timing.misc_info.INTERLACE =
-		lvds->lcd_timing.miscinfo & ATOM_INTERLACE;
+		!!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE);
 
 	/* not provided by VBIOS*/
 	info->lcd_timing.misc_info.DOUBLE_CLOCK = 0;

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c static enum bp_result get_embedded_panel_info_v2_1( · line 1062

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +1 -1
@@ -1056,7 +1056,7 @@ static enum bp_result get_embedded_panel_info_v2_1(
 	info->ss_id = 0;
 
 	info->realtek_eDPToLVDS =
-			(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID ? 1:0);
+			!!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID);
 
 	return BP_RESULT_OK;
 }

The commit log doesn't fit the change very well anymore.

Pet peeve alert:

In general, IMHO one doesn't "fix a warning". One either fixes a problem which was highlighted by a warning, such as in this case, or one silences the warning instead. One should always make sure carefully there's no actual problem behind a warning before simply silencing it.

That said, the actual fix is

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 7aa74a33-e9a5-5ddd-8999-9bb97f303165-otUistvHUpPR7s880joybQ@public.gmane.org

#7 lore raw
Quoted 44 lines · Michel Dänzer
Quoted 31 lines · Harry Wentland

v2: convert value to bool using !!

---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +4 -4
index cb94e18cc455..43e9a9959288 100644
@@ -1042,13 +1042,13 @@ static enum bp_result get_embedded_panel_info_v2_1(
 	info->lcd_timing.misc_info.VERTICAL_CUT_OFF = 0;
 
 	info->lcd_timing.misc_info.H_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_H_REPLICATIONBY2);
 	info->lcd_timing.misc_info.V_REPLICATION_BY2 =
-		lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2;
+		!!(lvds->lcd_timing.miscinfo & ATOM_V_REPLICATIONBY2);
 	info->lcd_timing.misc_info.COMPOSITE_SYNC =
-		lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC;
+		!!(lvds->lcd_timing.miscinfo & ATOM_COMPOSITESYNC);
 	info->lcd_timing.misc_info.INTERLACE =
-		lvds->lcd_timing.miscinfo & ATOM_INTERLACE;
+		!!(lvds->lcd_timing.miscinfo & ATOM_INTERLACE);
 
 	/* not provided by VBIOS*/
 	info->lcd_timing.misc_info.DOUBLE_CLOCK = 0;

drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c static enum bp_result get_embedded_panel_info_v2_1( · line 1062

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +1 -1
@@ -1056,7 +1056,7 @@ static enum bp_result get_embedded_panel_info_v2_1(
 	info->ss_id = 0;
 
 	info->realtek_eDPToLVDS =
-			(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID ? 1:0);
+			!!(lvds->dplvdsrxid == eDP_TO_LVDS_REALTEK_ID);
 
 	return BP_RESULT_OK;
 }

The commit log doesn't fit the change very well anymore.

Quoted 8 lines

Pet peeve alert:

In general, IMHO one doesn't "fix a warning". One either fixes a problem which was highlighted by a warning, such as in this case, or one silences the warning instead. One should always make sure carefully there's no actual problem behind a warning before simply silencing it.

Very good points and thanks for preaching it. We've been doing quite badly on this front in the DC team and I often get lazy myself. Will keep an eye on this going forward.

Quoted 2 lines

That said, the actual fix is

Thanks.

Harry

Quoted 3 lines

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