public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/intel_reg: fix shift undefined behaviour
@ 2019-03-21 10:26 Simon Ser
  2019-03-21 11:43 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Simon Ser @ 2019-03-21 10:26 UTC (permalink / raw)
  To: igt-dev

1<<31 (same as 2<<30) is undefined behaviour in C. When compiling with
GCC and UBSan, it gives this error:

../tools/intel_reg_decode.c: In function ‘ivb_debug_port’:
../tools/intel_reg_decode.c:398:3: error: case label does not reduce to an integer constant
   case PORT_DBG_DRRS_HW_STATE_HIGH:
   ^~~~

This happens because 1<<31 isn't representable as a signed int. Instead,
use am unsigned int.

Signed-off-by: Simon Ser <simon.ser@intel.com>
---
 lib/intel_reg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/intel_reg.h b/lib/intel_reg.h
index f85fb742..069440cb 100644
--- a/lib/intel_reg.h
+++ b/lib/intel_reg.h
@@ -3383,7 +3383,7 @@ typedef enum {
 #define PORT_DBG                    0x42308
 #define  PORT_DBG_DRRS_HW_STATE_OFF     (0<<30)
 #define  PORT_DBG_DRRS_HW_STATE_LOW     (1<<30)
-#define  PORT_DBG_DRRS_HW_STATE_HIGH    (2<<30)
+#define  PORT_DBG_DRRS_HW_STATE_HIGH    (2U<<30)
 
 /* RC6 residence counters
  */
-- 
2.21.0

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-16 10:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-21 10:26 [igt-dev] [PATCH i-g-t] lib/intel_reg: fix shift undefined behaviour Simon Ser
2019-03-21 11:43 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-03-21 22:21 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-04-16 10:36 ` [igt-dev] [PATCH i-g-t] " Petri Latvala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox