[SSSD] [PATCH] IFP: cached objects
Lukas Slebodnik
lslebodn at redhat.com
Tue Jun 2 12:17:55 UTC 2015
On (02/06/15 11:18), Pavel Březina wrote:
>On 05/26/2015 05:22 PM, Jakub Hrozek wrote:
>>There is a compilation warning discovered by Coverity:
It is gcc-5.1 warning and not coverity
I can see them as well.
>>Error: COMPILER_WARNING:
>>sssd-1.12.90/src/responder/ifp/ifp_cache.c:118:13: warning: 'base_dn' may be used uninitialized in this function [-Wmaybe-uninitialized]
>># 116| }
>># 117|
>># 118|-> ldb_ret = ldb_search(sysdb_ctx_get_ldb(domain->sysdb), tmp_ctx, &result,
>># 119| base_dn, LDB_SCOPE_SUBTREE, attrs,
>># 120| "(&(objectClass=%s)(%s=TRUE))", class, SYSDB_CACHED);
>>
>>Error: COMPILER_WARNING:
>>sssd-1.12.90/src/responder/ifp/ifp_cache.c:118:13: warning: 'class' may be used uninitialized in this function [-Wmaybe-uninitialized]
>># ldb_ret = ldb_search(sysdb_ctx_get_ldb(domain->sysdb), tmp_ctx, &result,
>># ^
>># 116| }
>># 117|
>># 118|-> ldb_ret = ldb_search(sysdb_ctx_get_ldb(domain->sysdb), tmp_ctx, &result,
>># 119| base_dn, LDB_SCOPE_SUBTREE, attrs,
>># 120| "(&(objectClass=%s)(%s=TRUE))", class, SYSDB_CACHED);
>>
>>Error: COMPILER_WARNING:
>>sssd-1.12.90/src/responder/ifp/ifp_cache.c: scope_hint: In function 'ifp_cache_get_cached_objects'
>>sssd-1.12.90/src/responder/ifp/ifp_cache.c:134:18: warning: 'path' may be used uninitialized in this function [-Wmaybe-uninitialized]
>># paths[i] = ifp_cache_build_path(paths, type, domain, result->msgs[i]);
>># ^
>># 132|
>># 133| for (i = 0; i < result->count; i++) {
>># 134|-> paths[i] = ifp_cache_build_path(paths, type, domain, result->msgs[i]);
>># 135| if (paths[i] == NULL) {
>># 136| ret = ENOMEM;
>
>I don't see how those warning happends... base_dn, class and paths is
>initialized.
It seems that gcc 5.1 optimize enum in some ways
and expects that functions ifp_cache_build_path and ifp_cache_build_base_dn
can return unitialized value.
If you do not wan to add Defualt to switch then you can initialize
local variabels in these functions.
diff --git a/src/responder/ifp/ifp_cache.c b/src/responder/ifp/ifp_cache.c
index 4e5f59c..949c3f9 100644
--- a/src/responder/ifp/ifp_cache.c
+++ b/src/responder/ifp/ifp_cache.c
@@ -34,7 +34,7 @@ ifp_cache_build_base_dn(TALLOC_CTX *mem_ctx,
enum ifp_cache_type type,
struct sss_domain_info *domain)
{
- struct ldb_dn *base_dn;
+ struct ldb_dn *base_dn = NULL;
switch (type) {
case IFP_CACHE_USER:
@@ -54,7 +54,7 @@ ifp_cache_build_path(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
struct ldb_message *msg)
{
- char *path;
+ char *path = NULL;
switch (type) {
case IFP_CACHE_USER:
LS
More information about the sssd-devel
mailing list