From 834318eb1550d929acf669c99cb85383bdc884ad Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Sat, 10 Mar 2018 06:18:30 +0100 Subject: [PATCH] nlattr: check NLA_TYPE_MASK at compile time * nlattr.c: Include "static_assert.h" (print_nlattr): Check the expectations about NLA_TYPE_MASK. Co-Authored-by: Dmitry V. Levin --- nlattr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nlattr.c b/nlattr.c index ac430f4f..da968da1 100644 --- a/nlattr.c +++ b/nlattr.c @@ -34,6 +34,7 @@ #include #include #include +#include "static_assert.h" static bool fetch_nlattr(struct tcb *const tcp, struct nlattr *const nlattr, @@ -55,6 +56,9 @@ print_nlattr(const struct nlattr *const nla, const struct xlat *const table, const char *const dflt) { + static_assert(NLA_TYPE_MASK == ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER), + "wrong NLA_TYPE_MASK"); + tprintf("{nla_len=%u, nla_type=", nla->nla_len); if (nla->nla_type & NLA_F_NESTED) tprints("NLA_F_NESTED|"); -- 2.40.0