From: Eugene Syromyatnikov Date: Sat, 10 Mar 2018 05:18:30 +0000 (+0100) Subject: nlattr: check NLA_TYPE_MASK at compile time X-Git-Tag: v4.22~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=834318eb1550d929acf669c99cb85383bdc884ad;p=strace 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 --- 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|");