]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: Make use of IN_SET (#5977)
authorSusant Sahani <ssahani@users.noreply.github.com>
Thu, 18 May 2017 10:56:36 +0000 (10:56 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 May 2017 10:56:36 +0000 (12:56 +0200)
src/libsystemd/sd-netlink/netlink-util.c
src/libsystemd/sd-netlink/netlink-util.h

index 73b9ac0258cacd955045b7743223dbb8681ab256..6b660b7dbf3621a234d8322f20dea1e2181ea9b9 100644 (file)
@@ -116,51 +116,6 @@ int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_mess
         return 0;
 }
 
-bool rtnl_message_type_is_neigh(uint16_t type) {
-        switch (type) {
-                case RTM_NEWNEIGH:
-                case RTM_GETNEIGH:
-                case RTM_DELNEIGH:
-                        return true;
-                default:
-                        return false;
-        }
-}
-
-bool rtnl_message_type_is_route(uint16_t type) {
-        switch (type) {
-                case RTM_NEWROUTE:
-                case RTM_GETROUTE:
-                case RTM_DELROUTE:
-                        return true;
-                default:
-                        return false;
-        }
-}
-
-bool rtnl_message_type_is_link(uint16_t type) {
-        switch (type) {
-                case RTM_NEWLINK:
-                case RTM_SETLINK:
-                case RTM_GETLINK:
-                case RTM_DELLINK:
-                        return true;
-                default:
-                        return false;
-        }
-}
-
-bool rtnl_message_type_is_addr(uint16_t type) {
-        switch (type) {
-                case RTM_NEWADDR:
-                case RTM_GETADDR:
-                case RTM_DELADDR:
-                        return true;
-                default:
-                        return false;
-        }
-}
-
 int rtnl_log_parse_error(int r) {
         return log_error_errno(r, "Failed to parse netlink message: %m");
 }
index 49bb226ef309360fd3342ca5dd644c031b8101e0..215af124063baa6fb67b88fa1cd146390f5f90ec 100644 (file)
@@ -27,10 +27,21 @@ int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_mess
 uint32_t rtnl_message_get_serial(sd_netlink_message *m);
 void rtnl_message_seal(sd_netlink_message *m);
 
-bool rtnl_message_type_is_link(uint16_t type);
-bool rtnl_message_type_is_addr(uint16_t type);
-bool rtnl_message_type_is_route(uint16_t type);
-bool rtnl_message_type_is_neigh(uint16_t type);
+static inline bool rtnl_message_type_is_neigh(uint16_t type) {
+        return IN_SET(type, RTM_NEWNEIGH, RTM_GETNEIGH, RTM_DELNEIGH);
+}
+
+static inline bool rtnl_message_type_is_route(uint16_t type) {
+        return IN_SET(type, RTM_NEWROUTE, RTM_GETROUTE, RTM_DELROUTE);
+}
+
+static inline bool rtnl_message_type_is_link(uint16_t type) {
+        return IN_SET(type, RTM_NEWLINK, RTM_SETLINK, RTM_GETLINK, RTM_DELLINK);
+}
+
+static inline bool rtnl_message_type_is_addr(uint16_t type) {
+        return IN_SET(type, RTM_NEWADDR, RTM_GETADDR, RTM_DELADDR);
+}
 
 static inline bool rtnl_message_type_is_addrlabel(uint16_t type) {
         return IN_SET(type, RTM_NEWADDRLABEL, RTM_DELADDRLABEL, RTM_GETADDRLABEL);