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:
Alan Barr
2018-10-13 19:04:40 +01:00
committed by Orestis
parent dfe89cc4f1
commit 7c0994dafc
3 changed files with 4 additions and 4 deletions

View File

@ -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])