[SSSD] [PATCH] IFP: Suppress warning from static analyzer

Lukas Slebodnik lslebodn at redhat.com
Thu Sep 24 07:36:02 UTC 2015


On (23/09/15 21:18), Jakub Hrozek wrote:
>On Wed, Sep 23, 2015 at 09:00:04PM +0200, Pavel Březina wrote:
>> On 09/23/2015 01:29 PM, Lukas Slebodnik wrote:
>> >ehlo,
>> >
>> >simple patch is attached.
>> >
>> >LS
>> 
>> >-    if (errno != 0) {
>> >-        ret = errno;
>> >+    ret = errno;
>> >+    if (ret != 0) {
>> >         goto done;
>> >     }
>> 
>> Hi,
>> if we are checking ret, it may be nicer to test against EOK since that is
>> what we usually do with this name.
Updated version is attached.

>We might even go one step further (in master, when we release 1.13.1)
>and just convert the function to return a result and error code
>separately:
>    ret = strtouint32(val, &ret);
It should not be a problem.

LS
-------------- next part --------------
>From a008ec0c232e6ad1f42b8343ffc592c8b535ff60 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn at redhat.com>
Date: Wed, 23 Sep 2015 13:24:53 +0200
Subject: [PATCH] IFP: Suppress warning from static analyzer

It seems that clang expected that errno can change to 0
in case of error. It might be a bug in static analyzer.
But the workaround does not change the logic and
the errno is read just once.
---
 src/responder/ifp/ifp_groups.c | 4 ++--
 src/responder/ifp/ifp_users.c  | 4 ++--
 src/responder/ifp/ifpsrv.c     | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/responder/ifp/ifp_groups.c b/src/responder/ifp/ifp_groups.c
index 3060035924026641cc245f2a1970db9e2646e11c..d5d7324da05d34580d346c590067d47831d2483a 100644
--- a/src/responder/ifp/ifp_groups.c
+++ b/src/responder/ifp/ifp_groups.c
@@ -68,8 +68,8 @@ static errno_t ifp_groups_decompose_path(struct sss_domain_info *domains,
     }
 
     gid = strtouint32(parts[1], NULL, 10);
-    if (errno != 0) {
-        ret = errno;
+    ret = errno;
+    if (ret != EOK) {
         goto done;
     }
 
diff --git a/src/responder/ifp/ifp_users.c b/src/responder/ifp/ifp_users.c
index effefdc0435d794206dbe7358c61d2ea47760361..9b71a3538db01ebd5ca622f382d253d1fe3fac85 100644
--- a/src/responder/ifp/ifp_users.c
+++ b/src/responder/ifp/ifp_users.c
@@ -70,8 +70,8 @@ static errno_t ifp_users_decompose_path(struct sss_domain_info *domains,
     }
 
     uid = strtouint32(parts[1], NULL, 10);
-    if (errno != 0) {
-        ret = errno;
+    ret = errno;
+    if (ret != EOK) {
         goto done;
     }
 
diff --git a/src/responder/ifp/ifpsrv.c b/src/responder/ifp/ifpsrv.c
index cdc411faa330dc2c063e52abe63cd68dbe16a5d9..83e5ad3959aa75758402cb85b69bbc30fd4e5706 100644
--- a/src/responder/ifp/ifpsrv.c
+++ b/src/responder/ifp/ifpsrv.c
@@ -338,8 +338,8 @@ int ifp_process_init(TALLOC_CTX *mem_ctx,
 
     if (wildcard_limit_str) {
         ifp_ctx->wildcard_limit = strtouint32(wildcard_limit_str, NULL, 10);
-        if (errno != 0) {
-            ret = errno;
+        ret = errno;
+        if (ret != EOK) {
             goto fail;
         }
     }
-- 
2.5.0



More information about the sssd-devel mailing list