[SSSD] [PATCH] MONITOR: Disable inlining of function load_configuration
Lukas Slebodnik
lslebodn at redhat.com
Mon Dec 8 09:35:15 UTC 2014
ehlo,
Michal tried to fix gcc warning im 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.
LS
-------------- next part --------------
>From b94b7fa6ba182f18b4c938ed1ae7d34969078f1c Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Sat, 6 Dec 2014 12:58:33 +0100
Subject: [PATCH 1/2] 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.
---
src/monitor/monitor.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index c6834a1159b393bedd7251d9c3d28d3326cdc547..c63206b78e0a845be4fdd54ccd672e0059826bfc 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));
--
2.1.0
More information about the sssd-devel
mailing list