- uint16_t type;
- void *data;
-
- assert(sd_rtnl_message_new_link(RTM_NEWLINK, 0, &m) >= 0);
-
- assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0);
- assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) == -ENOTSUP);
- assert(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "kind") >= 0);
- assert(sd_rtnl_message_open_container(m, IFLA_INFO_DATA) >= 0);
- assert(sd_rtnl_message_open_container(m, IFLA_INFO_DATA) == -ENOTSUP);
- assert(sd_rtnl_message_append_u16(m, IFLA_VLAN_ID, 100) >= 0);
- assert(sd_rtnl_message_close_container(m) >= 0);
- assert(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "kind") >= 0);
- assert(sd_rtnl_message_close_container(m) >= 0);
- assert(sd_rtnl_message_close_container(m) == -EINVAL);
-
- assert(rtnl_message_seal(NULL, m) >= 0);
-
- assert(sd_rtnl_message_read(m, &type, &data) >= 0);
- assert(type == IFLA_LINKINFO);
- assert(data == NULL);
- assert(sd_rtnl_message_read(m, &type, &data) >= 0);
- assert(type == IFLA_INFO_KIND);
- assert(streq("kind", (char *)data));
- assert(sd_rtnl_message_read(m, &type, &data) >= 0);
- assert(type == IFLA_INFO_DATA);
- assert(data == NULL);
- assert(sd_rtnl_message_read(m, &type, &data) >= 0);
- assert(type == IFLA_VLAN_ID);
- assert(*(uint16_t *)data == 100);
- assert(sd_rtnl_message_read(m, &type, &data) == 0);
- assert(sd_rtnl_message_exit_container(m) >= 0);
- assert(sd_rtnl_message_read(m, &type, &data) >= 0);
- assert(type == IFLA_INFO_KIND);
- assert(streq("kind", (char *)data));
- assert(sd_rtnl_message_read(m, &type, &data) == 0);
- assert(sd_rtnl_message_exit_container(m) >= 0);
- assert(sd_rtnl_message_exit_container(m) == -EINVAL);
+ uint16_t u16_data;
+ uint32_t u32_data;
+ const char *string_data;
+
+ assert_se(sd_rtnl_message_new_link(NULL, &m, RTM_NEWLINK, 0) >= 0);
+
+ assert_se(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0);
+ assert_se(sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "vlan") >= 0);
+ assert_se(sd_rtnl_message_append_u16(m, IFLA_VLAN_ID, 100) >= 0);
+ assert_se(sd_rtnl_message_close_container(m) >= 0);
+ assert_se(sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "vlan") >= 0);
+ assert_se(sd_rtnl_message_close_container(m) >= 0);
+ assert_se(sd_rtnl_message_close_container(m) == -EINVAL);
+
+ assert_se(sd_rtnl_message_rewind(m) >= 0);
+
+ assert_se(sd_rtnl_message_enter_container(m, IFLA_LINKINFO) >= 0);
+ assert_se(sd_rtnl_message_read_string(m, IFLA_INFO_KIND, &string_data) >= 0);
+ assert_se(streq("vlan", string_data));
+
+ assert_se(sd_rtnl_message_enter_container(m, IFLA_INFO_DATA) >= 0);
+ assert_se(sd_rtnl_message_read_u16(m, IFLA_VLAN_ID, &u16_data) >= 0);
+ assert_se(sd_rtnl_message_exit_container(m) >= 0);
+
+ assert_se(sd_rtnl_message_read_string(m, IFLA_INFO_KIND, &string_data) >= 0);
+ assert_se(streq("vlan", string_data));
+ assert_se(sd_rtnl_message_exit_container(m) >= 0);
+
+ assert_se(sd_rtnl_message_read_u32(m, IFLA_LINKINFO, &u32_data) < 0);
+
+ assert_se(sd_rtnl_message_exit_container(m) == -EINVAL);