diff options
author | Simo Sorce <simo@redhat.com> | 2013-03-05 10:12:10 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-03-05 18:52:22 +0100 |
commit | 0c16d2eefbc6ac8331078a4cdcecfee817a71bc6 (patch) | |
tree | e670967d771738bb2f1cb991d68c366e824325b9 | |
parent | 2ba16c5a5c4b6d3cd2a44179186ec60eda828bcd (diff) | |
download | sssd-0c16d2eefbc6ac8331078a4cdcecfee817a71bc6.tar.gz sssd-0c16d2eefbc6ac8331078a4cdcecfee817a71bc6.tar.bz2 sssd-0c16d2eefbc6ac8331078a4cdcecfee817a71bc6.zip |
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.
-rw-r--r-- | src/util/util_errors.h | 4 |
1 files 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 */ |