From d72958f09ce3718019992b7a117f112e38855b55 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Sat, 6 Dec 2014 12:58:33 +0100 Subject: MONITOR: Disable inlining of function load_configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit cff89439b21f8573c6896b09cb1a8d5f9de3144c. The previous fix was not sufficient and similar warning appears after different change in function load_configuration. src/monitor/monitor.c: In function ‘main’: src/monitor/monitor.c:2962:24: error: ‘monitor’ may be used uninitialized in this function [-Werror=maybe-uninitialized] monitor->is_daemon = !opt_interactive; ^ cc1: all warnings being treated as errors It's better to disable optimisation of function load_configuration after fail in chown(unlink) instead of checking errno for 0 and overriding it with EINVAL. Reviewed-by: Michal Židek --- src/monitor/monitor.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/monitor') diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index c6834a115..c63206b78 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -1648,9 +1648,17 @@ static int monitor_ctx_destructor(void *mem) return 0; } -static errno_t load_configuration(TALLOC_CTX *mem_ctx, - const char *config_file, - struct mt_ctx **monitor) +/* + * This function should not be static otherwise gcc does some special kind of + * optimisations which should not happen according to code: chown (unlink) + * failed (return -1) but errno was zero. + * As a result of this * warning is printed ‘monitor’ may be used + * uninitialized in this function. Instead of checking errno for 0 + * it's better to disable optimisation(in-lining) of this function. + */ +errno_t load_configuration(TALLOC_CTX *mem_ctx, + const char *config_file, + struct mt_ctx **monitor) { errno_t ret; struct mt_ctx *ctx; @@ -1730,9 +1738,7 @@ static errno_t load_configuration(TALLOC_CTX *mem_ctx, * when SSSD runs as nonroot */ ret = chown(cdb_file, ctx->uid, ctx->gid); if (ret != 0) { - /* Init ret to suppress gcc warning with high -O level */ - ret = EINVAL; - if (errno) ret = errno; + ret = errno; DEBUG(SSSDBG_FATAL_FAILURE, "chown failed for [%s]: [%d][%s].\n", cdb_file, ret, sss_strerror(ret)); -- cgit