summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-18 02:35:16 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-18 12:38:32 +0200
commitca4e095ab9e970cb8fa472ae69ea1f0648041722 (patch)
treef52866c74ae50f3b996f164efaaa690513c96034 /src
parent0204152684188302e6c6232e50f30997fecb4ae3 (diff)
sd-rtnl: make string returned by sd_rtnl_message_read_string() const
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c6
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c13
-rw-r--r--src/network/networkd-link.c4
-rw-r--r--src/network/networkd-manager.c2
-rw-r--r--src/network/networkd-netdev.c4
-rw-r--r--src/systemd/sd-rtnl.h2
6 files changed, 16 insertions, 15 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 4d1b6fb198..c0a38e148b 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -786,7 +786,7 @@ int rtnl_message_read_internal(sd_rtnl_message *m, unsigned short type, void **d
return RTA_PAYLOAD(rta);
}
-int sd_rtnl_message_read_string(sd_rtnl_message *m, unsigned short type, char **data) {
+int sd_rtnl_message_read_string(sd_rtnl_message *m, unsigned short type, const char **data) {
int r;
void *attr_data;
@@ -800,7 +800,7 @@ int sd_rtnl_message_read_string(sd_rtnl_message *m, unsigned short type, char **
else if (strnlen(attr_data, r) >= (size_t) r)
return -EIO;
- *data = (char *) attr_data;
+ *data = (const char *) attr_data;
return 0;
}
@@ -962,7 +962,7 @@ int sd_rtnl_message_enter_container(sd_rtnl_message *m, unsigned short type) {
return r;
} else if (nl_type->type == NLA_UNION) {
const NLTypeSystemUnion *type_system_union;
- char *key;
+ const char *key;
r = type_system_get_type_system_union(m->container_type_system[m->n_containers],
&type_system_union,
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index e6ba08e076..cd81acae77 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -35,7 +35,7 @@ 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";
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 */
@@ -61,7 +61,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;
@@ -108,7 +108,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);
@@ -174,7 +174,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);
@@ -277,7 +278,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);
@@ -355,7 +356,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;
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 328c4d8003..7a0f30bdf5 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -42,7 +42,7 @@ static bool ipv4ll_is_bound(sd_ipv4ll *ll);
static int link_new(Manager *manager, sd_rtnl_message *message, Link **ret) {
_cleanup_link_unref_ Link *link = NULL;
uint16_t type;
- char *ifname;
+ const char *ifname;
int r, ifindex;
assert(manager);
@@ -2337,7 +2337,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
int link_update(Link *link, sd_rtnl_message *m) {
struct ether_addr mac;
- char *ifname;
+ const char *ifname;
int r;
assert(link);
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 4d105248f0..e363fb0c1b 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -227,7 +227,7 @@ static int manager_rtnl_process_link(sd_rtnl *rtnl, sd_rtnl_message *message, vo
Link *link = NULL;
NetDev *netdev = NULL;
uint16_t type;
- char *name;
+ const char *name;
int r, ifindex;
assert(rtnl);
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 8e53439d32..86f2250c8f 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -341,8 +341,8 @@ int netdev_join(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callback)
int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
uint16_t type;
const char *kind;
- char *received_kind;
- char *received_name;
+ const char *received_kind;
+ const char *received_name;
int r, ifindex;
assert(netdev);
diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h
index b5aa634d05..497705d855 100644
--- a/src/systemd/sd-rtnl.h
+++ b/src/systemd/sd-rtnl.h
@@ -112,7 +112,7 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type);
int sd_rtnl_message_open_container_union(sd_rtnl_message *m, unsigned short type, const char *key);
int sd_rtnl_message_close_container(sd_rtnl_message *m);
-int sd_rtnl_message_read_string(sd_rtnl_message *m, unsigned short type, char **data);
+int sd_rtnl_message_read_string(sd_rtnl_message *m, unsigned short type, const char **data);
int sd_rtnl_message_read_u8(sd_rtnl_message *m, unsigned short type, uint8_t *data);
int sd_rtnl_message_read_u16(sd_rtnl_message *m, unsigned short type, uint16_t *data);
int sd_rtnl_message_read_u32(sd_rtnl_message *m, unsigned short type, uint32_t *data);