diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-09-02 10:45:24 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-09-02 10:45:38 +0300 |
commit | 9f333edbdf76c1a8e9842ab551b97975570cf192 (patch) | |
tree | 9b7e017a88804f6fc342e2cf722307d526a76e06 | |
parent | aaab73802c5f05d231d87ab9d401e6b262c6fe2e (diff) | |
download | libmicrohttpd-9f333edbdf76c1a8e9842ab551b97975570cf192.tar.gz libmicrohttpd-9f333edbdf76c1a8e9842ab551b97975570cf192.zip |
Fixed possible preprocessor error when SIZE_MAX is not digits-only
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 4 | ||||
-rw-r--r-- | src/microhttpd/mhd_threads.c | 4 |
3 files changed, 18 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index ec27649d..3ee40378 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1073,6 +1073,9 @@ AC_CHECK_HEADER([[search.h]], | |||
1073 | AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]]) | 1073 | AM_CONDITIONAL([MHD_HAVE_TSEARCH], [[test "x$ac_cv_header_search_h" = xyes && test "x$HAVE_TSEARCH" = "x1" && test "x$REPLACE_TSEARCH" != "x1"]]) |
1074 | 1074 | ||
1075 | # Check for types sizes | 1075 | # Check for types sizes |
1076 | # Types sizes are used as an indirect indication of maximum allowed values for types | ||
1077 | # which is used to exclude by preprocessor some compiler checks for values clips | ||
1078 | # Assuming no staffing or uniform staffing for integer types | ||
1076 | AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec], | 1079 | AC_CACHE_CHECK([size of tv_sec member of struct timeval], [mhd_cv_size_timeval_tv_sec], |
1077 | [ | 1080 | [ |
1078 | AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))], | 1081 | AC_COMPUTE_INT([mhd_cv_size_timeval_tv_sec], [((long int)sizeof(test_var.tv_sec))], |
@@ -1103,6 +1106,17 @@ AC_DEFINE_UNQUOTED([SIZEOF_STRUCT_TIMEVAL_TV_SEC], [$mhd_cv_size_timeval_tv_sec] | |||
1103 | [The size of `tv_sec' member of `struct timeval', as computed by sizeof]) | 1106 | [The size of `tv_sec' member of `struct timeval', as computed by sizeof]) |
1104 | AC_CHECK_SIZEOF([uint64_t], [], [[#include <stdint.h>]]) | 1107 | AC_CHECK_SIZEOF([uint64_t], [], [[#include <stdint.h>]]) |
1105 | AC_CHECK_SIZEOF([unsigned int], [], [[#include <stdint.h>]]) | 1108 | AC_CHECK_SIZEOF([unsigned int], [], [[#include <stdint.h>]]) |
1109 | AC_CHECK_SIZEOF([size_t], [], | ||
1110 | [[ | ||
1111 | #ifdef HAVE_STDLIB_H | ||
1112 | #include <stdlib.h> | ||
1113 | #endif /* HAVE_STDLIB_H */ | ||
1114 | #ifdef HAVE_STDDEF_H | ||
1115 | #include <stddef.h> | ||
1116 | #endif /* HAVE_STDDEF_H */ | ||
1117 | #include <stdio.h> | ||
1118 | ]] | ||
1119 | ) | ||
1106 | 1120 | ||
1107 | AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT]) | 1121 | AC_CHECK_HEADERS([dlfcn.h],[have_tlsplugin=yes],[have_tlsplugin=no], [AC_INCLUDES_DEFAULT]) |
1108 | AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]]) | 1122 | AM_CONDITIONAL([MHD_HAVE_TLS_PLUGIN], [[test "x$have_tlsplugin" = xyes]]) |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 83110dd3..faf12c08 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -5695,7 +5695,7 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
5695 | #endif | 5695 | #endif |
5696 | daemon->worker_pool_size = 0; | 5696 | daemon->worker_pool_size = 0; |
5697 | } | 5697 | } |
5698 | #if (0 == (UINT_MAX + 0)) || (UINT_MAX >= (SIZE_MAX / (64 * 1024))) | 5698 | #if SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2) |
5699 | /* Next comparison could be always false on some platforms and whole branch will | 5699 | /* Next comparison could be always false on some platforms and whole branch will |
5700 | * be optimized out on these platforms. On others it will be compiled into real | 5700 | * be optimized out on these platforms. On others it will be compiled into real |
5701 | * check. */ | 5701 | * check. */ |
@@ -5709,7 +5709,7 @@ parse_options_va (struct MHD_Daemon *daemon, | |||
5709 | #endif | 5709 | #endif |
5710 | return MHD_NO; | 5710 | return MHD_NO; |
5711 | } | 5711 | } |
5712 | #endif /* (UINT_MAX >= (SIZE_MAX/(64*1024))) */ | 5712 | #endif /* SIZEOF_UNSIGNED_INT >= (SIZEOF_SIZE_T - 2) */ |
5713 | else | 5713 | else |
5714 | { | 5714 | { |
5715 | if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) | 5715 | if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) |
diff --git a/src/microhttpd/mhd_threads.c b/src/microhttpd/mhd_threads.c index 52aba875..f40480c6 100644 --- a/src/microhttpd/mhd_threads.c +++ b/src/microhttpd/mhd_threads.c | |||
@@ -215,13 +215,13 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread, | |||
215 | 215 | ||
216 | return ! res; | 216 | return ! res; |
217 | #elif defined(MHD_USE_W32_THREADS) | 217 | #elif defined(MHD_USE_W32_THREADS) |
218 | #if SIZE_MAX != UINT_MAX | 218 | #if SIZEOF_SIZE_T != SIZEOF_UNSIGNED_INT |
219 | if (stack_size > UINT_MAX) | 219 | if (stack_size > UINT_MAX) |
220 | { | 220 | { |
221 | errno = EINVAL; | 221 | errno = EINVAL; |
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
224 | #endif /* SIZE_MAX != UINT_MAX */ | 224 | #endif /* SIZEOF_SIZE_T != SIZEOF_UNSIGNED_INT */ |
225 | 225 | ||
226 | thread->handle = (MHD_thread_handle_) | 226 | thread->handle = (MHD_thread_handle_) |
227 | _beginthreadex (NULL, | 227 | _beginthreadex (NULL, |