diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2015-11-19 14:17:36 +0000 |
---|---|---|
committer | Lukas Slebodnik <lslebodn@redhat.com> | 2016-01-29 09:32:18 +0100 |
commit | f47a339d7794cd5a24d368b3b3640452686e45a5 (patch) | |
tree | 21bb397fe92e85348b2c9d3a7862675a79c9bec6 /src/python | |
parent | 2ff8131cf02decaf0dd0754e843732fe7774fc59 (diff) | |
download | sssd-f47a339d7794cd5a24d368b3b3640452686e45a5.tar.gz sssd-f47a339d7794cd5a24d368b3b3640452686e45a5.tar.xz sssd-f47a339d7794cd5a24d368b3b3640452686e45a5.zip |
pyhbac: Fix warning Wsign-compare
src/python/pyhbac.c: In function ‘HbacRuleElement_repr’:
src/python/pyhbac.c:506:59: error: comparison between
signed and unsigned integer expressions [-Werror=sign-compare]
if (strnames == NULL || strgroups == NULL || category == -1) {
^
src/python/pyhbac.c: In function ‘HbacRuleElement_to_native’:
src/python/pyhbac.c:614:51: error: comparison between
signed and unsigned integer expressions [-Werror=sign-compare]
if (!el->names || !el->groups || el->category == -1) {
^
The static function native_category had type of terurn value uint32_t
But it also could return -1 which indicated an error.
It's better to don't mix return code with returned value.
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/python')
-rw-r--r-- | src/python/pyhbac.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/python/pyhbac.c b/src/python/pyhbac.c index fca476c56..820ef11b5 100644 --- a/src/python/pyhbac.c +++ b/src/python/pyhbac.c @@ -191,8 +191,8 @@ pyobject_to_category(PyObject *o) return -1; } -static uint32_t -native_category(PyObject *pycat) +static int +native_category(PyObject *pycat, uint32_t *_category) { PyObject *iterator; PyObject *item; @@ -218,7 +218,9 @@ native_category(PyObject *pycat) } Py_DECREF(iterator); - return cat; + + *_category = cat; + return 0; } static char * @@ -491,6 +493,7 @@ HbacRuleElement_repr(HbacRuleElement *self) char *strnames = NULL; char *strgroups = NULL; uint32_t category; + int ret; PyObject *o, *format, *args; format = PyUnicode_FromString("<category %lu names [%s] groups [%s]>"); @@ -502,8 +505,8 @@ HbacRuleElement_repr(HbacRuleElement *self) discard_const_p(char, ",")); strgroups = str_concat_sequence(self->groups, discard_const_p(char, ",")); - category = native_category(self->category); - if (strnames == NULL || strgroups == NULL || category == -1) { + ret = native_category(self->category, &category); + if (strnames == NULL || strgroups == NULL || ret == -1) { PyMem_Free(strnames); PyMem_Free(strgroups); Py_DECREF(format); @@ -592,6 +595,7 @@ struct hbac_rule_element * HbacRuleElement_to_native(HbacRuleElement *pyel) { struct hbac_rule_element *el = NULL; + int ret; /* check the type, None would wreak havoc here because for some reason * it would pass the sequence check */ @@ -608,10 +612,10 @@ HbacRuleElement_to_native(HbacRuleElement *pyel) goto fail; } - el->category = native_category(pyel->category); + ret = native_category(pyel->category, &el->category); el->names = sequence_as_string_list(pyel->names, "names"); el->groups = sequence_as_string_list(pyel->groups, "groups"); - if (!el->names || !el->groups || el->category == -1) { + if (!el->names || !el->groups || ret == -1) { goto fail; } |