Module: kamailio
Branch: 5.5
Commit: c4821bdaa44198dce153c1764b298c8c00652463
URL:
https://github.com/kamailio/kamailio/commit/c4821bdaa44198dce153c1764b298c8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-11-05T08:43:09+01:00
core: unsigned literal for 1 used in left shifting for script callbacks
- GH #2897
(cherry picked from commit 6348de19626f691036fd94134be6f64fff4418ed)
---
Modified: src/core/script_cb.c
Modified: src/core/script_cb.h
---
Diff:
https://github.com/kamailio/kamailio/commit/c4821bdaa44198dce153c1764b298c8…
Patch:
https://github.com/kamailio/kamailio/commit/c4821bdaa44198dce153c1764b298c8…
---
diff --git a/src/core/script_cb.c b/src/core/script_cb.c
index 2f83608e66..266037674a 100644
--- a/src/core/script_cb.c
+++ b/src/core/script_cb.c
@@ -78,11 +78,11 @@ int register_script_cb( cb_function f, unsigned int flags, void *param
)
int i;
/* type checkings */
- if ( (flags&((1<<SCRIPT_CB_NUM)-1))==0 ) {
+ if ( (flags&((1u<<SCRIPT_CB_NUM)-1))==0 ) {
LM_BUG("callback flag not specified\n");
return -1;
}
- if ( (flags&(~(PRE_SCRIPT_CB|POST_SCRIPT_CB))) >= 1<<SCRIPT_CB_NUM ) {
+ if ( (flags&(~(PRE_SCRIPT_CB|POST_SCRIPT_CB))) >= 1u<<SCRIPT_CB_NUM ) {
LM_BUG("unsupported callback flags: %u\n",
flags);
return -1;
@@ -102,7 +102,7 @@ int register_script_cb( cb_function f, unsigned int flags, void *param
)
* (as many times as many flags are set)
*/
for (i=0; i<SCRIPT_CB_NUM; i++) {
- if ((flags&(1<<i)) == 0)
+ if ((flags&(1u<<i)) == 0)
continue;
if (add_callback(&cb_array[i], f, param) < 0)
goto add_error;
@@ -155,7 +155,7 @@ int exec_pre_script_cb( struct sip_msg *msg, enum script_cb_type
type)
return 0;
}
- flags = PRE_SCRIPT_CB | (1<<(type-1));
+ flags = PRE_SCRIPT_CB | (1u<<(type-1));
for (cb=pre_script_cb[type-1]; cb ; cb=cb->next ) {
/* stop on error */
if (cb->cbf(msg, flags, cb->param)==0)
@@ -177,7 +177,7 @@ int exec_post_script_cb( struct sip_msg *msg, enum script_cb_type
type)
return 1;
}
- flags = POST_SCRIPT_CB | (1<<(type-1));
+ flags = POST_SCRIPT_CB | (1u<<(type-1));
for (cb=post_script_cb[type-1]; cb ; cb=cb->next){
cb->cbf(msg, flags, cb->param);
}
diff --git a/src/core/script_cb.h b/src/core/script_cb.h
index ece69b8e41..650bf053fa 100644
--- a/src/core/script_cb.h
+++ b/src/core/script_cb.h
@@ -33,8 +33,8 @@
typedef int (cb_function)(struct sip_msg *msg, unsigned int flags, void *param);
-#define PRE_SCRIPT_CB (1<<30)
-#define POST_SCRIPT_CB (1<<31)
+#define PRE_SCRIPT_CB (1u<<30)
+#define POST_SCRIPT_CB (1u<<31)
/* Pre- and post-script callback flags. Use these flags to register
* for the callbacks, and to check the type of the callback from the