summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2019-12-11 10:04:36 +0100
committerPetr Štetiar <ynezz@true.cz>2019-12-16 23:39:16 +0100
commitd61282db56404bae71515d207b878a445854624a (patch)
tree53fa0df798058996ef66cc5968f28e73c94c5529
parent90fb16234c2258e31bc5a0e67a8cff3f30395951 (diff)
downloadubus-d61282db56404bae71515d207b878a445854624a.tar.gz
ubusd: fix comparison of integers of different signs
Fixes following clang-9 compiler warning: ubusd.c:36:19: error: comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'int' [-Werror,-Wsign-compare] if (ub->refcount == ~0) { ~~~~~~~~~~~~ ^ ~~ Signed-off-by: Petr Štetiar <ynezz@true.cz>
-rw-r--r--ubusd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ubusd.c b/ubusd.c
index 0f35d3e..7738f50 100644
--- a/ubusd.c
+++ b/ubusd.c
@@ -30,10 +30,12 @@
#include "ubusd.h"
+#define USES_EXTERNAL_BUFFER ~0U
+
static struct ubus_msg_buf *ubus_msg_ref(struct ubus_msg_buf *ub)
{
struct ubus_msg_buf *new_ub;
- if (ub->refcount == ~0) {
+ if (ub->refcount == USES_EXTERNAL_BUFFER) {
new_ub = ubus_msg_new(ub->data, ub->len, false);
if (!new_ub)
return NULL;
@@ -61,7 +63,7 @@ struct ubus_msg_buf *ubus_msg_new(void *data, int len, bool shared)
ub->fd = -1;
if (shared) {
- ub->refcount = ~0;
+ ub->refcount = USES_EXTERNAL_BUFFER;
ub->data = data;
} else {
ub->refcount = 1;
@@ -78,7 +80,7 @@ void ubus_msg_free(struct ubus_msg_buf *ub)
{
switch (ub->refcount) {
case 1:
- case ~0:
+ case USES_EXTERNAL_BUFFER:
if (ub->fd >= 0)
close(ub->fd);