[Openvpn-devel,6/9] Add noreturn attribute for MSVC to assert_failed method.

Message ID 20210512131511.1309914-7-arne@rfc2549.org
State Accepted
Headers show
Series
  • Miscellaneous cleanup patches/small fixes
Related show

Commit Message

Arne Schwabe May 12, 2021, 1:15 p.m.
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/error.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Gert Doering May 14, 2021, 1:10 p.m. | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

I can't claim to understand the MSVC intricacies, but the explanation
is good, and it shouldn't break non-MSVC compiles.  The dangling ";" 
after an #endif is truly OpenVPN-style ugly, though...  we avoid
it elsewhere by defining

  #define __attribute__(x)

for MSVC builds, but error.h is special... the code would benefit from
a comment, though.

Your patch has been applied to the master branch.

commit ad2140e0337f99c183e732b61df03ae29bdec766
Author: Arne Schwabe
Date:   Wed May 12 15:15:08 2021 +0200

     Add noreturn attribute for MSVC to assert_failed method.

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20210512131511.1309914-7-arne@rfc2549.org>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22344.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/error.h b/src/openvpn/error.h
index 1a5521654..469afe20a 100644
--- a/src/openvpn/error.h
+++ b/src/openvpn/error.h
@@ -202,8 +202,14 @@  FILE *msg_fp(const unsigned int flags);
 #define ASSERT(x) do { if (!(x)) {assert_failed(__FILE__, __LINE__, NULL);}} while (false)
 #endif
 
+#ifdef _MSC_VER
+__declspec(noreturn)
+#endif
 void assert_failed(const char *filename, int line, const char *condition)
-__attribute__((__noreturn__));
+#ifndef _MSC_VER
+__attribute__((__noreturn__))
+#endif
+;
 
 /* Poor-man's static_assert() for when not supplied by assert.h, taken from
  * Linux's sys/cdefs.h under GPLv2 */