logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: 9b268df2f79e112b98dce51fe9359dbce126711e
parent e6df1e7263e94204d4445eb684c3df13e9fc8a1a
Author: Michael Forney <mforney@mforney.org>
Date:   Fri,  4 Oct 2019 18:34:31 -0700

libnl: Update to 3.5.0

Diffstat:

Mpkg/libnl/defs.h6+++---
Mpkg/libnl/gen.lua6+++---
Dpkg/libnl/patch/0001-Remove-redundant-linux-in6.h-include.patch24------------------------
Apkg/libnl/patch/0001-Use-static-inline-functions-for-min-and-max.patch123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dpkg/libnl/patch/0002-Avoid-pointer-arithmetic-on-void.patch139-------------------------------------------------------------------------------
Apkg/libnl/patch/0002-Avoid-statement-expression-in-nl_container_of.patch28++++++++++++++++++++++++++++
Apkg/libnl/patch/0003-Avoid-initialization-of-flexible-array-member.patch39+++++++++++++++++++++++++++++++++++++++
Dpkg/libnl/patch/0003-Don-t-return-expression-in-function-returning-void.patch39---------------------------------------
Apkg/libnl/patch/0004-Avoid-statement-expression-in-ATTR_DIFF-macro.patch28++++++++++++++++++++++++++++
Dpkg/libnl/patch/0004-Don-t-omit-second-operand-to-operator.patch25-------------------------
Apkg/libnl/patch/0005-Remove-_nl_auto-helpers.patch238+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dpkg/libnl/patch/0005-Use-static-inline-functions-for-min-and-max.patch123-------------------------------------------------------------------------------
Dpkg/libnl/patch/0006-Avoid-statement-expression-in-nl_container_of.patch28----------------------------
Dpkg/libnl/patch/0007-Use-__typeof__-instead-of-typeof.patch37-------------------------------------
Dpkg/libnl/patch/0008-Avoid-initialization-of-flexible-array-member.patch39---------------------------------------
Dpkg/libnl/patch/0009-Avoid-statement-expression-in-ATTR_DIFF-macro.patch28----------------------------
Dpkg/libnl/patch/0010-Fallback-to-alloca-when-VLAs-aren-t-available.patch28----------------------------
Mpkg/libnl/ver2+-
18 files changed, 463 insertions(+), 517 deletions(-)

