gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated: Added support for "noreturn" func


From: gnunet
Subject: [libmicrohttpd] branch master updated: Added support for "noreturn" function declaration.
Date: Mon, 04 Oct 2021 09:32:31 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new 85db559e Added support for "noreturn" function declaration.
85db559e is described below

commit 85db559ed6a0df39587cad4d055020a84d18e04b
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Oct 4 10:32:11 2021 +0300

    Added support for "noreturn" function declaration.
    
    It should help static analyzer to properly detect code paths.
---
 configure.ac                 | 42 ++++++++++++++++++++++++++++++++++++++++++
 src/microhttpd/daemon.c      |  2 +-
 src/testcurl/test_toolarge.c |  6 +++---
 3 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 23d5a900..bd6bd899 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,6 @@
 # This file is part of libmicrohttpd.
 # (C) 2006-2021 Christian Grothoff (and other contributing authors)
+# (C) 2014-2021 Evgeny Grin (Karlson2k)
 #
 # libmicrohttpd is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published
@@ -1107,6 +1108,47 @@ AC_CHECK_HEADER([[search.h]],
 
 AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && 
test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]])
 
+AC_CACHE_CHECK([for suported 'noreturn' keyword], [mhd_cv_decl_noreturn],
+  [
+    mhd_cv_decl_noreturn="none"
+    save_CFLAGS="${CFLAGS}"
+    CFLAGS="${CFLAGS} ${errattr_CFLAGS}"
+    for decl_noret in '_Noreturn' '__attribute__((__noreturn__))' 
'__declspec(noreturn)'; do
+      AC_LINK_IFELSE([AC_LANG_SOURCE(
+          [[
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+${decl_noret} void myexitfunc(int code)
+{
+#ifdef HAVE_STDLIB_H
+  exit (code);
+#else
+  (void)code;
+#endif
+}
+
+int main (int argc, char *const *argv)
+{
+  (void) argv;
+  if (argc > 2)
+    myexitfunc (2);
+  return 0;
+}
+          ]]
+        )], [mhd_cv_decl_noreturn="${decl_noret}"]
+      )
+      AS_IF([test "x${mhd_cv_decl_noreturn}" != "xnone"], [break])
+    done
+    CFLAGS="${save_CFLAGS}"
+  ]
+)
+AS_VAR_IF([mhd_cv_decl_noreturn], ["none"],
+  [AC_DEFINE([_MHD_NORETURN], [], [Define to supported 'noreturn' function 
declaration])],
+  [AC_DEFINE_UNQUOTED([_MHD_NORETURN], [${mhd_cv_decl_noreturn}], [Define to 
supported 'noreturn' function declaration])]
+)
+
 # Check for types sizes
 # Types sizes are used as an indirect indication of maximum allowed values for 
types
 # which is used to exclude by preprocessor some compiler checks for values 
clips
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f1660848..d022247d 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -125,7 +125,7 @@ MHD_epoll (struct MHD_Daemon *daemon,
  * @param line line number with the problem
  * @param reason error message with details
  */
-static void
+_MHD_NORETURN static void
 mhd_panic_std (void *cls,
                const char *file,
                unsigned int line,
diff --git a/src/testcurl/test_toolarge.c b/src/testcurl/test_toolarge.c
index f81827e7..70b37ff9 100644
--- a/src/testcurl/test_toolarge.c
+++ b/src/testcurl/test_toolarge.c
@@ -113,7 +113,7 @@
 #endif
 
 
-static void
+_MHD_NORETURN static void
 _externalErrorExit_func (const char *errDesc, const char *funcName, int 
lineNum)
 {
   if ((NULL != errDesc) && (0 != errDesc[0]))
@@ -137,7 +137,7 @@ _externalErrorExit_func (const char *errDesc, const char 
*funcName, int lineNum)
 
 static char libcurl_errbuf[CURL_ERROR_SIZE] = "";
 
-static void
+_MHD_NORETURN static void
 _libcurlErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
 {
   if ((NULL != errDesc) && (0 != errDesc[0]))
@@ -159,7 +159,7 @@ _libcurlErrorExit_func (const char *errDesc, const char 
*funcName, int lineNum)
 }
 
 
-static void
+_MHD_NORETURN static void
 _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
 {
   if ((NULL != errDesc) && (0 != errDesc[0]))

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]