summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-03-05 10:12:10 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-03-05 18:52:22 +0100
commit0c16d2eefbc6ac8331078a4cdcecfee817a71bc6 (patch)
treee670967d771738bb2f1cb991d68c366e824325b9 /src
parent2ba16c5a5c4b6d3cd2a44179186ec60eda828bcd (diff)
downloadsssd-0c16d2eefbc6ac8331078a4cdcecfee817a71bc6.tar.gz
sssd-0c16d2eefbc6ac8331078a4cdcecfee817a71bc6.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/util/util_errors.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/util_errors.h b/src/util/util_errors.h
index 9292c9959..91fea1766 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 */