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>
#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;
ub->fd = -1;
if (shared) {
- ub->refcount = ~0;
+ ub->refcount = USES_EXTERNAL_BUFFER;
ub->data = data;
} else {
ub->refcount = 1;
{
switch (ub->refcount) {
case 1:
- case ~0:
+ case USES_EXTERNAL_BUFFER:
if (ub->fd >= 0)
close(ub->fd);