Commit 70602f40 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed broken if statements: unsigned < 0?

parent e027861c
......@@ -1137,7 +1137,8 @@ static void mb_shift_write(
for (i = 0; i < (quant + sh) / 8; i++) {
if (i == 0) {
unsigned char mask = ~0 << sh;
unsigned char mask = ~0;
mask = mask << sh;
out[0] &= ~mask;
out[0] |= mask & (in[0] << sh);
......@@ -1147,7 +1148,8 @@ static void mb_shift_write(
}
}
if ((quant + sh) % 8 != 0) {
unsigned char mask = ~0 << ((quant + sh) % 8);
unsigned char mask = ~0;
mask = mask << ((quant + sh) % 8);
mask = ~mask;
out[i] &= ~mask;
......
......@@ -986,7 +986,8 @@ static void mb_shift_write(
for (i = 0; i < (quant + sh) / 8; i++) {
if (i == 0) {
unsigned char mask = ~0 << sh;
unsigned char mask = ~0;
mask = mask << sh;
out[0] &= ~mask;
out[0] |= mask & (in[0] << sh);
......@@ -996,7 +997,8 @@ static void mb_shift_write(
}
}
if ((quant + sh) % 8 != 0) {
unsigned char mask = ~0 << ((quant + sh) % 8);
unsigned char mask = ~0;
mask = mask << ((quant + sh) % 8);
mask = ~mask;
out[i] &= ~mask;
......
......@@ -273,9 +273,13 @@ static pwr_tStatus IoCardRead(
/* Buttons */
idx = js.number;
/*
// TODO:
// js.number is an unsigned 8-bit, which has a maximum value of 256.
// KEY_MAX - BTN_MISC = 511, so this is always false.
if (js.number < KEY_MAX - BTN_MISC)
idx = local->button_map[js.number];
else
else */
break;
*(pwr_tBoolean*)cp->chanlist[idx].vbp = (js.value != 0);
......
......@@ -4595,23 +4595,27 @@ int sev_dbhdf5::check_deadband(pwr_eType type, unsigned int size,
}
break;
case pwr_eType_UInt64:
if (ABS(*(pwr_tUInt64*)value - *(pwr_tUInt64*)oldvalue) < deadband) {
if (ABS(((pwr_tInt64)(*(pwr_tUInt64*)value - *(pwr_tUInt64*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt32:
case pwr_eType_Boolean:
if (ABS(*(pwr_tUInt32*)value - *(pwr_tUInt32*)oldvalue) < deadband) {
if (ABS(((pwr_tInt32)(*(pwr_tUInt32*)value - *(pwr_tUInt32*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt16:
if (ABS(*(pwr_tUInt16*)value - *(pwr_tUInt16*)oldvalue) < deadband) {
if (ABS(((pwr_tInt16)(*(pwr_tUInt16*)value - *(pwr_tUInt16*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt8:
if (ABS(*(pwr_tUInt8*)value - *(pwr_tUInt8*)oldvalue) < deadband) {
if (ABS(((pwr_tInt8)(*(pwr_tUInt8*)value - *(pwr_tUInt8*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
......
......@@ -1323,8 +1323,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt64)))
|| (ABS(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt64)(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -1337,8 +1337,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt32)))
|| (ABS(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt32)(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -1350,8 +1350,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt16)))
|| (ABS(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt16)(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -1363,8 +1363,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt8)))
|| (ABS(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt8)(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -1464,8 +1464,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt64)))
|| (ABS(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt64)(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -1477,8 +1477,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt32)))
|| (ABS(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt32)(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -1489,8 +1489,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt16)))
|| (ABS(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt16)(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -1501,8 +1501,8 @@ int sev_dbms::write_value(pwr_tStatus* sts, int item_idx, int attr_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt8)))
|| (ABS(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt8)(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -3893,23 +3893,27 @@ int sev_dbms::check_deadband(pwr_eType type, unsigned int size,
}
break;
case pwr_eType_UInt64:
if (ABS(*(pwr_tUInt64*)value - *(pwr_tUInt64*)oldvalue) < deadband) {
if (ABS(((pwr_tInt64)(*(pwr_tUInt64*)value - *(pwr_tUInt64*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt32:
case pwr_eType_Boolean:
if (ABS(*(pwr_tUInt32*)value - *(pwr_tUInt32*)oldvalue) < deadband) {
if (ABS(((pwr_tInt32)(*(pwr_tUInt32*)value - *(pwr_tUInt32*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt16:
if (ABS(*(pwr_tUInt16*)value - *(pwr_tUInt16*)oldvalue) < deadband) {
if (ABS(((pwr_tInt16)(*(pwr_tUInt16*)value - *(pwr_tUInt16*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt8:
if (ABS(*(pwr_tUInt8*)value - *(pwr_tUInt8*)oldvalue) < deadband) {
if (ABS(((pwr_tInt8)(*(pwr_tUInt8*)value - *(pwr_tUInt8*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
......
......@@ -703,8 +703,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt64)))
|| (ABS(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt64)(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -717,8 +717,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt32)))
|| (ABS(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt32)(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -730,8 +730,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt16)))
|| (ABS(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt16)(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -743,8 +743,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt8)))
|| (ABS(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt8)(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
update_time_only = 1;
} else {
......@@ -844,8 +844,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt64)))
|| (ABS(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt64)(*(pwr_tUInt64*)buf
- *(pwr_tUInt64*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -857,8 +857,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt32)))
|| (ABS(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt32)(*(pwr_tUInt32*)buf
- *(pwr_tUInt32*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -869,8 +869,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt16)))
|| (ABS(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt16)(*(pwr_tUInt16*)buf
- *(pwr_tUInt16*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -881,8 +881,8 @@ int sev_dbsqlite::store_value(pwr_tStatus* sts, void* thread, int item_idx,
if ((feqf(m_items[item_idx].deadband, 0.0f)
&& !memcmp(
buf, m_items[item_idx].old_value, sizeof(pwr_tUInt8)))
|| (ABS(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)
|| (ABS(((pwr_tInt8)(*(pwr_tUInt8*)buf
- *(pwr_tUInt8*)m_items[item_idx].old_value)))
< m_items[item_idx].deadband)) {
m_items[item_idx].deadband_active = 1;
set_jump = 1;
......@@ -2812,23 +2812,27 @@ int sev_dbsqlite::check_deadband(pwr_eType type, unsigned int size,
}
break;
case pwr_eType_UInt64:
if (ABS(*(pwr_tUInt64*)value - *(pwr_tUInt64*)oldvalue) < deadband) {
if (ABS(((pwr_tInt64)(*(pwr_tUInt64*)value - *(pwr_tUInt64*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt32:
case pwr_eType_Boolean:
if (ABS(*(pwr_tUInt32*)value - *(pwr_tUInt32*)oldvalue) < deadband) {
if (ABS(((pwr_tInt32)(*(pwr_tUInt32*)value - *(pwr_tUInt32*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt16:
if (ABS(*(pwr_tUInt16*)value - *(pwr_tUInt16*)oldvalue) < deadband) {
if (ABS(((pwr_tInt16)(*(pwr_tUInt16*)value - *(pwr_tUInt16*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
case pwr_eType_UInt8:
if (ABS(*(pwr_tUInt8*)value - *(pwr_tUInt8*)oldvalue) < deadband) {
if (ABS(((pwr_tInt8)(*(pwr_tUInt8*)value - *(pwr_tUInt8*)oldvalue)))
< deadband) {
deadband_active = 1;
}
break;
......
......@@ -48,7 +48,7 @@
*/
#define PWR_XDR_BYTES(xdrs, addr, len) \
{ \
if (((xdrs)->x_handy -= len) < 0) \
if (((int) ((xdrs)->x_handy -= len)) < 0) \
return (FALSE); \
\
if ((xdrs)->x_op == XDR_DECODE) \
......@@ -65,7 +65,7 @@
*/
#define PWR_XDR_STRING(xdrs, addr, len) \
{ \
if (((xdrs)->x_handy -= len) < 0) \
if (((int) ((xdrs)->x_handy -= len)) < 0) \
return (FALSE); \
\
if ((xdrs)->x_op == XDR_DECODE) \
......@@ -82,7 +82,7 @@
*/
#define PWR_XDR_INT(xdrs, objp, objtype) \
{ \
if (((xdrs)->x_handy -= sizeof(int)) < 0) \
if (((int) ((xdrs)->x_handy -= sizeof(int))) < 0) \
return (FALSE); \
\
if ((xdrs)->x_op == XDR_DECODE) \
......
......@@ -4991,7 +4991,7 @@ static int xnav_open_func(void* client_data, void* client_flag)
xao->pop();
} else {
xao = xnav->xattone_new(
&aref, title_str, bypass ? pwr_mPrv_RtWrite : xnav->priv, &sts);
&aref, title_str, bypass ? pwr_mPrv_RtWrite : ((pwr_mPrv) xnav->priv), &sts);
if (EVEN(sts))
xnav->message('E', "Unable to open attribute");
else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment