Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TS-1464: apply noreturn attribute to _TSReleaseAssert

  • Loading branch information...
commit 0a87a651eb08afe5d547da76fb9955bfdee6e7b6 1 parent 48bbfbf
James Peach jpeach authored
Showing with 13 additions and 6 deletions.
  1. +2 −3 proxy/InkAPI.cc
  2. +1 −1  proxy/InkIOCoreAPI.cc
  3. +10 −2 proxy/api/ts/ts.h.in
5 proxy/InkAPI.cc
View
@@ -403,11 +403,10 @@ TSError(const char *fmt, ...)
}
// Assert in debug AND optim
-int
+void
_TSReleaseAssert(const char *text, const char *file, int line)
{
_ink_assert(text, file, line);
- return 0;
}
// Assert only in debug
@@ -430,7 +429,7 @@ _TSAssert(const char *text, const char *file, int line)
#define sdk_assert(EX) (void)(EX)
#else
#define sdk_assert(EX) \
- (void)((EX) || (_TSReleaseAssert(#EX, __FILE__, __LINE__)))
+ ( (void)((EX) ? (void)0 : _TSReleaseAssert(#EX, __FILE__, __LINE__)) )
#endif
2  proxy/InkIOCoreAPI.cc
View
@@ -44,7 +44,7 @@
#define sdk_assert(EX) (void)(EX)
#else
#define sdk_assert(EX) \
- (void)((EX) || (_TSReleaseAssert(#EX, __FILE__, __LINE__)))
+ ( (void)((EX) ? (void)0 : _TSReleaseAssert(#EX, __FILE__, __LINE__)) )
#endif
12 proxy/api/ts/ts.h.in
View
@@ -51,6 +51,14 @@
#endif
#endif
+#if !defined(TS_NORETURN)
+#if defined(__GNUC__) || defined(__clang__)
+#define TS_NORETURN __attribute__((noreturn))
+#else
+#define TS_NORETURN
+#endif
+#endif
+
#ifdef __cplusplus
extern "C"
{
@@ -1249,11 +1257,11 @@ extern "C"
/* --------------------------------------------------------------------------
Assertions */
- tsapi int _TSReleaseAssert(const char* txt, const char* f, int l);
+ tsapi void _TSReleaseAssert(const char* txt, const char* f, int l) TS_NORETURN;
tsapi int _TSAssert(const char* txt, const char* f, int l);
#define TSReleaseAssert(EX) \
- (void)((EX) || (_TSReleaseAssert(#EX, __FILE__, __LINE__)))
+ ( (void)((EX) ? (void)0 : _TSReleaseAssert(#EX, __FILE__, __LINE__)) )
#define TSAssert(EX) \
(void)((EX) || (_TSAssert(#EX, __FILE__, __LINE__)))
Please sign in to comment.
Something went wrong with that request. Please try again.