From 0c16d2eefbc6ac8331078a4cdcecfee817a71bc6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 5 Mar 2013 10:12:10 -0500 Subject: Improve IS_SSSD_ERROR() macro We need to mask the first part with 0xFFFF or there is a slight chance an unrelated error code would match even if the upper part is not exactly equal to ERR_BASE but just has all it's bits and some more. Also make the macro more reasable by adding another helper macro for filtering the base. Finally compare err and ERR_LAST directly w/o masking err, or the comparison will always return true. --- src/util/util_errors.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/util_errors.h b/src/util/util_errors.h index 9292c995..91fea176 100644 --- a/src/util/util_errors.h +++ b/src/util/util_errors.h @@ -62,10 +62,10 @@ enum sssd_errors { ERR_LAST /* ALWAYS LAST */ }; +#define SSSD_ERR_BASE(err) ((err) & ~ERR_MASK) #define SSSD_ERR_IDX(err) ((err) & ERR_MASK) #define IS_SSSD_ERROR(err) \ - ((((err) & ERR_BASE) == ERR_BASE) && \ - SSSD_ERR_IDX(err) < ERR_LAST) + ((SSSD_ERR_BASE(err) == ERR_BASE) && ((err) < ERR_LAST)) #define ERR_OK 0 /* Backwards compat */ -- cgit