[Git][NTPsec/ntpsec][master] 6 commits: assert: remove ALWAYS_REQUIRE(), ALWAYS_INVARIANT().

Gary E. Miller gitlab at mg.gitlab.com
Fri Jun 2 04:51:48 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
26fa13c4 by Gary E. Miller at 2017-06-01T21:31:26-07:00
assert: remove ALWAYS_REQUIRE(), ALWAYS_INVARIANT().

Just a shim between two different layers of macros.

- - - - -
98437b5c by Gary E. Miller at 2017-06-01T21:36:47-07:00
assert: remove unused ISC_CHECK_ALL and ISC_CHECK_NONE.

And remove the code they guarded, since they were never set.

- - - - -
c28c2237 by Gary E. Miller at 2017-06-01T21:39:04-07:00
asert: remove the 4 never defined ISC_CHECK_*

Leave the code guearded by #ifndef(ISC_CHECK_*)

- - - - -
7547d94f by Gary E. Miller at 2017-06-01T21:42:29-07:00
assert: collapse another pointless macro layer.

ISC_REQUIRE() was only ever used by REQUIRE().  So rename
ISC_REQUIRE() to REQUIRE.  Ditto ISC_INVARIANT(), ISC_INSIST(),
and ISC_ENSURE().

- - - - -
661a46f4 by Gary E. Miller at 2017-06-01T21:46:10-07:00
assert: remove comment about dead code.

- - - - -
26047507 by Gary E. Miller at 2017-06-01T21:50:25-07:00
assert: remove hardcoded ISC_PLATFORM_NORETURN_POST

It was always defined as __attribute__((noreturn)).  Code uses
that directly in other places, so it is just obfuscation.

- - - - -


4 changed files:

- devel/ifdex-ignores
- include/ntp_assert.h
- libisc/include/isc/error.h
- wscript


Changes:

=====================================
devel/ifdex-ignores
=====================================
--- a/devel/ifdex-ignores
+++ b/devel/ifdex-ignores
@@ -70,7 +70,6 @@ ENABLE_MSSNTP
 HAVE_LINUX_CAPABILITY
 HAVE_SECCOMP_H
 HAVE_SOLARIS_PRIVS
-ISC_PLATFORM_NORETURN_POST
 PLATFORM_OPENBSD
 WORDS_BIGENDIAN
 


=====================================
include/ntp_assert.h
=====================================
--- a/include/ntp_assert.h
+++ b/include/ntp_assert.h
@@ -34,28 +34,14 @@
 
 #include <stdbool.h>
 
-/* # if defined(__COVERITY__) */
-/*
- * DH: try letting coverity scan our actual assertion macros, now that
- * isc_assertioncallback_t is marked __attribute__ __noreturn__.
- */
-
-/*
- * Coverity has special knowledge that assert(x) terminates the process
- * if x is not true.  Rather than teach it about our assertion macros,
- * just use the one it knows about for Coverity Prevent scans.  This
- * means our assertion code (and ISC's) escapes Coverity analysis, but
- * that seems to be a reasonable trade-off.
- */
-
 #if defined(__FLEXELINT__)
 
 #include <assert.h>
 
-#define ALWAYS_REQUIRE(x)	assert(x)
-#define INSIST(x)		assert(x)
-#define ALWAYS_INVARIANT(x)	assert(x)
-#define ENSURE(x)		assert(x)
+#define REQUIRE(x)      assert(x)
+#define INSIST(x)       assert(x)
+#define INVARIANT(x)    assert(x)
+#define ENSURE(x)       assert(x)
 
 # else	/* not FlexeLint */
 
@@ -72,7 +58,7 @@ typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
 
 /* coverity[+kill] */
 void isc_assertion_failed(const char *, int, isc_assertiontype_t,
-			  const char *) ISC_PLATFORM_NORETURN_POST;
+			  const char *) __attribute__((noreturn));
 
 void
 isc_assertion_setcallback(isc_assertioncallback_t);
@@ -81,86 +67,30 @@ const char *
 isc_assertion_typetotext(isc_assertiontype_t type)
 			__attribute__((const));
 
