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 0accf8ccb6
commit 9757384c7c
5 changed files with 5 additions and 6 deletions

View File

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

View File

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

View File

@@ -288,7 +288,7 @@ class LdapKeyDB(AbstractHSM):
for attr in default_attrs: for attr in default_attrs:
key.setdefault(attr, default_attrs[attr]) 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'] 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 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 assert 'ipk11label' in key, 'key "%s" is missing ipk11Label' % key.entry.dn

View File

@@ -87,6 +87,8 @@ class AutomountTest(XMLRPC_test):
break break
else: else:
current_file.write(line + '\n') 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() current_file.close()
self.failsafe_add(api.Object.automountlocation, self.locname) self.failsafe_add(api.Object.automountlocation, self.locname)

View File

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