diff --git a/pkg/libnl/defs.h b/pkg/libnl/defs.h @@ -16,12 +16,12 @@ #define PACKAGE "libnl" #define PACKAGE_BUGREPORT "" #define PACKAGE_NAME "libnl" -#define PACKAGE_STRING "libnl 3.4.0" +#define PACKAGE_STRING "libnl 3.5.0" #define PACKAGE_TARNAME "libnl" #define PACKAGE_URL "http://www.infradead.org/~tgr/libnl/" -#define PACKAGE_VERSION "3.4.0" +#define PACKAGE_VERSION "3.5.0" #define STDC_HEADERS 1 -#define VERSION "3.4.0" +#define VERSION "3.5.0" /* #undef const */ #ifndef __cplusplus /* #undef inline */ diff --git a/pkg/libnl/gen.lua b/pkg/libnl/gen.lua @@ -9,10 +9,10 @@ cflags{ build('sed', '$outdir/include/netlink/version.h', '$srcdir/include/netlink/version.h.in', { expr={ - '-e s,@PACKAGE_STRING@,\'libnl 3.4.0\',', - '-e s,@PACKAGE_VERSION@,3.4.0,', + '-e s,@PACKAGE_STRING@,\'libnl 3.5.0\',', + '-e s,@PACKAGE_VERSION@,3.5.0,', '-e s,@MAJ_VERSION@,3,', - '-e s,@MIN_VERSION@,4,', + '-e s,@MIN_VERSION@,5,', '-e s,@MIC_VERSION@,0,', '-e s,@LT_CURRENT@,226,', '-e s,@LT_REVISION@,0,', diff --git a/pkg/libnl/patch/0001-Remove-redundant-linux-in6.h-include.patch b/pkg/libnl/patch/0001-Remove-redundant-linux-in6.h-include.patch @@ -1,24 +0,0 @@ -From c3556dfb4b2b6467e5d0b0468c2dac8b602ae733 Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 1 Jan 2017 16:42:21 -0800 -Subject: [PATCH] Remove redundant linux/in6.h include - ---- - include/linux-private/linux/ipv6.h | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/include/linux-private/linux/ipv6.h b/include/linux-private/linux/ipv6.h -index e05e684..f16349d 100644 ---- a/include/linux-private/linux/ipv6.h -+++ b/include/linux-private/linux/ipv6.h -@@ -2,7 +2,6 @@ - #define _IPV6_H - - #include <asm/byteorder.h> --#include <linux/in6.h> - - /* The latest drafts declared increase in minimal mtu up to 1280. */ - --- -2.11.0 - diff --git a/pkg/libnl/patch/0001-Use-static-inline-functions-for-min-and-max.patch b/pkg/libnl/patch/0001-Use-static-inline-functions-for-min-and-max.patch @@ -0,0 +1,123 @@ +From 5205a990e10f9bf1102c719198f82aba342cbca5 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 11 Aug 2019 05:05:09 +0000 +Subject: [PATCH] Use static inline functions for min and max + +These generic macros were only ever used with type `int`, and making +them inline functions avoids the use of non-standard statement +expressions. +--- + include/netlink-private/netlink.h | 27 +++++++++++---------------- + lib/attr.c | 2 +- + lib/msg.c | 2 +- + lib/route/cls/ematch_syntax.y | 2 +- + lib/route/link/inet.c | 2 +- + lib/route/link/inet6.c | 2 +- + 6 files changed, 16 insertions(+), 21 deletions(-) + +diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h +index 5f6e3f7..fca3133 100644 +--- a/include/netlink-private/netlink.h ++++ b/include/netlink-private/netlink.h +@@ -158,22 +158,17 @@ static inline int nl_cb_call(struct nl_cb *cb, enum nl_cb_type type, struct nl_m + #undef __deprecated + #define __deprecated __attribute__ ((deprecated)) + +-#define min(x,y) ({ \ +- __typeof__(x) _x = (x); \ +- __typeof__(y) _y = (y); \ +- (void) (&_x == &_y); \ +- _x < _y ? _x : _y; }) +- +-#define max(x,y) ({ \ +- __typeof__(x) _x = (x); \ +- __typeof__(y) _y = (y); \ +- (void) (&_x == &_y); \ +- _x > _y ? _x : _y; }) +- +-#define min_t(type,x,y) \ +- ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) +-#define max_t(type,x,y) \ +- ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) ++static inline int ++min(int x, int y) ++{ ++ return x < y ? x : y; ++} ++ ++static inline int ++max(int x, int y) ++{ ++ return x > y ? x : y; ++} + + extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *, + struct nlmsghdr *, struct nl_parser_param *); +diff --git a/lib/attr.c b/lib/attr.c +index a4f5852..025627e 100644 +--- a/lib/attr.c ++++ b/lib/attr.c +@@ -358,7 +358,7 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count) + if (!src) + return 0; + +- minlen = min_t(int, count, nla_len(src)); ++ minlen = min(count, nla_len(src)); + memcpy(dest, nla_data(src), minlen); + + return minlen; +diff --git a/lib/msg.c b/lib/msg.c +index c08b3a4..d854df3 100644 +--- a/lib/msg.c ++++ b/lib/msg.c +@@ -155,7 +155,7 @@ struct nlattr *nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen) + */ + int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen) + { +- return max_t(int, nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen), 0); ++ return max(nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen), 0); + } + + /** @} */ +diff --git a/lib/route/cls/ematch_syntax.y b/lib/route/cls/ematch_syntax.y +index 82d753d..88665cc 100644 +--- a/lib/route/cls/ematch_syntax.y ++++ b/lib/route/cls/ematch_syntax.y +@@ -411,7 +411,7 @@ pattern: + if (nl_addr_parse($1, AF_UNSPEC, &addr) == 0) { + $$.len = nl_addr_get_len(addr); + +- $$.index = min_t(int, $$.len, nl_addr_get_prefixlen(addr)/8); ++ $$.index = min($$.len, nl_addr_get_prefixlen(addr)/8); + + if (!($$.data = calloc(1, $$.len))) { + nl_addr_put(addr); +diff --git a/lib/route/link/inet.c b/lib/route/link/inet.c +index 6651bc3..e33a3fe 100644 +--- a/lib/route/link/inet.c ++++ b/lib/route/link/inet.c +@@ -110,7 +110,7 @@ static int inet_parse_af(struct rtnl_link *link, struct nlattr *attr, void *data + + if (tb[IFLA_INET_CONF]) { + int i; +- int len = min_t(int, IPV4_DEVCONF_MAX, nla_len(tb[IFLA_INET_CONF]) / 4); ++ int len = min(IPV4_DEVCONF_MAX, nla_len(tb[IFLA_INET_CONF]) / 4); + + for (i = 0; i < len; i++) + id->i_confset[i] = 1; +diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c +index f02792c..8a3de01 100644 +--- a/lib/route/link/inet6.c ++++ b/lib/route/link/inet6.c +@@ -199,7 +199,7 @@ static int inet6_parse_protinfo(struct rtnl_link *link, struct nlattr *attr, + map_stat_id = map_stat_id_from_IPSTATS_MIB_v1; + } + +- len = min_t(int, __IPSTATS_MIB_MAX, len); ++ len = min(__IPSTATS_MIB_MAX, len); + for (i = 1; i < len; i++) { + memcpy(&stat, &cnt[i * sizeof(stat)], sizeof(stat)); + rtnl_link_set_stat(link, map_stat_id[i], stat); +-- +2.23.0 + diff --git a/pkg/libnl/patch/0002-Avoid-pointer-arithmetic-on-void.patch b/pkg/libnl/patch/0002-Avoid-pointer-arithmetic-on-void.patch @@ -1,139 +0,0 @@ -From 02a03be66ad59503e43be9d7915ae18161007e6f Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 04:49:07 +0000 -Subject: [PATCH] Avoid pointer arithmetic on `void *` - -ISO C requires that the pointer operand to the binary + operator be to -a complete object type[0]. - -[0] http://port70.net/~nsz/c/c11/n1570.html#6.5.6p2 ---- - lib/attr.c | 8 ++++---- - lib/data.c | 2 +- - lib/genl/genl.c | 4 ++-- - lib/msg.c | 6 +++--- - lib/object.c | 2 +- - 5 files changed, 11 insertions(+), 11 deletions(-) - -diff --git a/lib/attr.c b/lib/attr.c -index 0dca3ec..7c0ac4d 100644 ---- a/lib/attr.c -+++ b/lib/attr.c -@@ -477,7 +477,7 @@ struct nlattr *nla_reserve(struct nl_msg *msg, int attrtype, int attrlen) - NL_DBG(2, "msg %p: attr <%p> %d: Reserved %d (%d) bytes at offset +%td " - "nlmsg_len=%d\n", msg, nla, nla->nla_type, - nla_total_size(attrlen), attrlen, -- (void *) nla - nlmsg_data(msg->nm_nlh), -+ (char *) nla - (char *) nlmsg_data(msg->nm_nlh), - msg->nm_nlh->nlmsg_len); - - return nla; -@@ -513,7 +513,7 @@ int nla_put(struct nl_msg *msg, int attrtype, int datalen, const void *data) - memcpy(nla_data(nla), data, datalen); - NL_DBG(2, "msg %p: attr <%p> %d: Wrote %d bytes at offset +%td\n", - msg, nla, nla->nla_type, datalen, -- (void *) nla - nlmsg_data(msg->nm_nlh)); -+ (char *) nla - (char *) nlmsg_data(msg->nm_nlh)); - } - - return 0; -@@ -925,7 +925,7 @@ int nla_nest_end(struct nl_msg *msg, struct nlattr *start) - { - size_t pad, len; - -- len = (void *) nlmsg_tail(msg->nm_nlh) - (void *) start; -+ len = (char *) nlmsg_tail(msg->nm_nlh) - (char *) start; - - if (len == NLA_HDRLEN || len > USHRT_MAX) { - /* -@@ -974,7 +974,7 @@ void nla_nest_cancel(struct nl_msg *msg, const struct nlattr *attr) - { - ssize_t len; - -- len = (void *) nlmsg_tail(msg->nm_nlh) - (void *) attr; -+ len = (char *) nlmsg_tail(msg->nm_nlh) - (char *) attr; - if (len < 0) - BUG(); - else if (len > 0) { -diff --git a/lib/data.c b/lib/data.c -index 83ecd03..0123170 100644 ---- a/lib/data.c -+++ b/lib/data.c -@@ -111,7 +111,7 @@ struct nl_data *nl_data_clone(const struct nl_data *src) - int nl_data_append(struct nl_data *data, const void *buf, size_t size) - { - if (size > 0) { -- void *d_data = realloc(data->d_data, data->d_size + size); -+ char *d_data = realloc(data->d_data, data->d_size + size); - if (!d_data) - return -NLE_NOMEM; - -diff --git a/lib/genl/genl.c b/lib/genl/genl.c -index a663ad8..30e8c8b 100644 ---- a/lib/genl/genl.c -+++ b/lib/genl/genl.c -@@ -259,7 +259,7 @@ void *genlmsg_user_hdr(const struct genlmsghdr *gnlh) - */ - void *genlmsg_user_data(const struct genlmsghdr *gnlh, const int hdrlen) - { -- return genlmsg_user_hdr(gnlh) + NLMSG_ALIGN(hdrlen); -+ return (char *) genlmsg_user_hdr(gnlh) + NLMSG_ALIGN(hdrlen); - } - - /** -@@ -363,7 +363,7 @@ void *genlmsg_put(struct nl_msg *msg, uint32_t port, uint32_t seq, int family, - NL_DBG(2, "msg %p: Added generic netlink header cmd=%d version=%d\n", - msg, cmd, version); - -- return nlmsg_data(nlh) + GENL_HDRLEN; -+ return (char *) nlmsg_data(nlh) + GENL_HDRLEN; - } - - /** @} */ -diff --git a/lib/msg.c b/lib/msg.c -index 3e27d4e..0ce5887 100644 ---- a/lib/msg.c -+++ b/lib/msg.c -@@ -407,7 +407,7 @@ struct nl_msg *nlmsg_convert(struct nlmsghdr *hdr) - */ - void *nlmsg_reserve(struct nl_msg *n, size_t len, int pad) - { -- void *buf = n->nm_nlh; -+ char *buf = (char *) n->nm_nlh; - size_t nlmsg_len = n->nm_nlh->nlmsg_len; - size_t tlen; - -@@ -835,7 +835,7 @@ static void print_genl_hdr(FILE *ofd, void *start) - static void *print_genl_msg(struct nl_msg *msg, FILE *ofd, struct nlmsghdr *hdr, - struct nl_cache_ops *ops, int *payloadlen) - { -- void *data = nlmsg_data(hdr); -+ char *data = nlmsg_data(hdr); - - if (*payloadlen < GENL_HDRLEN) - return data; -@@ -898,7 +898,7 @@ static void dump_attrs(FILE *ofd, struct nlattr *attrs, int attrlen, - prefix_line(ofd, prefix); - fprintf(ofd, " [PADDING] %d octets\n", - padlen); -- dump_hex(ofd, nla_data(nla) + alen, -+ dump_hex(ofd, (char *) nla_data(nla) + alen, - padlen, prefix); - } - } -diff --git a/lib/object.c b/lib/object.c -index 64e3b07..aeb4307 100644 ---- a/lib/object.c -+++ b/lib/object.c -@@ -131,7 +131,7 @@ struct nl_object *nl_object_clone(struct nl_object *obj) - new->ce_mask = obj->ce_mask; - - if (size) -- memcpy((void *)new + doff, (void *)obj + doff, size); -+ memcpy((char *)new + doff, (char *)obj + doff, size); - - if (ops->oo_clone) { - if (ops->oo_clone(new, obj) < 0) { --- -2.22.0 - diff --git a/pkg/libnl/patch/0002-Avoid-statement-expression-in-nl_container_of.patch b/pkg/libnl/patch/0002-Avoid-statement-expression-in-nl_container_of.patch @@ -0,0 +1,28 @@ +From e9b9e271c57d3d3129fa87c8866e91daeffe8144 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 11 Aug 2019 05:14:48 +0000 +Subject: [PATCH] Avoid statement expression in nl_container_of + +--- + include/netlink/list.h | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/include/netlink/list.h b/include/netlink/list.h +index 2f20634..f116126 100644 +--- a/include/netlink/list.h ++++ b/include/netlink/list.h +@@ -59,9 +59,8 @@ static inline int nl_list_empty(struct nl_list_head *head) + return head->next == head; + } + +-#define nl_container_of(ptr, type, member) ({ \ +- const __typeof__( ((type *)0)->member ) *__mptr = (ptr);\ +- (type *)( (char *)__mptr - (offsetof(type, member)));}) ++#define nl_container_of(ptr, type, member) ( \ ++ (type *)( (char *)(ptr) - (offsetof(type, member)))) + + #define nl_list_entry(ptr, type, member) \ + nl_container_of(ptr, type, member) +-- +2.23.0 + diff --git a/pkg/libnl/patch/0003-Avoid-initialization-of-flexible-array-member.patch b/pkg/libnl/patch/0003-Avoid-initialization-of-flexible-array-member.patch @@ -0,0 +1,39 @@ +From d1f59de10a2fbce42735b3a1938ecd4d60c8e205 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 11 Aug 2019 21:55:54 +0000 +Subject: [PATCH] Avoid initialization of flexible array member + +--- + include/netlink-private/cache-api.h | 2 +- + include/netlink-private/netlink.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/netlink-private/cache-api.h b/include/netlink-private/cache-api.h +index c684e79..82be310 100644 +--- a/include/netlink-private/cache-api.h ++++ b/include/netlink-private/cache-api.h +@@ -259,7 +259,7 @@ struct nl_cache_ops + struct genl_ops * co_genl; + + /* Message type definition */ +- struct nl_msgtype co_msgtypes[]; ++ struct nl_msgtype *co_msgtypes; + }; + + /** @} */ +diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h +index fca3133..1148cec 100644 +--- a/include/netlink-private/netlink.h ++++ b/include/netlink-private/netlink.h +@@ -200,7 +200,7 @@ static inline const char *nl_cache_name(struct nl_cache *cache) + } + + #define GENL_FAMILY(id, name) \ +- { \ ++ (struct nl_msgtype[]){ \ + { id, NL_ACT_UNSPEC, name }, \ + END_OF_MSGTYPES_LIST, \ + } +-- +2.23.0 + diff --git a/pkg/libnl/patch/0003-Don-t-return-expression-in-function-returning-void.patch b/pkg/libnl/patch/0003-Don-t-return-expression-in-function-returning-void.patch @@ -1,39 +0,0 @@ -From befefcc3c3fef5d7d15713ae9dfb82108c331d56 Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 04:50:32 +0000 -Subject: [PATCH] Don't return expression in function returning void - ---- - lib/cache.c | 2 +- - lib/object.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/lib/cache.c b/lib/cache.c -index 427f5df..badf91c 100644 ---- a/lib/cache.c -+++ b/lib/cache.c -@@ -421,7 +421,7 @@ void nl_cache_free(struct nl_cache *cache) - - void nl_cache_put(struct nl_cache *cache) - { -- return nl_cache_free(cache); -+ nl_cache_free(cache); - } - - /** @} */ -diff --git a/lib/object.c b/lib/object.c -index aeb4307..f0c73da 100644 ---- a/lib/object.c -+++ b/lib/object.c -@@ -300,7 +300,7 @@ void nl_object_dump_buf(struct nl_object *obj, char *buf, size_t len) - .dp_buflen = len, - }; - -- return nl_object_dump(obj, &dp); -+ nl_object_dump(obj, &dp); - } - - /** --- -2.22.0 - diff --git a/pkg/libnl/patch/0004-Avoid-statement-expression-in-ATTR_DIFF-macro.patch b/pkg/libnl/patch/0004-Avoid-statement-expression-in-ATTR_DIFF-macro.patch @@ -0,0 +1,28 @@ +From e56f5df0379c7dc70f6ce61a31167185daa51cae Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Sun, 11 Aug 2019 21:57:03 +0000 +Subject: [PATCH] Avoid statement expression in ATTR_DIFF macro + +--- + include/netlink-private/object-api.h | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/include/netlink-private/object-api.h b/include/netlink-private/object-api.h +index 517e672..269cd4b 100644 +--- a/include/netlink-private/object-api.h ++++ b/include/netlink-private/object-api.h +@@ -260,10 +260,7 @@ struct nl_object + * @endcode + */ + #define ATTR_DIFF(LIST, ATTR, A, B, EXPR) \ +-({ uint64_t diff = 0; \ +- if (((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR)) \ +- diff = ATTR; \ +- diff; }) ++ ((uint64_t)(((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR) ? (ATTR) : 0)) + + /** + * Object Operations +-- +2.23.0 + diff --git a/pkg/libnl/patch/0004-Don-t-omit-second-operand-to-operator.patch b/pkg/libnl/patch/0004-Don-t-omit-second-operand-to-operator.patch @@ -1,25 +0,0 @@ -From aea1d02c2700adec3a5c67cfa2d74bb812d95725 Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 04:57:33 +0000 -Subject: [PATCH] Don't omit second operand to `?` operator - ---- - lib/nl.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/nl.c b/lib/nl.c -index 1b4355b..9065389 100644 ---- a/lib/nl.c -+++ b/lib/nl.c -@@ -681,7 +681,7 @@ int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla, - if (page_size == 0) - page_size = getpagesize() * 4; - -- iov.iov_len = sk->s_bufsize ? : page_size; -+ iov.iov_len = sk->s_bufsize ? sk->s_bufsize : page_size; - iov.iov_base = malloc(iov.iov_len); - - if (!iov.iov_base) { --- -2.22.0 - diff --git a/pkg/libnl/patch/0005-Remove-_nl_auto-helpers.patch b/pkg/libnl/patch/0005-Remove-_nl_auto-helpers.patch @@ -0,0 +1,238 @@ +From 558f898c413bd46423c6b07073422fc6fc18769c Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Fri, 4 Oct 2019 18:13:36 -0700 +Subject: [PATCH] Remove _nl_auto helpers + +These use non-standard __attribute__((cleanup)) and statement +expressions. +--- + include/netlink-private/utils.h | 49 --------------------------------- + lib/genl/mngt.c | 10 +++++-- + lib/xfrm/sa.c | 24 ++++++++-------- + 3 files changed, 19 insertions(+), 64 deletions(-) + +diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h +index f33a2f8..1456797 100644 +--- a/include/netlink-private/utils.h ++++ b/include/netlink-private/utils.h +@@ -67,7 +67,6 @@ + /*****************************************************************************/ + + #define _nl_unused __attribute__ ((__unused__)) +-#define _nl_auto(fcn) __attribute__ ((__cleanup__(fcn))) + + /*****************************************************************************/ + +@@ -83,18 +82,6 @@ + + /*****************************************************************************/ + +-#define _NL_AUTO_DEFINE_FCN_VOID0(CastType, name, func) \ +-static inline void name (void *v) \ +-{ \ +- if (*((CastType *) v)) \ +- func (*((CastType *) v)); \ +-} +- +-#define _nl_auto_free _nl_auto(_nl_auto_free_fcn) +-_NL_AUTO_DEFINE_FCN_VOID0 (void *, _nl_auto_free_fcn, free) +- +-/*****************************************************************************/ +- + extern const char *nl_strerror_l(int err); + + /*****************************************************************************/ +@@ -106,42 +93,6 @@ extern const char *nl_strerror_l(int err); + + /*****************************************************************************/ + +-#define _nl_clear_pointer(pp, destroy) \ +- ({ \ +- __typeof__ (*(pp)) *_pp = (pp); \ +- __typeof__ (*_pp) _p; \ +- int _changed = 0; \ +- \ +- if ( _pp \ +- && (_p = *_pp)) { \ +- _nl_unused const void *const _p_check_is_pointer = _p; \ +- \ +- *_pp = NULL; \ +- \ +- (destroy) (_p); \ +- \ +- _changed = 1; \ +- } \ +- _changed; \ +- }) +- +-#define _nl_clear_free(pp) _nl_clear_pointer (pp, free) +- +-#define _nl_steal_pointer(pp) \ +- ({ \ +- __typeof__ (*(pp)) *const _pp = (pp); \ +- __typeof__ (*_pp) _p = NULL; \ +- \ +- if ( _pp \ +- && (_p = *_pp)) { \ +- *_pp = NULL; \ +- } \ +- \ +- _p; \ +- }) +- +-/*****************************************************************************/ +- + #define _nl_malloc_maybe_a(alloca_maxlen, bytes, to_free) \ + ({ \ + const size_t _bytes = (bytes); \ +diff --git a/lib/genl/mngt.c b/lib/genl/mngt.c +index 28326cd..ff50e1d 100644 +--- a/lib/genl/mngt.c ++++ b/lib/genl/mngt.c +@@ -50,7 +50,7 @@ static struct genl_cmd *lookup_cmd(struct genl_ops *ops, int cmd_id) + static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh, + struct genl_ops *ops, struct nl_cache_ops *cache_ops, void *arg) + { +- _nl_auto_free struct nlattr **tb_free = NULL; ++ struct nlattr **tb_free = NULL; + int err; + struct genlmsghdr *ghdr; + struct genl_cmd *cmd; +@@ -74,7 +74,7 @@ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh, + cmd->c_maxattr, + cmd->c_attr_policy); + if (err < 0) +- return err; ++ goto out; + + { + struct genl_info info = { +@@ -85,8 +85,12 @@ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh, + .attrs = tb, + }; + +- return cmd->c_msg_parser(cache_ops, cmd, &info, arg); ++ err = cmd->c_msg_parser(cache_ops, cmd, &info, arg); + } ++ ++out: ++ free(tb_free); ++ return err; + } + + static int genl_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, +diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c +index 48265ba..14bf298 100644 +--- a/lib/xfrm/sa.c ++++ b/lib/xfrm/sa.c +@@ -1683,7 +1683,7 @@ int xfrmnl_sa_get_aead_params (struct xfrmnl_sa* sa, char* alg_name, unsigned in + + int xfrmnl_sa_set_aead_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, unsigned int icv_len, const char* key) + { +- _nl_auto_free struct xfrmnl_algo_aead *b = NULL; ++ struct xfrmnl_algo_aead *b = NULL; + size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8); + uint32_t newlen = sizeof (struct xfrmnl_algo_aead) + keysize; + +@@ -1699,7 +1699,7 @@ int xfrmnl_sa_set_aead_params (struct xfrmnl_sa* sa, const char* alg_name, unsig + memcpy (b->alg_key, key, keysize); + + free (sa->aead); +- sa->aead = _nl_steal_pointer (&b); ++ sa->aead = b; + sa->ce_mask |= XFRM_SA_ATTR_ALG_AEAD; + return 0; + } +@@ -1741,7 +1741,7 @@ int xfrmnl_sa_get_auth_params (struct xfrmnl_sa* sa, char* alg_name, unsigned in + + int xfrmnl_sa_set_auth_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, unsigned int trunc_len, const char* key) + { +- _nl_auto_free struct xfrmnl_algo_auth *b = NULL; ++ struct xfrmnl_algo_auth *b = NULL; + size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8); + uint32_t newlen = sizeof (struct xfrmnl_algo_auth) + keysize; + +@@ -1756,7 +1756,7 @@ int xfrmnl_sa_set_auth_params (struct xfrmnl_sa* sa, const char* alg_name, unsig + memcpy (b->alg_key, key, keysize); + + free (sa->auth); +- sa->auth = _nl_steal_pointer (&b); ++ sa->auth = b; + sa->ce_mask |= XFRM_SA_ATTR_ALG_AUTH; + return 0; + } +@@ -1795,7 +1795,7 @@ int xfrmnl_sa_get_crypto_params (struct xfrmnl_sa* sa, char* alg_name, unsigned + + int xfrmnl_sa_set_crypto_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, const char* key) + { +- _nl_auto_free struct xfrmnl_algo *b = NULL; ++ struct xfrmnl_algo *b = NULL; + size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8); + uint32_t newlen = sizeof (struct xfrmnl_algo) + keysize; + +@@ -1809,7 +1809,7 @@ int xfrmnl_sa_set_crypto_params (struct xfrmnl_sa* sa, const char* alg_name, uns + memcpy (b->alg_key, key, keysize); + + free(sa->crypt); +- sa->crypt = _nl_steal_pointer(&b); ++ sa->crypt = b; + sa->ce_mask |= XFRM_SA_ATTR_ALG_CRYPT; + return 0; + } +@@ -1848,7 +1848,7 @@ int xfrmnl_sa_get_comp_params (struct xfrmnl_sa* sa, char* alg_name, unsigned in + + int xfrmnl_sa_set_comp_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, const char* key) + { +- _nl_auto_free struct xfrmnl_algo *b = NULL; ++ struct xfrmnl_algo *b = NULL; + size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8); + uint32_t newlen = sizeof (struct xfrmnl_algo) + keysize; + +@@ -1862,7 +1862,7 @@ int xfrmnl_sa_set_comp_params (struct xfrmnl_sa* sa, const char* alg_name, unsig + memcpy (b->alg_key, key, keysize); + + free(sa->comp); +- sa->comp = _nl_steal_pointer(&b); ++ sa->comp = b; + sa->ce_mask |= XFRM_SA_ATTR_ALG_COMP; + return 0; + } +@@ -2023,7 +2023,7 @@ int xfrmnl_sa_get_sec_ctx (struct xfrmnl_sa* sa, unsigned int* doi, unsigned int + int xfrmnl_sa_set_sec_ctx (struct xfrmnl_sa* sa, unsigned int doi, unsigned int alg, unsigned int len, + unsigned int sid, const char* ctx_str) + { +- _nl_auto_free struct xfrmnl_user_sec_ctx *b = NULL; ++ struct xfrmnl_user_sec_ctx *b = NULL; + + if (!(b = calloc(1, sizeof (struct xfrmnl_user_sec_ctx) + 1 + len))) + return -1; +@@ -2037,7 +2037,7 @@ int xfrmnl_sa_set_sec_ctx (struct xfrmnl_sa* sa, unsigned int doi, unsigned int + b->ctx[len] = '\0'; + + free(sa->sec_ctx); +- sa->sec_ctx = _nl_steal_pointer(&b); ++ sa->sec_ctx = b; + sa->ce_mask |= XFRM_SA_ATTR_SECCTX; + return 0; + } +@@ -2136,7 +2136,7 @@ int xfrmnl_sa_set_replay_state_esn (struct xfrmnl_sa* sa, unsigned int oseq, uns + unsigned int oseq_hi, unsigned int seq_hi, unsigned int replay_window, + unsigned int bmp_len, unsigned int* bmp) + { +- _nl_auto_free struct xfrmnl_replay_state_esn *b = NULL; ++ struct xfrmnl_replay_state_esn *b = NULL; + + if (!(b = calloc (1, sizeof (struct xfrmnl_replay_state_esn) + (sizeof (uint32_t) * bmp_len)))) + return -1; +@@ -2150,7 +2150,7 @@ int xfrmnl_sa_set_replay_state_esn (struct xfrmnl_sa* sa, unsigned int oseq, uns + memcpy (b->bmp, bmp, bmp_len * sizeof (uint32_t)); + + free(sa->replay_state_esn); +- sa->replay_state_esn = _nl_steal_pointer(&b); ++ sa->replay_state_esn = b; + sa->ce_mask |= XFRM_SA_ATTR_REPLAY_STATE; + return 0; + } +-- +2.23.0 + diff --git a/pkg/libnl/patch/0005-Use-static-inline-functions-for-min-and-max.patch b/pkg/libnl/patch/0005-Use-static-inline-functions-for-min-and-max.patch @@ -1,123 +0,0 @@ -From e9dc83c59917fc86d3bd684a6b1d31e1619bc07e Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 05:05:09 +0000 -Subject: [PATCH] Use static inline functions for min and max - -These generic macros were only ever used with type `int`, and making -them inline functions avoids the use of non-standard statement -expressions. ---- - include/netlink-private/netlink.h | 27 +++++++++++---------------- - lib/attr.c | 2 +- - lib/msg.c | 2 +- - lib/route/cls/ematch_syntax.y | 2 +- - lib/route/link/inet.c | 2 +- - lib/route/link/inet6.c | 2 +- - 6 files changed, 16 insertions(+), 21 deletions(-) - -diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h -index 728ca5c..d9a3597 100644 ---- a/include/netlink-private/netlink.h -+++ b/include/netlink-private/netlink.h -@@ -159,22 +159,17 @@ static inline int nl_cb_call(struct nl_cb *cb, enum nl_cb_type type, struct nl_m - #undef __deprecated - #define __deprecated __attribute__ ((deprecated)) - --#define min(x,y) ({ \ -- typeof(x) _x = (x); \ -- typeof(y) _y = (y); \ -- (void) (&_x == &_y); \ -- _x < _y ? _x : _y; }) -- --#define max(x,y) ({ \ -- typeof(x) _x = (x); \ -- typeof(y) _y = (y); \ -- (void) (&_x == &_y); \ -- _x > _y ? _x : _y; }) -- --#define min_t(type,x,y) \ -- ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) --#define max_t(type,x,y) \ -- ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) -+static inline int -+min(int x, int y) -+{ -+ return x < y ? x : y; -+} -+ -+static inline int -+max(int x, int y) -+{ -+ return x > y ? x : y; -+} - - extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *, - struct nlmsghdr *, struct nl_parser_param *); -diff --git a/lib/attr.c b/lib/attr.c -index 7c0ac4d..9382b7f 100644 ---- a/lib/attr.c -+++ b/lib/attr.c -@@ -357,7 +357,7 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count) - if (!src) - return 0; - -- minlen = min_t(int, count, nla_len(src)); -+ minlen = min(count, nla_len(src)); - memcpy(dest, nla_data(src), minlen); - - return minlen; -diff --git a/lib/msg.c b/lib/msg.c -index 0ce5887..226a1d2 100644 ---- a/lib/msg.c -+++ b/lib/msg.c -@@ -154,7 +154,7 @@ struct nlattr *nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen) - */ - int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen) - { -- return max_t(int, nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen), 0); -+ return max(nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen), 0); - } - - /** @} */ -diff --git a/lib/route/cls/ematch_syntax.y b/lib/route/cls/ematch_syntax.y -index a0ca4bb..d730511 100644 ---- a/lib/route/cls/ematch_syntax.y -+++ b/lib/route/cls/ematch_syntax.y -@@ -411,7 +411,7 @@ pattern: - if (nl_addr_parse($1, AF_UNSPEC, &addr) == 0) { - $$.len = nl_addr_get_len(addr); - -- $$.index = min_t(int, $$.len, nl_addr_get_prefixlen(addr)/8); -+ $$.index = min($$.len, nl_addr_get_prefixlen(addr)/8); - - if (!($$.data = calloc(1, $$.len))) { - nl_addr_put(addr); -diff --git a/lib/route/link/inet.c b/lib/route/link/inet.c -index 6651bc3..e33a3fe 100644 ---- a/lib/route/link/inet.c -+++ b/lib/route/link/inet.c -@@ -110,7 +110,7 @@ static int inet_parse_af(struct rtnl_link *link, struct nlattr *attr, void *data - - if (tb[IFLA_INET_CONF]) { - int i; -- int len = min_t(int, IPV4_DEVCONF_MAX, nla_len(tb[IFLA_INET_CONF]) / 4); -+ int len = min(IPV4_DEVCONF_MAX, nla_len(tb[IFLA_INET_CONF]) / 4); - - for (i = 0; i < len; i++) - id->i_confset[i] = 1; -diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c -index e638d06..8f403ce 100644 ---- a/lib/route/link/inet6.c -+++ b/lib/route/link/inet6.c -@@ -197,7 +197,7 @@ static int inet6_parse_protinfo(struct rtnl_link *link, struct nlattr *attr, - map_stat_id = map_stat_id_from_IPSTATS_MIB_v1; - } - -- len = min_t(int, __IPSTATS_MIB_MAX, len); -+ len = min(__IPSTATS_MIB_MAX, len); - for (i = 1; i < len; i++) { - memcpy(&stat, &cnt[i * sizeof(stat)], sizeof(stat)); - rtnl_link_set_stat(link, map_stat_id[i], stat); --- -2.22.0 - diff --git a/pkg/libnl/patch/0006-Avoid-statement-expression-in-nl_container_of.patch b/pkg/libnl/patch/0006-Avoid-statement-expression-in-nl_container_of.patch @@ -1,28 +0,0 @@ -From caff6ac158a66ecf0688ee00a58e30e67971125c Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 05:14:48 +0000 -Subject: [PATCH] Avoid statement expression in nl_container_of - ---- - include/netlink/list.h | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/include/netlink/list.h b/include/netlink/list.h -index fcfb826..a5ce74f 100644 ---- a/include/netlink/list.h -+++ b/include/netlink/list.h -@@ -59,9 +59,8 @@ static inline int nl_list_empty(struct nl_list_head *head) - return head->next == head; - } - --#define nl_container_of(ptr, type, member) ({ \ -- const typeof( ((type *)0)->member ) *__mptr = (ptr); \ -- (type *)( (char *)__mptr - (offsetof(type, member)));}) -+#define nl_container_of(ptr, type, member) ( \ -+ (type *)( (char *)(ptr) - (offsetof(type, member)))) - - #define nl_list_entry(ptr, type, member) \ - nl_container_of(ptr, type, member) --- -2.22.0 - diff --git a/pkg/libnl/patch/0007-Use-__typeof__-instead-of-typeof.patch b/pkg/libnl/patch/0007-Use-__typeof__-instead-of-typeof.patch @@ -1,37 +0,0 @@ -From 334b5121a678ef1ec200c5b83855b46f6d238756 Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 05:15:37 +0000 -Subject: [PATCH] Use __typeof__ instead of typeof - ---- - include/netlink/list.h | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/include/netlink/list.h b/include/netlink/list.h -index a5ce74f..f116126 100644 ---- a/include/netlink/list.h -+++ b/include/netlink/list.h -@@ -78,15 +78,15 @@ static inline int nl_list_empty(struct nl_list_head *head) - nl_list_entry((head)->next, type, member) - - #define nl_list_for_each_entry(pos, head, member) \ -- for (pos = nl_list_entry((head)->next, typeof(*pos), member); \ -+ for (pos = nl_list_entry((head)->next, __typeof__(*pos), member); \ - &(pos)->member != (head); \ -- (pos) = nl_list_entry((pos)->member.next, typeof(*(pos)), member)) -+ (pos) = nl_list_entry((pos)->member.next, __typeof__(*(pos)), member)) - - #define nl_list_for_each_entry_safe(pos, n, head, member) \ -- for (pos = nl_list_entry((head)->next, typeof(*pos), member), \ -- n = nl_list_entry(pos->member.next, typeof(*pos), member); \ -+ for (pos = nl_list_entry((head)->next, __typeof__(*pos), member), \ -+ n = nl_list_entry(pos->member.next, __typeof__(*pos), member); \ - &(pos)->member != (head); \ -- pos = n, n = nl_list_entry(n->member.next, typeof(*n), member)) -+ pos = n, n = nl_list_entry(n->member.next, __typeof__(*n), member)) - - #define nl_init_list_head(head) \ - do { (head)->next = (head); (head)->prev = (head); } while (0) --- -2.22.0 - diff --git a/pkg/libnl/patch/0008-Avoid-initialization-of-flexible-array-member.patch b/pkg/libnl/patch/0008-Avoid-initialization-of-flexible-array-member.patch @@ -1,39 +0,0 @@ -From 90733be9145ba1d977ec23f21eae45b062dc8bcf Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 21:55:54 +0000 -Subject: [PATCH] Avoid initialization of flexible array member - ---- - include/netlink-private/cache-api.h | 2 +- - include/netlink-private/netlink.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/include/netlink-private/cache-api.h b/include/netlink-private/cache-api.h -index c684e79..82be310 100644 ---- a/include/netlink-private/cache-api.h -+++ b/include/netlink-private/cache-api.h -@@ -259,7 +259,7 @@ struct nl_cache_ops - struct genl_ops * co_genl; - - /* Message type definition */ -- struct nl_msgtype co_msgtypes[]; -+ struct nl_msgtype *co_msgtypes; - }; - - /** @} */ -diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h -index d9a3597..531940f 100644 ---- a/include/netlink-private/netlink.h -+++ b/include/netlink-private/netlink.h -@@ -201,7 +201,7 @@ static inline const char *nl_cache_name(struct nl_cache *cache) - } - - #define GENL_FAMILY(id, name) \ -- { \ -+ (struct nl_msgtype[]){ \ - { id, NL_ACT_UNSPEC, name }, \ - END_OF_MSGTYPES_LIST, \ - } --- -2.22.0 - diff --git a/pkg/libnl/patch/0009-Avoid-statement-expression-in-ATTR_DIFF-macro.patch b/pkg/libnl/patch/0009-Avoid-statement-expression-in-ATTR_DIFF-macro.patch @@ -1,28 +0,0 @@ -From 84eb9f312cc183e98d97805eda9d5e5bef7542b6 Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Sun, 11 Aug 2019 21:57:03 +0000 -Subject: [PATCH] Avoid statement expression in ATTR_DIFF macro - ---- - include/netlink-private/object-api.h | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/include/netlink-private/object-api.h b/include/netlink-private/object-api.h -index 517e672..269cd4b 100644 ---- a/include/netlink-private/object-api.h -+++ b/include/netlink-private/object-api.h -@@ -260,10 +260,7 @@ struct nl_object - * @endcode - */ - #define ATTR_DIFF(LIST, ATTR, A, B, EXPR) \ --({ uint64_t diff = 0; \ -- if (((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR)) \ -- diff = ATTR; \ -- diff; }) -+ ((uint64_t)(((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR) ? (ATTR) : 0)) - - /** - * Object Operations --- -2.22.0 - diff --git a/pkg/libnl/patch/0010-Fallback-to-alloca-when-VLAs-aren-t-available.patch b/pkg/libnl/patch/0010-Fallback-to-alloca-when-VLAs-aren-t-available.patch @@ -1,28 +0,0 @@ -From 672da355b5beb5bc2729f968318f87eb7795572b Mon Sep 17 00:00:00 2001 -From: Michael Forney <mforney@mforney.org> -Date: Mon, 12 Aug 2019 02:22:15 +0000 -Subject: [PATCH] Fallback to alloca when VLAs aren't available - ---- - lib/genl/mngt.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/lib/genl/mngt.c b/lib/genl/mngt.c -index ebfe85e..dda661f 100644 ---- a/lib/genl/mngt.c -+++ b/lib/genl/mngt.c -@@ -61,7 +61,11 @@ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh, - if (cmd->c_msg_parser == NULL) - err = -NLE_OPNOTSUPP; - else { -+#ifndef __STDC_NO_VLA__ - struct nlattr *tb[cmd->c_maxattr + 1]; -+#else -+ struct nlattr **tb = alloca((cmd->c_maxattr + 1) * sizeof(tb[0])); -+#endif - struct genl_info info = { - .who = who, - .nlh = nlh, --- -2.22.0 - diff --git a/pkg/libnl/ver b/pkg/libnl/ver @@ -1 +1 @@ -3.4.0 r1 +3.5.0 r0