On 5/11/26 12:03, David Gibson wrote:
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
--- netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlink.c b/netlink.c index 6b74e882..9076462b 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; }
Reviewed-by: Laurent Vivier