summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2016-06-16 17:40:50 +0200
committerLukas Slebodnik <lslebodn@redhat.com>2016-06-29 12:18:57 +0200
commitb54cd7caf6b73b36b68fcefc0cad39a626690398 (patch)
tree54e2e842cde33274d15b6554b144282ba33fa005 /src/util
parentbdadcaf271818e88e56e86c2bd90663a08fd9721 (diff)
downloadsssd-b54cd7caf6b73b36b68fcefc0cad39a626690398.tar.gz
sssd-b54cd7caf6b73b36b68fcefc0cad39a626690398.tar.xz
sssd-b54cd7caf6b73b36b68fcefc0cad39a626690398.zip
Downcast to errno_t after tevent_req_is_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. Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/util/util.h b/src/util/util.h
index d36bb6086..a8b4776be 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 ERR_INTERNAL; \
+ } \
return TRROEerr; \
} \
return ERR_INTERNAL; \