URL: https://github.com/SSSD/sssd/pull/140 Author: lslebodn Title: #140: gcc7 related fixes Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/140/head:pr140 git checkout pr140
From 6f5f2bca8fa8169dabd2022207b273f0dfb88d97 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Mon, 30 Jan 2017 12:17:25 +0100 Subject: [PATCH 1/4] UTIL: Suppres implicit-fallthrough from gcc 7 Some kind of comments are recognized by gcc 7 but they are ignored with -Wimplicit-fallthrough=5 and only attributes disable the warning. --- configure.ac | 24 ++++++++++++++++++++++++ src/providers/fail_over.c | 1 + src/providers/ldap/sdap_idmap.c | 1 + src/responder/common/responder_dp.c | 1 + src/util/murmurhash3.c | 3 +++ 5 files changed, 30 insertions(+) diff --git a/configure.ac b/configure.ac index 2915046..d264abf 100644 --- a/configure.ac +++ b/configure.ac @@ -418,6 +418,30 @@ if test x"$sss_cv_attribute_warn_unused_result" = xyes ; then [whether compiler supports __attribute__((warn_unused_result))]) fi +SAFE_CFLAGS=$CFLAGS +CFLAGS="-Werror" +AC_CACHE_CHECK( + [whether compiler supports __attribute__((fallthrough))], + [sss_cv_attribute_fallthrough], + [AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [ __attribute__ ((fallthrough)); ]) + ],[ + sss_cv_attribute_fallthrough=yes + sss_cv_attribute_fallthrough_val="__attribute__ ((fallthrough))" + ],[ + sss_cv_attribute_fallthrough=no + sss_cv_attribute_fallthrough_val= + ]) + ]) +CFLAGS=$SAFE_CFLAGS + +AC_DEFINE_UNQUOTED( + [SSS_ATTRIBUTE_FALLTHROUGH], + [$sss_cv_attribute_fallthrough_val], + [__attribute__((fallthrough)) if supported]) + + PKG_CHECK_MODULES([CHECK], [check >= 0.9.5], [have_check=1], [have_check=]) if test x$have_check = x; then AC_MSG_WARN([Without the 'CHECK' libraries, you will be unable to run all tests in the 'make check' suite]) diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c index 7708409..aa0afa2 100644 --- a/src/providers/fail_over.c +++ b/src/providers/fail_over.c @@ -1284,6 +1284,7 @@ resolve_srv_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, * "server" might be invalid now if the SRV * query collapsed * */ + SSS_ATTRIBUTE_FALLTHROUGH; case SRV_NEUTRAL: /* Request SRV lookup */ if (server != NULL && server != state->meta) { /* A server created by expansion of meta server was marked as diff --git a/src/providers/ldap/sdap_idmap.c b/src/providers/ldap/sdap_idmap.c index b5dfc6c..0fda815 100644 --- a/src/providers/ldap/sdap_idmap.c +++ b/src/providers/ldap/sdap_idmap.c @@ -516,6 +516,7 @@ sdap_idmap_sid_to_unix(struct sdap_idmap_ctx *idmap_ctx, "sssd-ad(5) for an explanation of how to resolve this issue.\n", sid_str); /* Fall through intentionally */ + SSS_ATTRIBUTE_FALLTHROUGH; default: DEBUG(SSSDBG_MINOR_FAILURE, "Could not convert objectSID [%s] to a UNIX ID\n", diff --git a/src/responder/common/responder_dp.c b/src/responder/common/responder_dp.c index da67676..11eb47c 100644 --- a/src/responder/common/responder_dp.c +++ b/src/responder/common/responder_dp.c @@ -221,6 +221,7 @@ static int sss_dp_get_reply(DBusPendingCall *pending, DEBUG(SSSDBG_FATAL_FAILURE,"The Data Provider returned an error [%s]\n", dbus_message_get_error_name(reply)); /* Falling through to default intentionally*/ + SSS_ATTRIBUTE_FALLTHROUGH; default: /* * Timeout or other error occurred or something diff --git a/src/util/murmurhash3.c b/src/util/murmurhash3.c index 03d10ff..061e64e 100644 --- a/src/util/murmurhash3.c +++ b/src/util/murmurhash3.c @@ -90,14 +90,17 @@ uint32_t murmurhash3(const char *key, int len, uint32_t seed) switch (len & 3) { case 3: k1 ^= tail[2] << 16; + SSS_ATTRIBUTE_FALLTHROUGH; case 2: k1 ^= tail[1] << 8; + SSS_ATTRIBUTE_FALLTHROUGH; case 1: k1 ^= tail[0]; k1 *= c1; k1 = rotl(k1, 15); k1 *= c2; h1 ^= k1; + break; default: break; } From a8b509f9c3943f37139dbfa359ce8ee8b248d4b0 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Mon, 30 Jan 2017 12:49:13 +0100 Subject: [PATCH 2/4] pam_sss: Suppress warning format-truncation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit src/sss_client/pam_sss.c: In function ‘send_and_receive’: src/sss_client/pam_sss.c:742:39: error: ‘%.*s’ directive output between 0 and 18446744073709551615 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-truncation=] ret = snprintf(user_msg, bufsize, "%s%s%.*s", ^~~~~~~~~~ sssd/src/sss_client/pam_sss.c:742:39: note: assuming directive output of 4294967295 bytes --- src/sss_client/pam_sss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c index be697c7..b4175ae 100644 --- a/src/sss_client/pam_sss.c +++ b/src/sss_client/pam_sss.c @@ -689,7 +689,7 @@ static int user_info_account_expired(pam_handle_t *pamh, size_t buflen, ret = snprintf(user_msg, bufsize, "%s%s%.*s", EXP_ACC_MSG, msg_len > 0 ? SRV_MSG : "", - msg_len, + (int)msg_len, msg_len > 0 ? (char *)(buf + 2 * sizeof(uint32_t)) : "" ); if (ret < 0 || ret > bufsize) { D(("snprintf failed.")); @@ -744,7 +744,7 @@ static int user_info_chpass_error(pam_handle_t *pamh, size_t buflen, ret = snprintf(user_msg, bufsize, "%s%s%.*s", _("Password change failed. "), msg_len > 0 ? _("Server message: ") : "", - msg_len, + (int)msg_len, msg_len > 0 ? (char *)(buf + 2 * sizeof(uint32_t)) : "" ); if (ret < 0 || ret > bufsize) { D(("snprintf failed.")); From 989d0f2b3112c296fb54f93105203d6a0619c2a7 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Mon, 30 Jan 2017 12:55:59 +0100 Subject: [PATCH 3/4] TOOLS: Fix warning format-truncation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit src/tools/sss_groupshow.c: In function ‘print_group_info’: src/tools/sss_groupshow.c:612:22: error: ‘%d’ directive output truncated writing between 10 and 11 bytes into a region of size 7 [-Werror=format-truncation=] snprintf(fmt, 8, "%%%ds", level*PADDING_SPACES); ^~~~~~~ src/tools/sss_groupshow.c:612:22: note: using the range [-2147483648, 2147483647] for directive argument src/tools/sss_groupshow.c:612:5: note: ‘snprintf’ output between 13 and 14 bytes into a destination of size 8 snprintf(fmt, 8, "%%%ds", level*PADDING_SPACES); --- src/tools/sss_groupshow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c index 258d458..ac4c3dc 100644 --- a/src/tools/sss_groupshow.c +++ b/src/tools/sss_groupshow.c @@ -603,7 +603,7 @@ static int group_show_mpg(TALLOC_CTX *mem_ctx, /*==================The main program=================================== */ -static void print_group_info(struct group_info *g, int level) +static void print_group_info(struct group_info *g, unsigned level) { int i; char padding[512]; @@ -634,7 +634,7 @@ static void print_group_info(struct group_info *g, int level) printf(_("\n%1$sMember groups: "), padding); } -static void print_recursive(struct group_info **group_members, int level) +static void print_recursive(struct group_info **group_members, unsigned level) { int i; From eb1900dc19b381508b0250165739cad62e4d1472 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <lsleb...@redhat.com> Date: Mon, 30 Jan 2017 14:36:56 +0100 Subject: [PATCH 4/4] sssctl: Fix warning may be used uninitialized MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc 7 probably does some new optimisations which might cause few wariables to be uninitialized. src/tools/sssctl/sssctl_cache.c: In function ‘sssctl_print_object’: src/tools/sssctl/sssctl_cache.c:523:13: error: ‘dom’ may be used uninitialized in this function [-Werror=maybe-uninitialized] ret = info[i].attr_fn(tmp_ctx, entry, dom, info[i].attr, &value); ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/tools/sssctl/sssctl_cache.c:472:15: error: ‘entry’ may be used uninitialized in this function [-Werror=maybe-uninitialized] *_entry = talloc_steal(mem_ctx, entry); ^~~~~~~~~~~~ src/tools/sssctl/sssctl_cache.c:437:25: note: ‘entry’ was declared here struct sysdb_attrs *entry; ^~~~~ Another workaround would be to remove static modifier from function sssctl_find_object which probably prevents some inlinig + optimisation. --- src/tools/sssctl/sssctl_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/sssctl/sssctl_cache.c b/src/tools/sssctl/sssctl_cache.c index 59c8cb4..8f0fc28 100644 --- a/src/tools/sssctl/sssctl_cache.c +++ b/src/tools/sssctl/sssctl_cache.c @@ -434,8 +434,8 @@ static errno_t sssctl_fetch_object(TALLOC_CTX *mem_ctx, struct sss_domain_info **_dom) { TALLOC_CTX *tmp_ctx; - struct sysdb_attrs *entry; - struct sss_domain_info *dom; + struct sysdb_attrs *entry = NULL; + struct sss_domain_info *dom = NULL; const char **attrs; char *sanitized; errno_t ret;
_______________________________________________ sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org