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 . */
#ifndef COCCI
#define DOWNLOAD_SCHEDULE(name) \
{ #name "DownloadSchedule", #name "DownloadInitialDelay", 0, 1 }
{ (#name "DownloadSchedule"), (#name "DownloadInitialDelay"), 0, 1 }
#else
#define DOWNLOAD_SCHEDULE(name) { NULL, NULL, 0, 1 }
#endif /* !defined(COCCI) */

View File

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

View File

@ -260,6 +260,7 @@ typedef struct config_deprecation_t {
const char *why_deprecated;
} config_deprecation_t;
#ifndef COCCI
/**
* 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
@ -268,7 +269,8 @@ typedef struct config_deprecation_t {
* For example, to declare "NumCpu" as an abbreviation for "NumCPUs",
* 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

View File

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

View File

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

View File

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