Fixes minor issues

Fixes issues discovered by Coverity

plugins/baseldap.py:      possible undefined value in return
certmonger.py:            possible dereference of None value
i18n.py:                  fixed always True bug (+ cosmetic change)

https://fedorahosted.org/freeipa/ticket/5661

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Stanislav Laznicka 2016-02-02 12:57:11 +01:00 committed by Jan Cholasta
parent 9757384c7c
commit d7efd8a33a
3 changed files with 13 additions and 7 deletions

View File

@ -451,12 +451,12 @@ def remove_external_post_callback(ldap, dn, entry_attrs, failed, completed,
# Run through the failures and gracefully remove any member defined
# as an external member.
completed_external = 0
if memberattr in failed and membertype in failed[memberattr]:
entry_attrs_ = ldap.get_entry(dn, [externalattr])
dn = entry_attrs_.dn
external_entries = entry_attrs_.get(externalattr, [])
failed_entries = []
completed_external = 0
for entry in failed[memberattr][membertype]:
membername = entry[0].lower()

View File

@ -318,8 +318,11 @@ def request_cert(nssdb, nickname, subject, principal, passwd_fname=None):
if result[0]:
request = _cm_dbus_object(cm.bus, cm, result[1], DBUS_CM_REQUEST_IF,
DBUS_CM_IF, True)
except TypeError:
root_logger.error('Failed to get create new request.')
else:
raise RuntimeError('add_request() returned False')
except Exception as e:
root_logger.error('Failed to create a new request: {error}'
.format(error=e))
raise
return request.obj_if.get_nickname()
@ -356,8 +359,11 @@ def start_tracking(nickname, secdir, password_file=None, command=None):
if result[0]:
request = _cm_dbus_object(cm.bus, cm, result[1], DBUS_CM_REQUEST_IF,
DBUS_CM_IF, True)
except TypeError as e:
root_logger.error('Failed to add new request.')
else:
raise RuntimeError('add_request() returned False')
except Exception as e:
root_logger.error('Failed to add new request: {error}'
.format(error=e))
raise
return request.prop_if.Get(DBUS_CM_REQUEST_IF, 'nickname')

View File

@ -755,7 +755,7 @@ def main():
print('ERROR: no mode specified', file=sys.stderr)
return 1
if options.mode == 'validate_pot' or options.mode == 'validate_po':
if options.mode in ('validate_pot', 'validate_po'):
if options.mode == 'validate_pot':
files = args
if not files:
@ -795,7 +795,7 @@ def main():
else:
return 0
elif options.mode == 'create_test' or 'test_gettext':
elif options.mode in ('create_test', 'test_gettext'):
po_file = '%s.po' % options.test_lang
pot_file = options.pot_file