Cosmetic changes to the code

Fixes some Coverity issues

ipadiscovery.py:          added assert should universe break
plugins/dns.py:           removed dead code
dnssec/ldapkeydb.py:      attribute assert in the proper object
test_automount_plugin.py: fixed possible close() on None
xmlrpc_test.py:           Coverity does not like accessing None.__class__

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:50:26 +01:00
committed by Jan Cholasta
parent 4734012c80
commit 61407ddb57
5 changed files with 5 additions and 6 deletions

View File

@@ -404,7 +404,7 @@ class IPADiscovery(object):
return [0, thost, lrealms[0]]
#we shouldn't get here
return [UNKNOWN_ERROR]
assert False, "Unknown error in ipadiscovery"
except errors.DatabaseTimeout:
root_logger.debug("LDAP Error: timeout")

View File

@@ -789,9 +789,6 @@ class DNSRecord(Str):
if value is None:
return
if value is None:
return
if not self.supported:
return _('DNS RR type "%s" is not supported by bind-dyndb-ldap plugin') \
% self.rrtype

View File

@@ -293,7 +293,7 @@ class LdapKeyDB(AbstractHSM):
for attr in default_attrs:
key.setdefault(attr, default_attrs[attr])
assert 'ipk11id' in o, 'key is missing ipk11Id in %s' % key.entry.dn
assert 'ipk11id' in key, 'key is missing ipk11Id in %s' % key.entry.dn
key_id = key['ipk11id']
assert key_id not in keys, 'duplicate ipk11Id=0x%s in "%s" and "%s"' % (hexlify(key_id), key.entry.dn, keys[key_id].entry.dn)
assert 'ipk11label' in key, 'key "%s" is missing ipk11Label' % key.entry.dn

View File

@@ -89,6 +89,8 @@ class AutomountTest(XMLRPC_test):
break
else:
current_file.write(line + '\n')
assert current_file is not None, ('The input file does not contain any'
'records of files to be opened.')
current_file.close()
self.failsafe_add(api.Object.automountlocation, self.locname)

View File

@@ -358,7 +358,7 @@ class Declarative(XMLRPC_test):
if not expected(e, output):
raise AssertionError(
UNEXPECTED % (cmd, name, args, options,
e.__class__.__name__, e)
type(e).__name__, e)
)
def check_output(self, nice, cmd, args, options, expected, extra_check):