chiark / gitweb /
remove unused variables
[elogind.git] / src / libsystemd / sd-rtnl / test-rtnl.c
index 78f5cca665dc848a106fdee52734236aaea3b30c..46b5bb20c38d82ecf9366dfe27da69f75cdd1c3f 100644 (file)
@@ -20,6 +20,7 @@
 ***/
 
 #include <netinet/ether.h>
+#include <net/if.h>
 
 #include "util.h"
 #include "macro.h"
@@ -33,8 +34,9 @@
 static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
         _cleanup_rtnl_message_unref_ sd_rtnl_message *message;
         const char *mac = "98:fe:94:3f:c6:18", *name = "test";
+        char buffer[ETHER_ADDR_TO_STRING_MAX];
         unsigned int mtu = 1450, mtu_out;
-        char *name_out;
+        const char *name_out;
         struct ether_addr mac_out;
 
         /* we'd really like to test NEWLINK, but let's not mess with the running kernel */
@@ -50,7 +52,7 @@ static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
         assert_se(streq(name, name_out));
 
         assert_se(sd_rtnl_message_read_ether_addr(message, IFLA_ADDRESS, &mac_out) >= 0);
-        assert_se(streq(mac, ether_ntoa(&mac_out)));
+        assert_se(streq(mac, ether_addr_to_string(&mac_out, buffer)));
 
         assert_se(sd_rtnl_message_read_u32(message, IFLA_MTU, &mtu_out) >= 0);
         assert_se(mtu == mtu_out);
@@ -60,7 +62,7 @@ static void test_link_get(sd_rtnl *rtnl, int ifindex) {
         sd_rtnl_message *m;
         sd_rtnl_message *r;
         unsigned int mtu = 1500;
-        char *str_data;
+        const char *str_data;
         uint8_t u8_data;
         uint32_t u32_data;
         struct ether_addr eth_data;
@@ -107,7 +109,7 @@ static void test_address_get(sd_rtnl *rtnl, int ifindex) {
         sd_rtnl_message *r;
         struct in_addr in_data;
         struct ifa_cacheinfo cache;
-        char *label;
+        const char *label;
 
         assert_se(sd_rtnl_message_new_addr(rtnl, &m, RTM_GETADDR, ifindex, AF_INET) >= 0);
         assert_se(m);
@@ -131,7 +133,7 @@ static void test_route(void) {
         uint32_t index = 2, u32_data;
         int r;
 
-        r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET);
+        r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET, RTPROT_STATIC);
         if (r < 0) {
                 log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
                 return;
@@ -173,7 +175,8 @@ static void test_multiple(void) {
 }
 
 static int link_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
-        char *ifname = userdata, *data;
+        char *ifname = userdata;
+        const char *data;
 
         assert_se(rtnl);
         assert_se(m);
@@ -276,7 +279,7 @@ static void test_container(void) {
         _cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
         uint16_t u16_data;
         uint32_t u32_data;
-        char *string_data;
+        const char *string_data;
 
         assert_se(sd_rtnl_message_new_link(NULL, &m, RTM_NEWLINK, 0) >= 0);
 
@@ -332,8 +335,8 @@ static void test_get_addresses(sd_rtnl *rtnl) {
 
         for (m = reply; m; m = sd_rtnl_message_next(m)) {
                 uint16_t type;
-                unsigned char family, scope, flags;
-                int ifindex;
+                unsigned char scope, flags;
+                int family, ifindex;
 
                 assert_se(sd_rtnl_message_get_type(m, &type) >= 0);
                 assert_se(type == RTM_NEWADDR);
@@ -354,7 +357,7 @@ int main(void) {
         sd_rtnl *rtnl;
         sd_rtnl_message *m;
         sd_rtnl_message *r;
-        char *string_data;
+        const char *string_data;
         int if_loopback;
         uint16_t type;