Fixes for undefined behaviour on signed shift (#3453)
Fixes for undefined behaviour on signed shift Change literal 1 to unsigned to allow safe bitshift of 31. Caught by cppcheck. Make 0xFF unsigned to prevent a left shift into signed bit. Spotted by @orestisf1993
This commit is contained in:
@ -278,8 +278,8 @@ void got_data(struct ev_loop *loop, ev_io *watcher, int events) {
|
||||
buffer[size] = '\0';
|
||||
|
||||
/* And call the callback (indexed by the type) */
|
||||
if (type & (1 << 31)) {
|
||||
type ^= 1 << 31;
|
||||
if (type & (1UL << 31)) {
|
||||
type ^= 1UL << 31;
|
||||
event_handlers[type](buffer);
|
||||
} else {
|
||||
if (reply_handlers[type])
|
||||
|
Reference in New Issue
Block a user