[PATCH] lib: add const-ness to appropriate parameters in addr, attr, data

Rohan Joyce rojoyce.github at gmail.com
Fri Feb 13 11:39:38 PST 2015


Hi Dan,

> Though I think it'll break source compatibility at least?  eg something
> built against libnl before this patch will no longer build after this
> patch, potentially.  Just something to think about.

I don't think it should. It changes the following types for some parameters
(and a few function-local vars):

struct nlattr *     -> const struct nlattr *
struct nl_addr *    -> const struct nl_addr *
struct nla_policy * -> const struct nla_policy *
struct nl_data *    -> const struct nl_data *
struct nl_msg *     -> const struct nl_msg *
void *              -> const void *
char *              -> const char *

As far as I know, anything that previously called:

uint8_t nla_get_u8(struct nlattr *);

should be fine (with respect to both syntax and abi) calling:

uint8_t nla_get_u8(const struct nlattr *);

With the latter it'll accept arguments of either type 'struct nlattr *' or
'const struct nlattr *'. The current API won't accept const-qualified pointers
for some operations that seem like they should be fine with them.

Thanks for your time,
Rohan



More information about the libnl mailing list