netlink plugin: fix build warnings
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Wed, 23 May 2018 13:38:26 +0000 (15:38 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Wed, 23 May 2018 13:38:26 +0000 (15:38 +0200)
src/netlink.c:546:13: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
      if (r >= sizeof(type_instance)) {
          ~ ^  ~~~~~~~~~~~~~~~~~~~~~
src/netlink.c:585:13: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
      if (r >= sizeof(type_instance)) {
          ~ ^  ~~~~~~~~~~~~~~~~~~~~~

src/netlink.c

index 0bd598c..a1f52a4 100644 (file)
@@ -543,7 +543,7 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) {
 
       int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
                        tc_inst);
 
       int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
                        tc_inst);
-      if (r >= sizeof(type_instance)) {
+      if ((size_t)r >= sizeof(type_instance)) {
         ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d",
               sizeof(type_instance), r);
         return MNL_CB_ERROR;
         ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d",
               sizeof(type_instance), r);
         return MNL_CB_ERROR;
@@ -582,7 +582,7 @@ static int qos_filter_cb(const struct nlmsghdr *nlh, void *args) {
 
       int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
                        tc_inst);
 
       int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
                        tc_inst);
-      if (r >= sizeof(type_instance)) {
+      if ((size_t)r >= sizeof(type_instance)) {
         ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d",
               sizeof(type_instance), r);
         return MNL_CB_ERROR;
         ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d",
               sizeof(type_instance), r);
         return MNL_CB_ERROR;