Use parentheses to avoid mis-indentations of stringified macro args

clang-format sometimes thinks that "#name" should be written as
"#     name" if it appears at the start of a line.  Using () appears
to suppress this, while confusing Coccinelle.
This commit is contained in:
Nick Mathewson 2020-01-10 15:01:42 -05:00
parent 6104c407e0
commit 06a6130666
6 changed files with 22 additions and 17 deletions

View File

@ -182,7 +182,7 @@ static const char unix_q_socket_prefix[] = "unix:\"";
* *DowloadInitialDelay . */ * *DowloadInitialDelay . */
#ifndef COCCI #ifndef COCCI
#define DOWNLOAD_SCHEDULE(name) \ #define DOWNLOAD_SCHEDULE(name) \
{ #name "DownloadSchedule", #name "DownloadInitialDelay", 0, 1 } { (#name "DownloadSchedule"), (#name "DownloadInitialDelay"), 0, 1 }
#else #else
#define DOWNLOAD_SCHEDULE(name) { NULL, NULL, 0, 1 } #define DOWNLOAD_SCHEDULE(name) { NULL, NULL, 0, 1 }
#endif /* !defined(COCCI) */ #endif /* !defined(COCCI) */

View File

@ -2272,7 +2272,7 @@ typedef struct control_cmd_def_t {
**/ **/
#define ONE_LINE(name, flags) \ #define ONE_LINE(name, flags) \
{ \ { \
#name, \ (#name), \
handle_control_ ##name, \ handle_control_ ##name, \
flags, \ flags, \
&name##_syntax, \ &name##_syntax, \
@ -2283,7 +2283,7 @@ typedef struct control_cmd_def_t {
* flags. * flags.
**/ **/
#define MULTLINE(name, flags) \ #define MULTLINE(name, flags) \
{ "+"#name, \ { ("+"#name), \
handle_control_ ##name, \ handle_control_ ##name, \
flags, \ flags, \
&name##_syntax \ &name##_syntax \

View File

@ -260,6 +260,7 @@ typedef struct config_deprecation_t {
const char *why_deprecated; const char *why_deprecated;
} config_deprecation_t; } config_deprecation_t;
#ifndef COCCI
/** /**
* Handy macro for declaring "In the config file or on the command line, you * Handy macro for declaring "In the config file or on the command line, you
* can abbreviate <b>tok</b>s as <b>tok</b>". Used inside an array of * can abbreviate <b>tok</b>s as <b>tok</b>". Used inside an array of
@ -268,7 +269,8 @@ typedef struct config_deprecation_t {
* For example, to declare "NumCpu" as an abbreviation for "NumCPUs", * For example, to declare "NumCpu" as an abbreviation for "NumCPUs",
* you can say PLURAL(NumCpu). * you can say PLURAL(NumCpu).
**/ **/
#define PLURAL(tok) { #tok, #tok "s", 0, 0 } #define PLURAL(tok) { (#tok), (#tok "s"), 0, 0 }
#endif /* !defined(COCCI) */
/** /**
* Validation function: verify whether a configuation object is well-formed * Validation function: verify whether a configuation object is well-formed

View File

@ -579,8 +579,10 @@ test_get_pt_proxy_uri(void *arg)
tor_free(uri); tor_free(uri);
} }
#ifndef COCCI
#define PT_LEGACY(name) \ #define PT_LEGACY(name) \
{ #name, test_pt_ ## name , 0, NULL, NULL } { (#name), test_pt_ ## name , 0, NULL, NULL }
#endif
struct testcase_t pt_tests[] = { struct testcase_t pt_tests[] = {
PT_LEGACY(parsing), PT_LEGACY(parsing),

View File

@ -6305,42 +6305,42 @@ test_util_map_anon_nofork(void *arg)
#ifndef COCCI #ifndef COCCI
#define UTIL_LEGACY(name) \ #define UTIL_LEGACY(name) \
{ #name, test_util_ ## name , 0, NULL, NULL } { (#name), test_util_ ## name , 0, NULL, NULL }
#define UTIL_TEST(name, flags) \ #define UTIL_TEST(name, flags) \
{ #name, test_util_ ## name, flags, NULL, NULL } { (#name), test_util_ ## name, flags, NULL, NULL }
#define COMPRESS(name, identifier) \ #define COMPRESS(name, identifier) \
{ "compress/" #name, test_util_compress, 0, &compress_setup, \ { ("compress/" #name), test_util_compress, 0, &compress_setup, \
(char*)(identifier) } (char*)(identifier) }
#define COMPRESS_CONCAT(name, identifier) \ #define COMPRESS_CONCAT(name, identifier) \
{ "compress_concat/" #name, test_util_decompress_concatenated, 0, \ { ("compress_concat/" #name), test_util_decompress_concatenated, 0, \
&compress_setup, \ &compress_setup, \
(char*)(identifier) } (char*)(identifier) }
#define COMPRESS_JUNK(name, identifier) \ #define COMPRESS_JUNK(name, identifier) \
{ "compress_junk/" #name, test_util_decompress_junk, 0, \ { ("compress_junk/" #name), test_util_decompress_junk, 0, \
&compress_setup, \ &compress_setup, \
(char*)(identifier) } (char*)(identifier) }
#define COMPRESS_DOS(name, identifier) \ #define COMPRESS_DOS(name, identifier) \
{ "compress_dos/" #name, test_util_decompress_dos, 0, \ { ("compress_dos/" #name), test_util_decompress_dos, 0, \
&compress_setup, \ &compress_setup, \
(char*)(identifier) } (char*)(identifier) }
#endif /* !defined(COCCI) */
#ifdef _WIN32 #ifdef _WIN32
#define UTIL_TEST_WIN_ONLY(n, f) UTIL_TEST(n, (f)) #define UTIL_TEST_WIN_ONLY(n, f) UTIL_TEST(n, (f))
#else #else
#define UTIL_TEST_WIN_ONLY(n, f) { #n, NULL, TT_SKIP, NULL, NULL } #define UTIL_TEST_WIN_ONLY(n, f) { (#n), NULL, TT_SKIP, NULL, NULL }
#endif #endif
#ifdef DISABLE_PWDB_TESTS #ifdef DISABLE_PWDB_TESTS
#define UTIL_TEST_PWDB(n, f) { #n, NULL, TT_SKIP, NULL, NULL } #define UTIL_TEST_PWDB(n, f) { (#n), NULL, TT_SKIP, NULL, NULL }
#else #else
#define UTIL_TEST_PWDB(n, f) UTIL_TEST(n, (f)) #define UTIL_TEST_PWDB(n, f) UTIL_TEST(n, (f))
#endif #endif
#endif
struct testcase_t util_tests[] = { struct testcase_t util_tests[] = {
UTIL_LEGACY(time), UTIL_LEGACY(time),

View File

@ -67,10 +67,12 @@ test_util_process_clear_waitpid_callback(void *ignored)
} }
#endif /* !defined(_WIN32) */ #endif /* !defined(_WIN32) */
#ifndef COCCI
#ifndef _WIN32 #ifndef _WIN32
#define TEST(name) { #name, test_util_process_##name, 0, NULL, NULL } #define TEST(name) { (#name), test_util_process_##name, 0, NULL, NULL }
#else #else
#define TEST(name) { #name, NULL, TT_SKIP, NULL, NULL } #define TEST(name) { (#name), NULL, TT_SKIP, NULL, NULL }
#endif
#endif #endif
struct testcase_t util_process_tests[] = { struct testcase_t util_process_tests[] = {
@ -78,4 +80,3 @@ struct testcase_t util_process_tests[] = {
TEST(clear_waitpid_callback), TEST(clear_waitpid_callback),
END_OF_TESTCASES END_OF_TESTCASES
}; };