-#if defined(ISC_CHECK_ALL) || defined(__COVERITY__)
-#define ISC_CHECK_REQUIRE		1
-#define ISC_CHECK_ENSURE		1
-#define ISC_CHECK_INSIST		1
-#define ISC_CHECK_INVARIANT		1
-#endif
-
-#if defined(ISC_CHECK_NONE) && !defined(__COVERITY__)
-#define ISC_CHECK_REQUIRE		0
-#define ISC_CHECK_ENSURE		0
-#define ISC_CHECK_INSIST		0
-#define ISC_CHECK_INVARIANT		0
-#endif
-
-#ifndef ISC_CHECK_REQUIRE
-#define ISC_CHECK_REQUIRE		1
-#endif
-
-#ifndef ISC_CHECK_ENSURE
-#define ISC_CHECK_ENSURE		1
-#endif
-
-#ifndef ISC_CHECK_INSIST
-#define ISC_CHECK_INSIST		1
-#endif
-
-#ifndef ISC_CHECK_INVARIANT
-#define ISC_CHECK_INVARIANT		1
-#endif
-
-#if ISC_CHECK_REQUIRE != 0
-#define ISC_REQUIRE(cond) \
+#define REQUIRE(cond) \
 	((void) ((cond) || \
 		 ((isc_assertion_failed)(__FILE__, __LINE__, \
 					 isc_assertiontype_require, \
 					 #cond), 0)))
-#else
-#define ISC_REQUIRE(cond)	((void) 0)
-#endif /* ISC_CHECK_REQUIRE */
 
-#if ISC_CHECK_ENSURE != 0
-#define ISC_ENSURE(cond) \
+#define ENSURE(cond) \
 	((void) ((cond) || \
 		 ((isc_assertion_failed)(__FILE__, __LINE__, \
 					 isc_assertiontype_ensure, \
 					 #cond), 0)))
-#else
-#define ISC_ENSURE(cond)	((void) 0)
-#endif /* ISC_CHECK_ENSURE */
 
-#if ISC_CHECK_INSIST != 0
-#define ISC_INSIST(cond) \
+#define INSIST(cond) \
 	((void) ((cond) || \
 		 ((isc_assertion_failed)(__FILE__, __LINE__, \
 					 isc_assertiontype_insist, \
 					 #cond), 0)))
-#else
-#define ISC_INSIST(cond)	((void) 0)
-#endif /* ISC_CHECK_INSIST */
-
-#if ISC_CHECK_INVARIANT != 0
-#define ISC_INVARIANT(cond) \
+#define INVARIANT(cond) \
 	((void) ((cond) || \
 		 ((isc_assertion_failed)(__FILE__, __LINE__, \
 					 isc_assertiontype_invariant, \
 					 #cond), 0)))
-#else
-#define ISC_INVARIANT(cond)	((void) 0)
-#endif /* ISC_CHECK_INVARIANT */
-
-#define ALWAYS_REQUIRE(x)	ISC_REQUIRE(x)
-#define INSIST(x)		ISC_INSIST(x)
-#define ALWAYS_INVARIANT(x)	ISC_INVARIANT(x)
-#define ENSURE(x)		ISC_ENSURE(x)
-
 # endif /* not FlexeLint */
 
-#define	REQUIRE(x)		ALWAYS_REQUIRE(x)
-#define	INVARIANT(x)		ALWAYS_INVARIANT(x)
-
 # ifdef DEBUG
 #define	DEBUG_REQUIRE(x)	REQUIRE(x)
 #define	DEBUG_INSIST(x)		INSIST(x)


=====================================
libisc/include/isc/error.h
=====================================
--- a/libisc/include/isc/error.h
+++ b/libisc/include/isc/error.h
@@ -32,7 +32,7 @@ isc_error_unexpected(const char *, int, const char *, ...)
 /*% fatal error */
 void
 isc_error_fatal(const char *, int, const char *, ...)
-ISC_FORMAT_PRINTF(3, 4) ISC_PLATFORM_NORETURN_POST;
+ISC_FORMAT_PRINTF(3, 4) __attribute__	((__noreturn__));
 
 /*% runtimecheck error */
 void


=====================================
wscript
=====================================
--- a/wscript
+++ b/wscript
@@ -803,11 +803,6 @@ int main(int argc, char **argv) {
     ctx.define("DIR_SEP", "'%s'" % sep, quote=False,
                comment="Directory separator used")
 
-    # libisc/
-    # XXX: Hack that needs to be fixed properly for all platforms
-    ctx.define("ISC_PLATFORM_NORETURN_POST",
-               "__attribute__((__noreturn__))", quote=False)
-
     if ctx.get_define("HAVE_SYS_SYSCTL_H"):
         ctx.define("HAVE_IFLIST_SYSCTL", 1,
                    comment="Whether sysctl interface exists")



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/911c1449aa49b7f1a73eac4d7c26b2b9b8da1218...260475073b48b0239522c83194465ed07a2d3361

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/911c1449aa49b7f1a73eac4d7c26b2b9b8da1218...260475073b48b0239522c83194465ed07a2d3361
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170602/79337b8a/attachment.html>


More information about the vc mailing list