ehlo,

attached is a patch for TEVENT_REQ_RETURN_ON_ERROR
which was discussed in dp_provider related thread.

It "fixes" 6 clang warnings
and 150 UNINIT from coverity (visible only in --agresive mode)

BTW feel fre to prose different error code
for result of down casting == 0.
It should not happen but one never knows.

LS
>From 4b6c0813ea3d73ec54c5dc50eeb6031b50d2d732 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lsleb...@redhat.com>
Date: Thu, 16 Jun 2016 17:40:50 +0200
Subject: [PATCH] UTIL: Use errno_t in TEVENT_REQ_RETURN_ON_ERROR

Functions tevent_req_is_error and _tevent_req_error
use type uint64_t for error code.

SSSD uses errno_t which is an alias for int.
Therefore complier assumes that macro TEVENT_REQ_RETURN_ON_ERROR
can return 0 due to implicit down casting from uint64_t -> int.
This patch makes down casting explicit and returns EINVAL
if result of downcasting is 0.
---
 src/util/util.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/util/util.h b/src/util/util.h
index 
d36bb6086fa90dd5dcf10b5c31bc3f6fc1ad771c..9719e634220eaa8069f0f84acbc68c73c0ab6b0a
 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -112,10 +112,15 @@
 
 #define TEVENT_REQ_RETURN_ON_ERROR(req) do { \
     enum tevent_req_state TRROEstate; \
-    uint64_t TRROEerr; \
+    uint64_t TRROEuint64; \
+    errno_t TRROEerr; \
     \
-    if (tevent_req_is_error(req, &TRROEstate, &TRROEerr)) { \
+    if (tevent_req_is_error(req, &TRROEstate, &TRROEuint64)) { \
+        TRROEerr = (errno_t) TRROEuint64; \
         if (TRROEstate == TEVENT_REQ_USER_ERROR) { \
+            if (TRROEerr == 0) { \
+                return EINVAL; \
+            } \
             return TRROEerr; \
         } \
         return ERR_INTERNAL; \
-- 
2.7.4

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/sssd-devel@lists.fedorahosted.org

Reply via email to