summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-12-06 12:58:33 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-12-11 17:37:46 +0100
commitd72958f09ce3718019992b7a117f112e38855b55 (patch)
tree5852547589a2eb48f48fb6913b87f1ed95d4a6d1
parent25d4435998d0446f7699e7ab0874c7a6f610ab58 (diff)
downloadsssd-d72958f09ce3718019992b7a117f112e38855b55.tar.gz
sssd-d72958f09ce3718019992b7a117f112e38855b55.tar.xz
sssd-d72958f09ce3718019992b7a117f112e38855b55.zip
MONITOR: Disable inlining of function load_configuration
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 <mzidek@redhat.com>
-rw-r--r--src/monitor/monitor.c18
1 files changed, 12 insertions, 6 deletions
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));