From eef03d70c1bedb3aabd4e2bcf10ab1f2678443bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 6 Mar 2018 09:37:11 +0100 Subject: [PATCH 1/2] basic/cgroup-util: remove unused variable --- src/basic/cgroup-util.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 9a4dd722700..c0962f288f3 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -2038,7 +2038,6 @@ int cg_get_keyed_attribute( char **ret_values) { _cleanup_free_ char *filename = NULL, *contents = NULL; - _cleanup_fclose_ FILE *f = NULL; const char *p; size_t n, i, n_done = 0; char **v; From f6a8265b9a00a0a9232bfaf0cd5d3962fbc4700a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 6 Mar 2018 09:34:03 +0100 Subject: [PATCH 2/2] core: drop unnecessary __useless_struct_to_allow_trailing_semicolon__ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ISO C does not allow empty statements outside of functions, and gcc will warn the trailing semicolons when compiling with -pedantic: warning: ISO C does not allow extra ‘;’ outside of a function [-Wpedantic] But our code cannot compile with -pedantic anyway, at least because warning: ISO C does not support ‘__PRETTY_FUNCTION__’ predefined identifier [-Wpedantic] Without -pedatnic, clang and even old gcc (3.4) generate no warnings about those semicolons, so let's just drop __useless_struct_to_allow_trailing_semicolon__. --- src/basic/macro.h | 3 +-- src/basic/nss-util.h | 6 ++---- src/basic/string-table.h | 9 +++------ src/basic/terminal-util.h | 7 ++----- src/core/dbus-util.h | 27 +++++++++------------------ src/shared/bus-unit-util.c | 6 ++---- src/shared/bus-util.h | 3 +-- src/shared/conf-parser.c | 3 +-- 8 files changed, 21 insertions(+), 43 deletions(-) diff --git a/src/basic/macro.h b/src/basic/macro.h index 89bdd852a94..95be63a2040 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -428,7 +428,6 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) { static inline void func##p(type *p) { \ if (*p) \ func(*p); \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #include "log.h" diff --git a/src/basic/nss-util.h b/src/basic/nss-util.h index 4fc676395f7..92f7d51d29a 100644 --- a/src/basic/nss-util.h +++ b/src/basic/nss-util.h @@ -116,8 +116,7 @@ enum nss_status _nss_##module##_gethostbyname_r( \ NULL, \ NULL); \ return ret; \ -} \ -struct __useless_struct_to_allow_trailing_semicolon__ +} #define NSS_GETHOSTBYADDR_FALLBACKS(module) \ enum nss_status _nss_##module##_gethostbyaddr_r( \ @@ -133,8 +132,7 @@ enum nss_status _nss_##module##_gethostbyaddr_r( \ buffer, buflen, \ errnop, h_errnop, \ NULL); \ -} \ -struct __useless_struct_to_allow_trailing_semicolon__ +} #define NSS_GETPW_PROTOTYPES(module) \ enum nss_status _nss_##module##_getpwnam_r( \ diff --git a/src/basic/string-table.h b/src/basic/string-table.h index 4306b90f46d..e78a6dbdef1 100644 --- a/src/basic/string-table.h +++ b/src/basic/string-table.h @@ -93,13 +93,11 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k #define _DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \ _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \ - _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) \ - struct __useless_struct_to_allow_trailing_semicolon__ + _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING(name,type,scope) #define _DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(name,type,yes,scope) \ _DEFINE_STRING_TABLE_LOOKUP_TO_STRING(name,type,scope) \ - _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(name,type,yes,scope) \ - struct __useless_struct_to_allow_trailing_semicolon__ + _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(name,type,yes,scope) #define DEFINE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,) #define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) _DEFINE_STRING_TABLE_LOOKUP(name,type,static) @@ -111,8 +109,7 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k /* For string conversions where numbers are also acceptable */ #define DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(name,type,max) \ _DEFINE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(name,type,max,) \ - _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_FALLBACK(name,type,max,) \ - struct __useless_struct_to_allow_trailing_semicolon__ + _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_FALLBACK(name,type,max,) #define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(name,type,max) \ _DEFINE_STRING_TABLE_LOOKUP_TO_STRING_FALLBACK(name,type,max,static) diff --git a/src/basic/terminal-util.h b/src/basic/terminal-util.h index b57157e3bbf..e92b6987e8f 100644 --- a/src/basic/terminal-util.h +++ b/src/basic/terminal-util.h @@ -133,16 +133,13 @@ bool dev_console_colors_enabled(void); #define DEFINE_ANSI_FUNC(name, NAME) \ static inline const char *ansi_##name(void) { \ return colors_enabled() ? ANSI_##NAME : ""; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define DEFINE_ANSI_FUNC_UNDERLINE(name, NAME, REPLACEMENT) \ static inline const char *ansi_##name(void) { \ return underline_enabled() ? ANSI_##NAME : \ colors_enabled() ? ANSI_##REPLACEMENT : ""; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ - + } DEFINE_ANSI_FUNC(highlight, HIGHLIGHT); DEFINE_ANSI_FUNC(highlight_red, HIGHLIGHT_RED); diff --git a/src/core/dbus-util.h b/src/core/dbus-util.h index 8260298577a..ab8ba9dd28b 100644 --- a/src/core/dbus-util.h +++ b/src/core/dbus-util.h @@ -48,8 +48,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_TRANSIENT_IS_VALID(function, bus_type, type, cast_type, fmt, check) \ int bus_set_transient_##function( \ @@ -80,8 +79,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_TRANSIENT_TO_STRING(function, bus_type, type, cast_type, fmt, to_string) \ int bus_set_transient_##function( \ @@ -114,8 +112,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(function, bus_type, type, cast_type, fmt, to_string) \ int bus_set_transient_##function( \ @@ -150,8 +147,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_TRANSIENT_PARSE(function, type, parse) \ int bus_set_transient_##function( \ @@ -184,8 +180,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(function, type, parse) \ int bus_set_transient_##function( \ @@ -218,8 +213,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(function, check) \ int bus_set_transient_##function( \ @@ -253,8 +247,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_CGROUP_WEIGHT(function, mask, check, val, str) \ int bus_cgroup_set_##function( \ @@ -291,8 +284,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_DEFINE_SET_CGROUP_SCALE(function, mask, scale) \ int bus_cgroup_set_##function##_scale( \ @@ -333,8 +325,7 @@ } \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } int bus_set_transient_mode_t(Unit *u, const char *name, mode_t *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error); int bus_set_transient_unsigned(Unit *u, const char *name, unsigned *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error); diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 54b2137c9c0..23e05daf48c 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -91,8 +91,7 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) { return bus_log_create_error(r); \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define DEFINE_BUS_APPEND_PARSE(bus_type, parse_func) \ static int bus_append_##parse_func( \ @@ -113,8 +112,7 @@ int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) { return bus_log_create_error(r); \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } DEFINE_BUS_APPEND_PARSE("b", parse_boolean); DEFINE_BUS_APPEND_PARSE("i", ioprio_class_from_string); diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index 969a444d838..8103f0e9a7f 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -150,8 +150,7 @@ int bus_log_create_error(int r); return r; \ \ return 1; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } #define BUS_PROPERTY_DUAL_TIMESTAMP(name, offset, flags) \ SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \ diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 15cfe4e4f71..eac1176556c 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -515,8 +515,7 @@ int config_parse_many( #type, rvalue); \ \ return 0; \ - } \ - struct __useless_struct_to_allow_trailing_semicolon__ + } DEFINE_PARSER(int, int, safe_atoi); DEFINE_PARSER(long, long, safe_atoli);