summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-22 12:07:01 +0100
committerThomas Haller <thaller@redhat.com>2020-02-22 12:09:56 +0100
commit9848589fbf89b890946cbda4d0a95b38ad53d1f0 (patch)
tree36b8338894027b29797058901cf60bd7ce442a7d
parentfd0d292cafd91cf36add6a24ad8975304de32e71 (diff)
downloadNetworkManager-9848589fbf89b890946cbda4d0a95b38ad53d1f0.tar.gz
platform: avoid compiler warning in _NMP_OBJECT_TYPE_IS_OBJ_WITH_IFINDEX()
Surisingly, the compiler may detect the remaining obj_type in the default switch. Then, inlining nmp_class_from_type() it may detect that this is only possible to hit with an out or range access to _nmp_classes array. Rework the code to avoid that compiler warning. It's either way not supposed to happen. Also, drop the default switch case and explicitly list the enum values. Otherwise it is error prone to forget a switch case.
-rw-r--r--src/platform/nmp-object.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h
index 91a9dba139..44525ed05b 100644
--- a/src/platform/nmp-object.h
+++ b/src/platform/nmp-object.h
@@ -504,10 +504,16 @@ _NMP_OBJECT_TYPE_IS_OBJ_WITH_IFINDEX (NMPObjectType obj_type)
case NMP_OBJECT_TYPE_LNK_VXLAN:
case NMP_OBJECT_TYPE_LNK_WIREGUARD:
return TRUE;
- default:
- nm_assert (nmp_class_from_type (obj_type));
+
+ case NMP_OBJECT_TYPE_ROUTING_RULE:
return FALSE;
+
+ case NMP_OBJECT_TYPE_UNKNOWN:
+ case __NMP_OBJECT_TYPE_LAST:
+ break;
}
+ nm_assert_not_reached ();
+ return FALSE;
}
#define NMP_OBJECT_CAST_OBJECT(obj) \