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 --- docs/CODE_STYLE.md | 19 +++++++++++++++++++ docs/examples/.checksrc | 2 ++ docs/examples/Makefile.am | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 docs/examples/.checksrc (limited to 'docs') diff --git a/docs/CODE_STYLE.md b/docs/CODE_STYLE.md index 0ceb5b9ad..561343752 100644 --- a/docs/CODE_STYLE.md +++ b/docs/CODE_STYLE.md @@ -244,3 +244,22 @@ depending on a build-time conditional: #endif int content = magic(3); + +## No typedefed structs + +Use structs by all means, but do not typedef them. Use the `struct name` way +of identifying them: + + struct something { + void *valid; + size_t way_to_write; + }; + struct something instance; + +**Not okay**: + + typedef struct { + void *wrong; + size_t way_to_write; + } something; + something instance; diff --git a/docs/examples/.checksrc b/docs/examples/.checksrc new file mode 100644 index 000000000..c45678aae --- /dev/null +++ b/docs/examples/.checksrc @@ -0,0 +1,2 @@ +disable TYPEDEFSTRUCT +disable SNPRINTF diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am index 53867cb22..db4d12337 100644 --- a/docs/examples/Makefile.am +++ b/docs/examples/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 @@ -67,4 +67,4 @@ CS_1 = CS_ = $(CS_0) checksrc: - $(CHECKSRC)(@PERL@ $(top_srcdir)/lib/checksrc.pl -ASNPRINTF $(srcdir)/*.c) + $(CHECKSRC)(@PERL@ $(top_srcdir)/lib/checksrc.pl $(srcdir)/*.c) -- cgit v1.2.3