Skip to contentSkip to conversation

media: dvb_frontend.h: Fix shifting signed 32-bit value problem

PATCH Superseded Luke Nowakowski-Krijger 3 participants 3 messages Jul 4, 2019 – Jul 5, 2019 Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: dvb_frontend.h: Fix shifting signed 32-bit value problem

Fix DVBFE_ALGO_RECOVERY and DVBFE_ALGO_SEARCH_ERROR to use U cast which fixes undefined behavior error by certain compilers.

Signed-off-by Luke Nowakowski-Krijger <lnowakow at eng.ucsd.edu>
---
 include/media/dvb_frontend.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/media/dvb_frontend.h +2 -2
index f05cd7b94a2c..472fe5871d94 100644
@@ -144,7 +144,7 @@ enum dvbfe_algo {
 	DVBFE_ALGO_HW			= (1 <<  0),
 	DVBFE_ALGO_SW			= (1 <<  1),
 	DVBFE_ALGO_CUSTOM		= (1 <<  2),
-	DVBFE_ALGO_RECOVERY		= (1 << 31)
+	DVBFE_ALGO_RECOVERY		= (1U << 31)
 };
 
 /**
@@ -175,7 +175,7 @@ enum dvbfe_search {
 	DVBFE_ALGO_SEARCH_FAILED	= (1 <<  2),
 	DVBFE_ALGO_SEARCH_INVALID	= (1 <<  3),
 	DVBFE_ALGO_SEARCH_AGAIN		= (1 <<  4),
-	DVBFE_ALGO_SEARCH_ERROR		= (1 << 31),
+	DVBFE_ALGO_SEARCH_ERROR		= (1U << 31),
 };
 
 /**
Signature · 1 line
2.20.1
#1 lore raw

Hi Luke,

Quoted 14 lines · Luke Nowakowski-Krijger

Fix DVBFE_ALGO_RECOVERY and DVBFE_ALGO_SEARCH_ERROR to use U cast which fixes undefined behavior error by certain compilers.

Signed-off-by Luke Nowakowski-Krijger <lnowakow at eng.ucsd.edu>
---
 include/media/dvb_frontend.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/media/dvb_frontend.h +0 -0
index f05cd7b94a2c..472fe5871d94 100644

include/media/dvb_frontend.h enum dvbfe_algo { · line 147

Quoted 5 lines
include/media/dvb_frontend.h +1 -1
@@ -144,7 +144,7 @@ enum dvbfe_algo {
        DVBFE_ALGO_HW                   = (1 <<  0),
        DVBFE_ALGO_SW                   = (1 <<  1),
        DVBFE_ALGO_CUSTOM               = (1 <<  2),
-       DVBFE_ALGO_RECOVERY             = (1 << 31)
+       DVBFE_ALGO_RECOVERY             = (1U << 31)

You could switch all these definitions to use the BIT() macro instead.

#2 lore raw
In reply to Luke Nowakowski-Krijger
Quoted 13 lines · Luke Nowakowski-Krijger

Fix DVBFE_ALGO_RECOVERY and DVBFE_ALGO_SEARCH_ERROR to use U cast which fixes undefined behavior error by certain compilers.

Signed-off-by Luke Nowakowski-Krijger <lnowakow at eng.ucsd.edu>
---
 include/media/dvb_frontend.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/media/dvb_frontend.h +0 -0
index f05cd7b94a2c..472fe5871d94 100644

include/media/dvb_frontend.h enum dvbfe_algo { · line 147

Quoted 5 lines
include/media/dvb_frontend.h +1 -1
@@ -144,7 +144,7 @@ enum dvbfe_algo {
 	DVBFE_ALGO_HW			= (1 <<  0),
 	DVBFE_ALGO_SW			= (1 <<  1),
 	DVBFE_ALGO_CUSTOM		= (1 <<  2),
-	DVBFE_ALGO_RECOVERY		= (1 << 31)
+	DVBFE_ALGO_RECOVERY		= (1U << 31)

BIT() is better for stuff like this.

thanks,

greg k-h