From 70cca70f523cf4d9734e657a2157fbb27fff7a60 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Sat, 24 Aug 2013 18:02:42 +0100 Subject: [PATCH] Move the stringify macros to build.h --- src/include/build.h | 9 +++++++-- src/include/conffile.h | 4 ---- src/main/detail.c | 6 +++--- src/main/mainconfig.c | 14 +++++++------- src/main/realms.c | 14 +++++++------- src/main/xlat.c | 4 ++-- src/modules/rlm_perl/rlm_perl.c | 4 ++-- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/include/build.h b/src/include/build.h index 694b53fc33..403965d4cb 100644 --- a/src/include/build.h +++ b/src/include/build.h @@ -9,11 +9,16 @@ extern "C" { #endif +/* + * The ubiquitous stringify macros + */ +#define XSTRINGIFY(x) #x +#define STRINGIFY(x) XSTRINGIFY(x) + /* * Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8 */ -#define DIAG_STR(s) #s -#define DIAG_JOINSTR(x,y) DIAG_STR(x ## y) +#define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y) #define DIAG_DO_PRAGMA(x) _Pragma (#x) #if defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402 diff --git a/src/include/conffile.h b/src/include/conffile.h index ca39293c12..f16ba26afe 100644 --- a/src/include/conffile.h +++ b/src/include/conffile.h @@ -47,10 +47,6 @@ typedef struct CONF_PARSER { const void *dflt; /* default as it would appear in radiusd.conf */ } CONF_PARSER; -/* This preprocessor trick will be useful in initializing CONF_PARSER struct */ -#define XStringify(x) #x -#define Stringify(x) XStringify(x) - CONF_SECTION *cf_section_alloc(CONF_SECTION *parent, char const *name1, char const *name2); int cf_pair_replace(CONF_SECTION *cs, CONF_PAIR *cp, diff --git a/src/main/detail.c b/src/main/detail.c index 59889528b2..9068e4ac71 100644 --- a/src/main/detail.c +++ b/src/main/detail.c @@ -835,11 +835,11 @@ static const CONF_PARSER detail_config[] = { { "filename", PW_TYPE_FILE_OUTPUT | PW_TYPE_REQUIRED, offsetof(listen_detail_t, filename), NULL, NULL }, { "load_factor", PW_TYPE_INTEGER, - offsetof(listen_detail_t, load_factor), NULL, Stringify(10)}, + offsetof(listen_detail_t, load_factor), NULL, STRINGIFY(10)}, { "poll_interval", PW_TYPE_INTEGER, - offsetof(listen_detail_t, poll_interval), NULL, Stringify(1)}, + offsetof(listen_detail_t, poll_interval), NULL, STRINGIFY(1)}, { "retry_interval", PW_TYPE_INTEGER, - offsetof(listen_detail_t, retry_interval), NULL, Stringify(30)}, + offsetof(listen_detail_t, retry_interval), NULL, STRINGIFY(30)}, { "one_shot", PW_TYPE_BOOLEAN, offsetof(listen_detail_t, one_shot), NULL, NULL}, { "max_outstanding", PW_TYPE_INTEGER, diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index 42d1981357..64115ea03e 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -102,8 +102,8 @@ static int do_colourise = false; * Security configuration for the server. */ static const CONF_PARSER security_config[] = { - { "max_attributes", PW_TYPE_INTEGER, 0, &fr_max_attributes, Stringify(0) }, - { "reject_delay", PW_TYPE_INTEGER, 0, &mainconfig.reject_delay, Stringify(0) }, + { "max_attributes", PW_TYPE_INTEGER, 0, &fr_max_attributes, STRINGIFY(0) }, + { "reject_delay", PW_TYPE_INTEGER, 0, &mainconfig.reject_delay, STRINGIFY(0) }, { "status_server", PW_TYPE_BOOLEAN, 0, &mainconfig.status_server, "no"}, { NULL, -1, 0, NULL, NULL } }; @@ -114,7 +114,7 @@ static const CONF_PARSER security_config[] = { */ static const CONF_PARSER logdest_config[] = { { "destination", PW_TYPE_STRING_PTR, 0, &radlog_dest, "files" }, - { "syslog_facility", PW_TYPE_STRING_PTR, 0, &syslog_facility, Stringify(0) }, + { "syslog_facility", PW_TYPE_STRING_PTR, 0, &syslog_facility, STRINGIFY(0) }, { "file", PW_TYPE_STRING_PTR, 0, &mainconfig.log_file, "${logdir}/radius.log" }, { "requests", PW_TYPE_STRING_PTR, 0, &default_log.file, NULL }, @@ -165,11 +165,11 @@ static const CONF_PARSER server_config[] = { { "libdir", PW_TYPE_STRING_PTR, 0, &radlib_dir, "${prefix}/lib"}, { "radacctdir", PW_TYPE_STRING_PTR, 0, &radacct_dir, "${logdir}/radacct" }, { "hostname_lookups", PW_TYPE_BOOLEAN, 0, &fr_dns_lookups, "no" }, - { "max_request_time", PW_TYPE_INTEGER, 0, &mainconfig.max_request_time, Stringify(MAX_REQUEST_TIME) }, - { "cleanup_delay", PW_TYPE_INTEGER, 0, &mainconfig.cleanup_delay, Stringify(CLEANUP_DELAY) }, - { "max_requests", PW_TYPE_INTEGER, 0, &mainconfig.max_requests, Stringify(MAX_REQUESTS) }, + { "max_request_time", PW_TYPE_INTEGER, 0, &mainconfig.max_request_time, STRINGIFY(MAX_REQUEST_TIME) }, + { "cleanup_delay", PW_TYPE_INTEGER, 0, &mainconfig.cleanup_delay, STRINGIFY(CLEANUP_DELAY) }, + { "max_requests", PW_TYPE_INTEGER, 0, &mainconfig.max_requests, STRINGIFY(MAX_REQUESTS) }, #ifdef DELETE_BLOCKED_REQUESTS - { "delete_blocked_requests", PW_TYPE_INTEGER, 0, &mainconfig.kill_unresponsive_children, Stringify(false) }, + { "delete_blocked_requests", PW_TYPE_INTEGER, 0, &mainconfig.kill_unresponsive_children, STRINGIFY(false) }, #endif { "pidfile", PW_TYPE_STRING_PTR, 0, &mainconfig.pid_file, "${run_dir}/radiusd.pid"}, { "checkrad", PW_TYPE_STRING_PTR, 0, &mainconfig.checkrad, "${sbindir}/checkrad" }, diff --git a/src/main/realms.c b/src/main/realms.c index 1bd67c8e41..d0913ab1c5 100644 --- a/src/main/realms.c +++ b/src/main/realms.c @@ -70,11 +70,11 @@ static rbtree_t *home_pools_byname = NULL; static const CONF_PARSER proxy_config[] = { { "retry_delay", PW_TYPE_INTEGER, offsetof(realm_config_t, retry_delay), - NULL, Stringify(RETRY_DELAY) }, + NULL, STRINGIFY(RETRY_DELAY) }, { "retry_count", PW_TYPE_INTEGER, offsetof(realm_config_t, retry_count), - NULL, Stringify(RETRY_COUNT) }, + NULL, STRINGIFY(RETRY_COUNT) }, { "default_fallback", PW_TYPE_BOOLEAN, offsetof(realm_config_t, fallback), @@ -82,7 +82,7 @@ static const CONF_PARSER proxy_config[] = { { "dead_time", PW_TYPE_INTEGER, offsetof(realm_config_t, dead_time), - NULL, Stringify(DEAD_TIME) }, + NULL, STRINGIFY(DEAD_TIME) }, { "wake_all_if_all_dead", PW_TYPE_BOOLEAN, offsetof(realm_config_t, wake_all_if_all_dead), @@ -307,13 +307,13 @@ static char *hs_proto = NULL; #ifdef WITH_COA static CONF_PARSER home_server_coa[] = { { "irt", PW_TYPE_INTEGER, - offsetof(home_server, coa_irt), 0, Stringify(2) }, + offsetof(home_server, coa_irt), 0, STRINGIFY(2) }, { "mrt", PW_TYPE_INTEGER, - offsetof(home_server, coa_mrt), 0, Stringify(16) }, + offsetof(home_server, coa_mrt), 0, STRINGIFY(16) }, { "mrc", PW_TYPE_INTEGER, - offsetof(home_server, coa_mrc), 0, Stringify(5) }, + offsetof(home_server, coa_mrc), 0, STRINGIFY(5) }, { "mrd", PW_TYPE_INTEGER, - offsetof(home_server, coa_mrd), 0, Stringify(30) }, + offsetof(home_server, coa_mrd), 0, STRINGIFY(30) }, { NULL, -1, 0, NULL, NULL } /* end the list */ }; diff --git a/src/main/xlat.c b/src/main/xlat.c index 9434185f36..0d5745dd98 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -449,8 +449,8 @@ int xlat_register(char const *name, RAD_XLAT_FUNC func, RADIUS_ESCAPE_STRING esc } #endif -#define XLAT_REGISTER(_x) xlat_register(Stringify(_x), xlat_ ## _x, NULL, NULL); \ - c = xlat_find(Stringify(_x)); \ +#define XLAT_REGISTER(_x) xlat_register(STRINGIFY(_x), xlat_ ## _x, NULL, NULL); \ + c = xlat_find(STRINGIFY(_x)); \ rad_assert(c != NULL); \ c->internal = true diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index e4bed0f2d4..7b46f7b54f 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -80,8 +80,8 @@ typedef struct rlm_perl_t { /* * A mapping of configuration file names to internal variables. */ -#define RLM_PERL_CONF(_x) { "func_" Stringify(_x), PW_TYPE_STRING_PTR, \ - offsetof(rlm_perl_t,func_##_x), NULL, Stringify(_x)} +#define RLM_PERL_CONF(_x) { "func_" STRINGIFY(_x), PW_TYPE_STRING_PTR, \ + offsetof(rlm_perl_t,func_##_x), NULL, STRINGIFY(_x)} static const CONF_PARSER module_config[] = { { "module", PW_TYPE_FILE_INPUT | PW_TYPE_DEPRECATED, -- 2.47.3