summaryrefslogtreecommitdiff
path: root/CMake/CurlTests.c
diff options
context:
space:
mode:
authormaxed <max.savenkov@gmail.com>2018-03-31 13:17:45 +0300
committerSergei Nikulov <snikulov@users.noreply.github.com>2018-05-28 08:05:16 +0300
commit7e93637acd9f5741ac4c09bbca353ac8da42bb17 (patch)
treee4be69e81d54de57c20c9612280e6001e38b618f /CMake/CurlTests.c
parentaa18b573c82ae73f49e59e7806b20cd7b4057d62 (diff)
downloadcurl-7e93637acd9f5741ac4c09bbca353ac8da42bb17.tar.gz
Fix the test for fsetxattr and strerror_r tests in CMake to work without compiling
Diffstat (limited to 'CMake/CurlTests.c')
-rw-r--r--CMake/CurlTests.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c
index bc36c8ef7..ac959f340 100644
--- a/CMake/CurlTests.c
+++ b/CMake/CurlTests.c
@@ -507,30 +507,30 @@ main ()
#ifdef HAVE_GLIBC_STRERROR_R
#include <string.h>
#include <errno.h>
+
+void check(char c) {}
+
int
main () {
- char buffer[1024]; /* big enough to play with */
- char *string =
- strerror_r(EACCES, buffer, sizeof(buffer));
- /* this should've returned a string */
- if(!string || !string[0])
- return 99;
- return 0;
+ char buffer[1024];
+ // This will not compile if strerror_r does not return a char*
+ check(strerror_r(EACCES, buffer, sizeof(buffer))[0]);
+ return 0;
}
#endif
#ifdef HAVE_POSIX_STRERROR_R
#include <string.h>
#include <errno.h>
+
+// float, because a pointer can't be implicitly cast to float
+void check(float f) {}
+
int
main () {
- char buffer[1024]; /* big enough to play with */
- int error =
- strerror_r(EACCES, buffer, sizeof(buffer));
- /* This should've returned zero, and written an error string in the
- buffer.*/
- if(!buffer[0] || error)
- return 99;
- return 0;
+ char buffer[1024];
+ // This will not compile if strerror_r does not return an int
+ check(strerror_r(EACCES, buffer, sizeof(buffer)));
+ return 0;
}
#endif
#ifdef HAVE_FSETXATTR_6