From 1e6b638b490918386292e79efc8f62311e4a9f2f Mon Sep 17 00:00:00 2001 From: David Gibson Date: Mon, 11 May 2026 20:03:15 +1000 Subject: netlink: erromsg should be const in nl_status() This pointer aliases part of the const nlmsghdr we're passed, so it should be const. While we're there, remove an unnecessary explicit cast (NLMSG_DATA() returns a void *, which implicitly casts to anything). This also removes a warning on cppcheck 2.20.0 and probably many other versions. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Signed-off-by: Stefano Brivio --- netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlink.c b/netlink.c index 6b74e88..9076462 100644 --- a/netlink.c +++ b/netlink.c @@ -170,7 +170,7 @@ static int nl_status(const struct nlmsghdr *nh, ssize_t n, uint32_t seq) return 0; } if (nh->nlmsg_type == NLMSG_ERROR) { - struct nlmsgerr *errmsg = (struct nlmsgerr *)NLMSG_DATA(nh); + const struct nlmsgerr *errmsg = NLMSG_DATA(nh); return errmsg->error; } -- cgit v1.2.3