From 6ebe63fac23f38df911edc348e8ccc72280f9434 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Aug 2020 08:30:38 +0200 Subject: options: API for meta-data about easy options const struct curl_easyoption *curl_easy_option_by_name(const char *name); const struct curl_easyoption *curl_easy_option_by_id (CURLoption id); const struct curl_easyoption * curl_easy_option_next(const struct curl_easyoption *prev); The purpose is to provide detailed enough information to allow for example libcurl bindings to get option information at run-time about what easy options that exist and what arguments they expect. Assisted-by: Jeroen Ooms Closes #5365 --- tests/libtest/mk-lib1521.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/libtest/mk-lib1521.pl') diff --git a/tests/libtest/mk-lib1521.pl b/tests/libtest/mk-lib1521.pl index f4ef19fe7..e71fe1e51 100755 --- a/tests/libtest/mk-lib1521.pl +++ b/tests/libtest/mk-lib1521.pl @@ -184,13 +184,15 @@ while() { print "${pref} \"string\");\n$check"; print "${pref} NULL);\n$check"; } - elsif($type eq "CURLOPTTYPE_LONG") { + elsif(($type eq "CURLOPTTYPE_LONG") || + ($type eq "CURLOPTTYPE_VALUES")) { print "${pref} 0L);\n$check"; print "${pref} 22L);\n$check"; print "${pref} LO);\n$check"; print "${pref} HI);\n$check"; } - elsif($type eq "CURLOPTTYPE_OBJECTPOINT") { + elsif(($type eq "CURLOPTTYPE_OBJECTPOINT") || + ($type eq "CURLOPTTYPE_CBPOINT")) { if($name =~ /DEPENDS/) { print "${pref} dep);\n$check"; } @@ -244,8 +246,8 @@ while() { print "${pref} &blob);\n$check"; } else { - print STDERR "\n---- $type\n"; - exit; # exit to make this noticed! + print STDERR "\nUnknown type: $type\n"; + exit 22; # exit to make this noticed! } } elsif($_ =~ /^ CURLINFO_NONE/) { -- cgit v1.2.3 From 17fcdf6a310d4c80762455ee9d5e4f52bd55c809 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 7 Sep 2020 10:52:48 +0200 Subject: lib: fix -Wassign-enum warnings configure --enable-debug now enables -Wassign-enum with clang, identifying several enum "abuses" also fixed. Reported-by: Gisle Vanem Bug: https://github.com/curl/curl/commit/879007f8118771f4896334731aaca5850a154675#commitcomment-42087553 Closes #5929 --- docs/examples/sslbackend.c | 6 +++--- lib/easyoptions.c | 2 +- lib/optiontable.pl | 2 +- lib/security.c | 6 +++--- lib/vtls/gtls.c | 2 +- lib/vtls/nss.c | 3 ++- m4/curl-compilers.m4 | 4 ++++ tests/libtest/lib1538.c | 14 +++++++------- tests/libtest/lib1560.c | 2 +- tests/libtest/lib1592.c | 4 ++-- tests/libtest/lib556.c | 4 ++-- tests/libtest/lib583.c | 2 +- tests/libtest/lib661.c | 2 +- tests/libtest/mk-lib1521.pl | 2 +- tests/libtest/test.h | 46 ++++++++++++++++++++++----------------------- 15 files changed, 53 insertions(+), 48 deletions(-) (limited to 'tests/libtest/mk-lib1521.pl') diff --git a/docs/examples/sslbackend.c b/docs/examples/sslbackend.c index 14c230390..12e515005 100644 --- a/docs/examples/sslbackend.c +++ b/docs/examples/sslbackend.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -47,7 +47,7 @@ int main(int argc, char **argv) const curl_ssl_backend **list; int i; - result = curl_global_sslset(-1, NULL, &list); + result = curl_global_sslset((curl_sslbackend)-1, NULL, &list); assert(result == CURLSSLSET_UNKNOWN_BACKEND); for(i = 0; list[i]; i++) @@ -62,7 +62,7 @@ int main(int argc, char **argv) result = curl_global_sslset((curl_sslbackend)id, NULL, NULL); } else - result = curl_global_sslset(-1, name, NULL); + result = curl_global_sslset((curl_sslbackend)-1, name, NULL); if(result == CURLSSLSET_UNKNOWN_BACKEND) { fprintf(stderr, "Unknown SSL backend id: %s\n", name); diff --git a/lib/easyoptions.c b/lib/easyoptions.c index 9145ba7fc..0ab6a3fc6 100644 --- a/lib/easyoptions.c +++ b/lib/easyoptions.c @@ -332,7 +332,7 @@ struct curl_easyoption Curl_easyopts[] = { {"XFERINFODATA", CURLOPT_XFERINFODATA, CURLOT_CBPTR, 0}, {"XFERINFOFUNCTION", CURLOPT_XFERINFOFUNCTION, CURLOT_FUNCTION, 0}, {"XOAUTH2_BEARER", CURLOPT_XOAUTH2_BEARER, CURLOT_STRING, 0}, - {NULL, 0, 0, 0} /* end of table */ + {NULL, CURLOPT_LASTENTRY, 0, 0} /* end of table */ }; #ifdef DEBUGBUILD diff --git a/lib/optiontable.pl b/lib/optiontable.pl index ce5d02015..9c3b62619 100644 --- a/lib/optiontable.pl +++ b/lib/optiontable.pl @@ -101,7 +101,7 @@ for my $name (sort @names) { } print <, et al. + * Copyright (C) 2001 - 2020, Daniel Stenberg, , et al. * * All rights reserved. * @@ -529,7 +529,7 @@ static CURLcode choose_mech(struct connectdata *conn) if(ret != AUTH_CONTINUE) { if(ret != AUTH_OK) { /* Mechanism has dumped the error to stderr, don't error here. */ - return -1; + return CURLE_USE_SSL_FAILED; } DEBUGASSERT(ret == AUTH_OK); diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index 9f280447c..978c61abf 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -304,7 +304,7 @@ static gnutls_x509_crt_fmt_t do_file_type(const char *type) return GNUTLS_X509_FMT_PEM; if(strcasecompare(type, "DER")) return GNUTLS_X509_FMT_DER; - return -1; + return GNUTLS_X509_FMT_PEM; /* default to PEM */ } #define GNUTLS_CIPHERS "NORMAL:-ARCFOUR-128:-CTYPE-ALL:+CTYPE-X509" diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c index 8e9de3cd6..25098814a 100644 --- a/lib/vtls/nss.c +++ b/lib/vtls/nss.c @@ -1672,7 +1672,8 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn, if(!dir) return CURLE_SSL_CACERT_BADFILE; - while((entry = PR_ReadDir(dir, PR_SKIP_BOTH | PR_SKIP_HIDDEN))) { + while((entry = + PR_ReadDir(dir, (PRDirFlags)(PR_SKIP_BOTH | PR_SKIP_HIDDEN)))) { char *fullpath = aprintf("%s/%s", capath, entry->name); if(!fullpath) { PR_CloseDir(dir); diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4 index b0d5d4213..7d59f0667 100644 --- a/m4/curl-compilers.m4 +++ b/m4/curl-compilers.m4 @@ -945,6 +945,10 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs" fi fi + dnl clang 7 or later + if test "$compiler_num" -ge "700"; then + CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum]) + fi fi ;; # diff --git a/tests/libtest/lib1538.c b/tests/libtest/lib1538.c index 91481e88d..0f91e2f0c 100644 --- a/tests/libtest/lib1538.c +++ b/tests/libtest/lib1538.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -31,12 +31,12 @@ int test(char *URL) CURLSHcode shareret; (void)URL; - curl_easy_strerror(INT_MAX); - curl_multi_strerror(INT_MAX); - curl_share_strerror(INT_MAX); - curl_easy_strerror(-INT_MAX); - curl_multi_strerror(-INT_MAX); - curl_share_strerror(-INT_MAX); + curl_easy_strerror((CURLcode)INT_MAX); + curl_multi_strerror((CURLMcode)INT_MAX); + curl_share_strerror((CURLSHcode)INT_MAX); + curl_easy_strerror((CURLcode)-INT_MAX); + curl_multi_strerror((CURLMcode)-INT_MAX); + curl_share_strerror((CURLSHcode)-INT_MAX); for(easyret = CURLE_OK; easyret <= CURL_LAST; easyret++) { printf("e%d: %s\n", (int)easyret, curl_easy_strerror(easyret)); } diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index 20f852310..cc61199e9 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -638,7 +638,7 @@ static CURLUPart part2id(char *part) return CURLUPART_FRAGMENT; if(!strcmp("zoneid", part)) return CURLUPART_ZONEID; - return 9999; /* bad input => bad output */ + return (CURLUPart)9999; /* bad input => bad output */ } static CURLUcode updateurl(CURLU *u, const char *cmd, unsigned int setflags) diff --git a/tests/libtest/lib1592.c b/tests/libtest/lib1592.c index 5e6bf04eb..ce0892be2 100644 --- a/tests/libtest/lib1592.c +++ b/tests/libtest/lib1592.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -43,7 +43,7 @@ int test(char *URL) int stillRunning; CURLM *multiHandle = NULL; CURL *curl = NULL; - CURLMcode res = CURLM_OK; + CURLcode res = CURLE_OK; int timeout; global_init(CURL_GLOBAL_ALL); diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 0595000ce..82e8b71dc 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -96,7 +96,7 @@ int test(char *URL) } if(iolen != 0) - res = TEST_ERR_FAILURE; + res = (CURLcode)TEST_ERR_FAILURE; } test_cleanup: diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index 86dd8b55a..3e2fe3867 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -35,7 +35,7 @@ int test(char *URL) int stillRunning; CURLM *multiHandle = NULL; CURL *curl = NULL; - CURLMcode res = CURLM_OK; + CURLcode res = CURLE_OK; global_init(CURL_GLOBAL_ALL); diff --git a/tests/libtest/lib661.c b/tests/libtest/lib661.c index a4f2c8e5c..454d8f337 100644 --- a/tests/libtest/lib661.c +++ b/tests/libtest/lib661.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2020, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms diff --git a/tests/libtest/mk-lib1521.pl b/tests/libtest/mk-lib1521.pl index e71fe1e51..9b57b64ee 100755 --- a/tests/libtest/mk-lib1521.pl +++ b/tests/libtest/mk-lib1521.pl @@ -297,7 +297,7 @@ while() { print <