From 8df455479f8801bbebad8839fc96abbffa711603 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 14 May 2020 00:05:04 +0200 Subject: source cleanup: remove all custom typedef structs - Stick to a single unified way to use structs - Make checksrc complain on 'typedef struct {' - Allow them in tests, public headers and examples - Let MD4_CTX, MD5_CTX, and SHA256_CTX typedefs remain as they actually typedef different types/structs depending on build conditions. Closes #5338 --- tests/libtest/.checksrc | 1 + tests/libtest/Makefile.am | 2 +- tests/libtest/lib1156.c | 10 +++++----- tests/libtest/lib576.c | 12 ++++++------ tests/unit/unit1305.c | 8 ++++---- tests/unit/unit1608.c | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 tests/libtest/.checksrc (limited to 'tests') diff --git a/tests/libtest/.checksrc b/tests/libtest/.checksrc new file mode 100644 index 000000000..24677d53e --- /dev/null +++ b/tests/libtest/.checksrc @@ -0,0 +1 @@ +disable TYPEDEFSTRUCT diff --git a/tests/libtest/Makefile.am b/tests/libtest/Makefile.am index 67a20cb98..e87a36306 100644 --- a/tests/libtest/Makefile.am +++ b/tests/libtest/Makefile.am @@ -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/lib1156.c b/tests/libtest/lib1156.c index df6062c56..ff94d9cfd 100644 --- a/tests/libtest/lib1156.c +++ b/tests/libtest/lib1156.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 @@ -40,12 +40,12 @@ #define F_CONTENTRANGE (1 << 3) /* Server sends content-range hdr. */ #define F_IGNOREBODY (1 << 4) /* Body should be ignored. */ -typedef struct { +struct testparams { unsigned int flags; /* ORed flags as above. */ CURLcode result; /* Code that should be returned by curl_easy_perform(). */ -} testparams; +}; -static const testparams params[] = { +static const struct testparams params[] = { { 0, CURLE_OK }, { F_CONTENTRANGE, CURLE_OK }, { F_FAIL, CURLE_OK }, @@ -82,7 +82,7 @@ static size_t writedata(char *data, size_t size, size_t nmemb, void *userdata) return size * nmemb; } -static int onetest(CURL *curl, const char *url, const testparams *p) +static int onetest(CURL *curl, const char *url, const struct testparams *p) { CURLcode res; unsigned int replyselector; diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 3b9a9001d..f66825895 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, 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 @@ -24,10 +24,10 @@ #include "testutil.h" #include "memdebug.h" -typedef struct { +struct chunk_data { int remains; int print_content; -} chunk_data_t; +}; static long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains); @@ -37,7 +37,7 @@ long chunk_end(void *ptr); static long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains) { - chunk_data_t *ch_d = ptr; + struct chunk_data *ch_d = ptr; ch_d->remains = remains; printf("=============================================================\n"); @@ -87,7 +87,7 @@ long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains) static long chunk_end(void *ptr) { - chunk_data_t *ch_d = ptr; + struct chunk_data *ch_d = ptr; if(ch_d->print_content) { ch_d->print_content = 0; printf("-------------------------------------------------------------\n"); @@ -101,7 +101,7 @@ int test(char *URL) { CURL *handle = NULL; CURLcode res = CURLE_OK; - chunk_data_t chunk_data = {0, 0}; + struct chunk_data chunk_data = {0, 0}; curl_global_init(CURL_GLOBAL_ALL); handle = curl_easy_init(); if(!handle) { diff --git a/tests/unit/unit1305.c b/tests/unit/unit1305.c index 6e4bbb861..f3cd9d8f0 100644 --- a/tests/unit/unit1305.c +++ b/tests/unit/unit1305.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 @@ -73,11 +73,11 @@ static void unit_stop(void) curl_global_cleanup(); } -static Curl_addrinfo *fake_ai(void) +static struct Curl_addrinfo *fake_ai(void) { - static Curl_addrinfo *ai; + static struct Curl_addrinfo *ai; - ai = calloc(1, sizeof(Curl_addrinfo)); + ai = calloc(1, sizeof(struct Curl_addrinfo)); if(!ai) return NULL; diff --git a/tests/unit/unit1608.c b/tests/unit/unit1608.c index 9105e2847..fc767d1d5 100644 --- a/tests/unit/unit1608.c +++ b/tests/unit/unit1608.c @@ -24,7 +24,7 @@ #include "hostip.h" CURLcode Curl_shuffle_addr(struct Curl_easy *data, - Curl_addrinfo **addr); + struct Curl_addrinfo **addr); #define NUM_ADDRS 8 static struct Curl_addrinfo addrs[NUM_ADDRS]; -- cgit v1.2.3