]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add unreachable.spatch coccinelle recipe and run it in precheck CI phase
authorOndřej Surý <ondrej@sury.org>
Thu, 8 Nov 2018 15:38:46 +0000 (22:38 +0700)
committerOndřej Surý <ondrej@sury.org>
Fri, 21 Dec 2018 08:29:47 +0000 (09:29 +0100)
cocci/.gitignore [new file with mode: 0644]
cocci/unreachable.spatch [new file with mode: 0644]
lib/lwres/getipnode.c
lib/lwres/getnameinfo.c
lib/lwres/unreachable_p.h [new file with mode: 0644]
util/check-cocci [new file with mode: 0755]
util/copyrights

diff --git a/cocci/.gitignore b/cocci/.gitignore
new file mode 100644 (file)
index 0000000..faacba5
--- /dev/null
@@ -0,0 +1 @@
+/*.patch
diff --git a/cocci/unreachable.spatch b/cocci/unreachable.spatch
new file mode 100644 (file)
index 0000000..0cc368a
--- /dev/null
@@ -0,0 +1,6 @@
+@@
+@@
+
+    INSIST(0);
++   ISC_UNREACHABLE();
+    ... when != ISC_UNREACHABLE();
index f0c0ae655f905c6fbab5aa0dede6981d507be76f..1d7934f4b72f47b6f39e30b6d4b8794d2de5506e 100644 (file)
 #include <lwres/netdb.h>       /* XXX #include <netdb.h> */
 
 #include "assert_p.h"
+#include "unreachable_p.h"
 
 #ifndef INADDRSZ
 #define INADDRSZ 4
@@ -1023,6 +1024,7 @@ hostfromaddr(lwres_gnbaresponse_t *addr, int af, const void *src) {
                break;
        default:
                INSIST(0);
+               ISC_UNREACHABLE();
        }
 
        /*
@@ -1100,6 +1102,7 @@ hostfromname(lwres_gabnresponse_t *name, int af) {
                break;
        default:
                INSIST(0);
+               ISC_UNREACHABLE();
        }
 
        /*
index 9951f4cf7ece4a88dcae6b72f0192b883785db0e..8a02a2a72a7c4f349417ff246ace5a51cd3ff5dc 100644 (file)
 #include "print_p.h"
 
 #include "assert_p.h"
+#include "unreachable_p.h"
 
 #define SUCCESS 0
 
@@ -299,6 +300,7 @@ lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
                        break;
                default:
                        INSIST(0);
+                       ISC_UNREACHABLE();
                }
 
                n = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0);
diff --git a/lib/lwres/unreachable_p.h b/lib/lwres/unreachable_p.h
new file mode 100644 (file)
index 0000000..525fe6d
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#pragma once
+
+#ifdef HAVE_BUILTIN_UNREACHABLE
+#define ISC_UNREACHABLE() __builtin_unreachable();
+#else
+#define ISC_UNREACHABLE()
+#endif
diff --git a/util/check-cocci b/util/check-cocci
new file mode 100755 (executable)
index 0000000..61792bd
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+ret=0
+for spatch in cocci/*.spatch; do
+    patch="$(dirname "$spatch")/$(basename "$spatch" .spatch).patch"
+    spatch --sp-file="$spatch" --use-gitgrep --dir . --very-quiet > "$patch";
+    if [ "$(< "$patch" wc -l)" -gt "0" ]; then
+       cat "$patch"
+       ret=1
+    else
+       rm "$patch"
+    fi
+done
+
+exit $ret
index cd13cc1fc4b8f92cdc1e3e0af0c5405afc6b1af5..61ea7577f408151fdf688f38f2f9c7ef7ca56642 100644 (file)
 ./bin/win32/BINDInstall/resource.h             X       2001,2005,2009,2018
 ./bind.keys                                    X       2009,2010,2011,2017,2018
 ./bind.keys.h                                  X       2009,2010,2011,2012,2014,2017,2018
+./cocci/unreachable.spatch                     X       2018
 ./config.guess                                 X       1998,1999,2000,2001,2004,2009,2013,2018
 ./config.h.in                                  X       1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
 ./config.h.win32                               C       1999,2000,2001,2004,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018
 ./lib/lwres/unix/include/Makefile.in           MAKE    2001,2004,2007,2012,2016,2018
 ./lib/lwres/unix/include/lwres/Makefile.in     MAKE    2001,2004,2007,2012,2016,2018
 ./lib/lwres/unix/include/lwres/net.h           C       2000,2001,2002,2004,2005,2007,2016,2018
+./lib/lwres/unreachable_p.h                    C       2018
 ./lib/lwres/version.c                          C       2000,2001,2004,2005,2007,2016,2018
 ./lib/lwres/win32/DLLMain.c                    C       2001,2004,2007,2016,2018
 ./lib/lwres/win32/Makefile.in                  MAKE    2001,2004,2007,2012,2016,2018
 ./util/branchsync.sh                           SH      2013,2016,2018
 ./util/check-categories.sh                     SH      2015,2016,2017,2018
 ./util/check-changes                           PERL    2002,2004,2007,2012,2016,2018
+./util/check-cocci                             X       2018
 ./util/check-includes.pl                       PERL    2000,2001,2004,2007,2012,2016,2018
 ./util/check-instincludes.sh                   SH      2000,2001,2004,2007,2012,2016,2018
 ./util/check-pullups.pl                                PERL    2001,2002,2003,2004,2007,2012,2016,2018