summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-09 11:46:44 (GMT)
committerThomas Haller <thaller@redhat.com>2017-10-09 11:51:29 (GMT)
commitb4802a17a7655bfeee3e9c06e649d30b96dbad3b (patch)
tree8a70c993fc2d929f51b2ab64119900ecbd0e8737 /lib
parent3fe3454b0228a6c9729ce9ffebf62bda85fd87ab (diff)
downloadlibnl-b4802a17a7655bfeee3e9c06e649d30b96dbad3b.zip
libnl-b4802a17a7655bfeee3e9c06e649d30b96dbad3b.tar.gz
libnl-b4802a17a7655bfeee3e9c06e649d30b96dbad3b.tar.bz2
nl: add "const" specifier for nla_policy argument of parse functions
Adding const to a function argument is generally not an API break (at least, if the argument is a struct, like in this case). Usually we declare the policy as static variables. The user should be able to mark them as "const", so that the linker makes the policy array read-only. Adjust the API to allow for that. Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/attr.c4
-rw-r--r--lib/genl/genl.c4
-rw-r--r--lib/msg.c4
-rw-r--r--lib/route/tc.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/lib/attr.c b/lib/attr.c
index 0dca3ec..b81e550 100644
--- a/lib/attr.c
+++ b/lib/attr.c
@@ -240,7 +240,7 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
* @return 0 on success or a negative error code.
*/
int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
- struct nla_policy *policy)
+ const struct nla_policy *policy)
{
struct nlattr *nla;
int rem, err;
@@ -997,7 +997,7 @@ void nla_nest_cancel(struct nl_msg *msg, const struct nlattr *attr)
* @return 0 on success or a negative error code.
*/
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla,
- struct nla_policy *policy)
+ const struct nla_policy *policy)
{
return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy);
}
diff --git a/lib/genl/genl.c b/lib/genl/genl.c
index a663ad8..c79fd24 100644
--- a/lib/genl/genl.c
+++ b/lib/genl/genl.c
@@ -150,7 +150,7 @@ int genlmsg_valid_hdr(struct nlmsghdr *nlh, int hdrlen)
* @return 0 on success or a negative error code.
*/
int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
- struct nla_policy *policy)
+ const struct nla_policy *policy)
{
struct genlmsghdr *ghdr;
@@ -190,7 +190,7 @@ int genlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
* @return 0 on success or a negative error code.
*/
int genlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
- int maxtype, struct nla_policy *policy)
+ int maxtype, const struct nla_policy *policy)
{
struct genlmsghdr *ghdr;
diff --git a/lib/msg.c b/lib/msg.c
index 3e27d4e..0a52340 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -212,7 +212,7 @@ struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining)
* See nla_parse()
*/
int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[],
- int maxtype, struct nla_policy *policy)
+ int maxtype, const struct nla_policy *policy)
{
if (!nlmsg_valid_hdr(nlh, hdrlen))
return -NLE_MSG_TOOSHORT;
@@ -243,7 +243,7 @@ struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, int hdrlen, int attrtype)
* @arg policy validation policy
*/
int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype,
- struct nla_policy *policy)
+ const struct nla_policy *policy)
{
if (!nlmsg_valid_hdr(nlh, hdrlen))
return -NLE_MSG_TOOSHORT;
diff --git a/lib/route/tc.c b/lib/route/tc.c
index f5b23f0..5dc43e1 100644
--- a/lib/route/tc.c
+++ b/lib/route/tc.c
@@ -37,7 +37,7 @@ static struct nla_policy tc_policy[TCA_MAX+1] = {
};
int tca_parse(struct nlattr **tb, int maxattr, struct rtnl_tc *g,
- struct nla_policy *policy)
+ const struct nla_policy *policy)
{
if (g->ce_mask & TCA_ATTR_OPTS)