summaryrefslogtreecommitdiffstats
path: root/lib/msg.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-07-28 09:23:22 (GMT)
committerThomas Haller <thaller@redhat.com>2023-07-28 10:28:24 (GMT)
commit2e0ae977e4d9172fda78dbf0b31b47bd59e7ae3e (patch)
tree7c7f42fbfe02564e6a8a1574516505d3250a9363 /lib/msg.c
parent57c451fa3f804514b0f97765c2dfdbb58e867df4 (diff)
downloadlibnl-2e0ae977e4d9172fda78dbf0b31b47bd59e7ae3e.zip
libnl-2e0ae977e4d9172fda78dbf0b31b47bd59e7ae3e.tar.gz
libnl-2e0ae977e4d9172fda78dbf0b31b47bd59e7ae3e.tar.bz2
all: use _NL_{MIN,MAX}() macros
Replace the use of the previous min()/min_t()/max()/max_t(). - min_t()/max_t() required a type, and would do plain assignment, which C would not complain about. It is thus a cumbersome and not very safe pattern. Avoid it. - min()/max() did better, it used typeof() to preserve the argument types and automatically detect it. However, it also required that both arguments had the same integer type, which is unnecessarily strict. _NL_MIN()/_NL_MAX() does better. It accepts arguments of any integer types, but has a static assertions that they match in signedness. So it's more flexible to use than min()/max() and still quite safe. Prefer the new macros.
Diffstat (limited to 'lib/msg.c')
-rw-r--r--lib/msg.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/msg.c b/lib/msg.c
index 17ca812..0e64722 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -148,7 +148,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 _NL_MAX(nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen), 0u);
}
/** @} */