]> granicus.if.org Git - strace/commitdiff
nlattr: check NLA_TYPE_MASK at compile time
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sat, 10 Mar 2018 05:18:30 +0000 (06:18 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 4 Apr 2018 20:32:42 +0000 (20:32 +0000)
* nlattr.c: Include "static_assert.h"
(print_nlattr): Check the expectations about NLA_TYPE_MASK.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
nlattr.c

index ac430f4fe18cfefb007982d7a3913674cca99fef..da968da1c347df5ae111f948d39f14be3564d46e 100644 (file)
--- a/nlattr.c
+++ b/nlattr.c
@@ -34,6 +34,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <linux/sock_diag.h>
+#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|");