Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored a11/master branch #1

Open
wants to merge 1 commit into
base: a11/master
Choose a base branch
from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Aug 5, 2022

Branch a11/master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the a11/master branch, then run:

git fetch origin sourcery/a11/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from ShelbyHell August 5, 2022 06:26
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

print('gen_version_h: processing [%s]' % version_makefile)
print(f'gen_version_h: processing [{version_makefile}]')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function gen_version_h refactored with the following changes:

Comment on lines -144 to +139
print('scan_arch_kbuild: processing [%s]' % arch_asm_kbuild)
print(f'scan_arch_kbuild: processing [{arch_asm_kbuild}]')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function scan_arch_kbuild refactored with the following changes:

Comment on lines -268 to +258
match = abi_re.match(generated)

if match:
abi = match.group(1)
if match := abi_re.match(generated):
abi = match[1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function gen_arch_headers refactored with the following changes:

Comment on lines -335 to +322
print('error: expected prefix [%s] on header [%s]' % (prefix, h))
print(f'error: expected prefix [{prefix}] on header [{h}]')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_headers_install refactored with the following changes:

Comment on lines -444 to +451
print('find_out: module_dir_sep [%s]' % module_dir_sep)
print('find_out: prefix_sep [%s]' % prefix_sep)
print(f'find_out: module_dir_sep [{module_dir_sep}]')
print(f'find_out: prefix_sep [{prefix_sep}]')

error_count = 0

for full_src in full_srcs:
if verbose:
print('find_out: full_src [%s]' % full_src)
print(f'find_out: full_src [{full_src}]')

if not full_src.startswith(module_dir_sep):
print('error: expected %s to start with %s' % (full_src, module_dir_sep))
print(f'error: expected {full_src} to start with {module_dir_sep}')
error_count += 1
continue

local_src = full_src[len(module_dir_sep):]

if verbose:
print('find_out: local_src [%s]' % local_src)
print(f'find_out: local_src [{local_src}]')

if not local_src.startswith(prefix_sep):
print('error: expected %s to start with %s' % (local_src, prefix_sep))
print(f'error: expected {local_src} to start with {prefix_sep}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_out refactored with the following changes:

Comment on lines -335 to +327
if (isinstance(child , nodes.comment)
or isinstance(child, nodes.system_message)):
if isinstance(child, (nodes.comment, nodes.system_message)):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ListTableBuilder.parseRowItem refactored with the following changes:

Comment on lines -43 to +71
f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h"
print "Writing file: " + f

p = open(f, 'w');
if not p:
tcm_mod_err("Unable to open file: " + f)

buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_tpg {\n"
buf += " /* FC lport target portal group tag for TCM */\n"
buf += " u16 lport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n"
buf += " struct " + fabric_mod_name + "_lport *lport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_lport {\n"
buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n"
buf += " u64 lport_wwpn;\n"
buf += " /* ASCII formatted WWPN for FC Target Lport */\n"
buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n"
buf += " struct se_wwn lport_wwn;\n"
buf += "};\n"

ret = p.write(buf)
if ret:
tcm_mod_err("Unable to write f: " + f)

p.close()
f = f"{fabric_mod_dir_var}/{fabric_mod_name}_base.h"
global fabric_mod_port
with open(f, 'w') as p:
if not p:
tcm_mod_err(f"Unable to open file: {f}")

buf = f"#define {fabric_mod_name.upper()}" + "_VERSION \"v0.1\"\n"
buf += f"#define {fabric_mod_name.upper()}" + "_NAMELEN 32\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_tpg {\n"
buf += " /* FC lport target portal group tag for TCM */\n"
buf += " u16 lport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n"
buf += " struct " + fabric_mod_name + "_lport *lport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_lport {\n"
buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n"
buf += " u64 lport_wwpn;\n"
buf += " /* ASCII formatted WWPN for FC Target Lport */\n"
buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n"
buf += " struct se_wwn lport_wwn;\n"
buf += "};\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_FC_include refactored with the following changes:

Comment on lines -87 to +110
f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h"
print "Writing file: " + f

p = open(f, 'w');
if not p:
tcm_mod_err("Unable to open file: " + f)

buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_tpg {\n"
buf += " /* SAS port target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += "struct " + fabric_mod_name + "_tport {\n"
buf += " /* Binary World Wide unique Port Name for SAS Target port */\n"
buf += " u64 tport_wwpn;\n"
buf += " /* ASCII formatted WWPN for SAS Target port */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

ret = p.write(buf)
if ret:
tcm_mod_err("Unable to write f: " + f)

p.close()
f = f"{fabric_mod_dir_var}/{fabric_mod_name}_base.h"
global fabric_mod_port
with open(f, 'w') as p:
if not p:
tcm_mod_err(f"Unable to open file: {f}")

buf = f"#define {fabric_mod_name.upper()}" + "_VERSION \"v0.1\"\n"
buf += f"#define {fabric_mod_name.upper()}" + "_NAMELEN 32\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_tpg {\n"
buf += " /* SAS port target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += f"struct {fabric_mod_name}" + "_tport {\n"
buf += " /* Binary World Wide unique Port Name for SAS Target port */\n"
buf += " u64 tport_wwpn;\n"
buf += " /* ASCII formatted WWPN for SAS Target port */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_SAS_include refactored with the following changes:

Comment on lines -130 to +147
f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h"
print "Writing file: " + f

p = open(f, 'w');
if not p:
tcm_mod_err("Unable to open file: " + f)

buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_tpg {\n"
buf += " /* iSCSI target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += "struct " + fabric_mod_name + "_tport {\n"
buf += " /* ASCII formatted TargetName for IQN */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

ret = p.write(buf)
if ret:
tcm_mod_err("Unable to write f: " + f)

p.close()
f = f"{fabric_mod_dir_var}/{fabric_mod_name}_base.h"
global fabric_mod_port
with open(f, 'w') as p:
if not p:
tcm_mod_err(f"Unable to open file: {f}")

buf = f"#define {fabric_mod_name.upper()}" + "_VERSION \"v0.1\"\n"
buf += f"#define {fabric_mod_name.upper()}" + "_NAMELEN 32\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_tpg {\n"
buf += " /* iSCSI target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += f"struct {fabric_mod_name}" + "_tport {\n"
buf += " /* ASCII formatted TargetName for IQN */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_iSCSI_include refactored with the following changes:

Comment on lines -183 to +338
+ "_drop_tpg(struct se_portal_group *se_tpg)\n"
)

buf += "{\n"
buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n"
buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n\n"
buf += " core_tpg_deregister(se_tpg);\n"
buf += " kfree(tpg);\n"
buf += "}\n\n"

buf += (
f"static struct se_wwn *{fabric_mod_name}_make_{fabric_mod_port}" + "(\n"
)

buf += " struct target_fabric_configfs *tf,\n"
buf += " struct config_group *group,\n"
buf += " const char *name)\n"
buf += "{\n"
buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + ";\n"

if proto_ident in ["FC", "SAS"]:
buf += " u64 wwpn = 0;\n\n"

buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
buf += " return ERR_PTR(-EINVAL); */\n\n"
buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n"
buf += " if (!" + fabric_mod_port + ") {\n"
buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n"
buf += " return ERR_PTR(-ENOMEM);\n"
buf += " }\n"

if proto_ident in ["FC", "SAS"]:
buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n"

buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n"
buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n"
buf += "}\n\n"
buf += (
f"static void {fabric_mod_name}_drop_{fabric_mod_port}"
+ "(struct se_wwn *wwn)\n"
)

buf += "{\n"
buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = container_of(wwn,\n"
buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n"
buf += " kfree(" + fabric_mod_port + ");\n"
buf += "}\n\n"

buf += (
f"static const struct target_core_fabric_ops {fabric_mod_name}"
+ "_ops = {\n"
)

buf += " .module = THIS_MODULE,\n"
buf += " .name = \"" + fabric_mod_name + "\",\n"
buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n"
buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n"
buf += " .tpg_get_tag = " + fabric_mod_name + "_get_tag,\n"
buf += " .tpg_check_demo_mode = " + fabric_mod_name + "_check_false,\n"
buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n"
buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n"
buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n"
buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n"
buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n"
buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n"
buf += " .sess_get_initiator_sid = NULL,\n"
buf += " .write_pending = " + fabric_mod_name + "_write_pending,\n"
buf += " .write_pending_status = " + fabric_mod_name + "_write_pending_status,\n"
buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n"
buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n"
buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n"
buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n"
buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n"
buf += " .aborted_task = " + fabric_mod_name + "_aborted_task,\n"
buf += " /*\n"
buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n"
buf += " */\n"
buf += " .fabric_make_wwn = " + fabric_mod_name + "_make_" + fabric_mod_port + ",\n"
buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n"
buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n"
buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n"
buf += "};\n\n"

buf += f"static int __init {fabric_mod_name}" + "_init(void)\n"
buf += "{\n"
buf += " return target_register_template(&" + fabric_mod_name + "_ops);\n"
buf += "};\n\n"

buf += f"static void __exit {fabric_mod_name}" + "_exit(void)\n"
buf += "{\n"
buf += " target_unregister_template(&" + fabric_mod_name + "_ops);\n"
buf += "};\n\n"

buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n"
buf += "MODULE_LICENSE(\"GPL\");\n"
buf += f"module_init({fabric_mod_name}" + "_init);\n"
buf += f"module_exit({fabric_mod_name}" + "_exit);\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_configfs refactored with the following changes:

Comment on lines 343 to -371

fabric_ops_api = f"{tcm_dir}include/target/target_core_fabric.h"

fabric_ops_api = tcm_dir + "include/target/target_core_fabric.h"

print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api
process_fo = 0;

p = open(fabric_ops_api, 'r')
with open(fabric_ops_api, 'r') as p:
line = p.readline()
while line:
if process_fo == 0 and re.search('struct target_core_fabric_ops {', line):
line = p.readline()
continue

if process_fo == 0:
process_fo = 1;
line = p.readline()
# Search for function pointer
if not re.search('\(\*', line):
continue

line = p.readline()
while line:
if process_fo == 0 and re.search('struct target_core_fabric_ops {', line):
line = p.readline()
continue
fabric_ops.append(line.rstrip())
continue

if process_fo == 0:
process_fo = 1;
line = p.readline()
# Search for function pointer
if not re.search('\(\*', line):
continue

fabric_ops.append(line.rstrip())
continue

line = p.readline()
# Search for function pointer
if not re.search('\(\*', line):
continue

fabric_ops.append(line.rstrip())

p.close()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_scan_fabric_ops refactored with the following changes:

Comment on lines -7 to +12
msrs = dict()
msrs = {}

with open(sys.argv[1] if len(sys.argv) > 1 else "msr-index.h", "r") as f:
for j in f:
m = re.match(r'#define (MSR_\w+)\s+(0x[0-9a-fA-F]+)', j)
if m:
msrs[int(m.group(2), 16)] = m.group(1)
if m := re.match(r'#define (MSR_\w+)\s+(0x[0-9a-fA-F]+)', j):
msrs[int(m[2], 16)] = m[1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 7-35 refactored with the following changes:

Comment on lines -63 to +68
f = open(path, "r");
val = f.read();
f.close()
with open(path, "r") as f:
val = f.read();
return int(val)
except IOError as e:
print("I/O error({0}): {1}".format(e.errno, e.strerror))
print("Invalid path %s" % path)
print(f"Invalid path {path}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function read_sysfs_int refactored with the following changes:

Comment on lines -73 to +76
f = open(path, "r+")
f.write(val)
f.close()
with open(path, "r+") as f:
f.write(val)
except IOError as e:
print("I/O error({0}): {1}".format(e.errno, e.strerror))
print("Invalid path %s" % path)
print(f"Invalid path {path}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function write_sysfs_val refactored with the following changes:

Comment on lines -84 to +96
fname = test_name + '_' + size + '_' + str(iteration_max) + '.csv'
fname = f'{test_name}_{size}_{str(iteration_max)}.csv'

try:
# gather data set
date = str(datetime.datetime.now())
error = read_sysfs_int(sys_pfx + 'error')
request_min = read_sysfs_int(sys_pfx + 'requests_per_second_min')
request_max = read_sysfs_int(sys_pfx + 'requests_per_second_max')
request_avg = read_sysfs_int(sys_pfx + 'requests_per_second_avg')
latency_min = read_sysfs_int(sys_pfx + 'latency_min')
latency_max = read_sysfs_int(sys_pfx + 'latency_max')
latency_avg = read_sysfs_int(sys_pfx + 'latency_avg')
throughput_min = read_sysfs_int(sys_pfx + 'throughput_min')
throughput_max = read_sysfs_int(sys_pfx + 'throughput_max')
throughput_avg = read_sysfs_int(sys_pfx + 'throughput_avg')
error = read_sysfs_int(f'{sys_pfx}error')
request_min = read_sysfs_int(f'{sys_pfx}requests_per_second_min')
request_max = read_sysfs_int(f'{sys_pfx}requests_per_second_max')
request_avg = read_sysfs_int(f'{sys_pfx}requests_per_second_avg')
latency_min = read_sysfs_int(f'{sys_pfx}latency_min')
latency_max = read_sysfs_int(f'{sys_pfx}latency_max')
latency_avg = read_sysfs_int(f'{sys_pfx}latency_avg')
throughput_min = read_sysfs_int(f'{sys_pfx}throughput_min')
throughput_max = read_sysfs_int(f'{sys_pfx}throughput_max')
throughput_avg = read_sysfs_int(f'{sys_pfx}throughput_avg')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function log_csv refactored with the following changes:

Comment on lines -357 to +347
if re.match(self.kprobes[name]['mask'], target):
return True
return False
return bool(re.match(self.kprobes[name]['mask'], target))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.kprobeMatch refactored with the following changes:

Comment on lines -361 to +355
self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name,'mask': name}
self.kprobes[name] = {
'name': name,
'func': name,
'args': {},
'format': name,
'mask': name,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.basicKprobe refactored with the following changes:

Comment on lines -367 to +365
archargs = 'args_'+platform.machine()
archargs = f'args_{platform.machine()}'
if archargs in k:
k['args'] = k[archargs]
else:
k['args'] = dict()
k['args'] = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.defaultKprobe refactored with the following changes:

Comment on lines -392 to +393
arglist = dict()
arglist = {}
# now process the args
for arg in sorted(args):
arglist[arg] = ''
m = re.match('.* '+arg+'=(?P<arg>.*) ', data);
if m:
arglist[arg] = m.group('arg')
else:
m = re.match('.* '+arg+'=(?P<arg>.*)', data);
if m:
arglist[arg] = m.group('arg')
if m := re.match(f'.* {arg}=(?P<arg>.*) ', data):
arglist[arg] = m['arg']
elif m := re.match(f'.* {arg}=(?P<arg>.*)', data):
arglist[arg] = m['arg']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.kprobeDisplayName refactored with the following changes:

Comment on lines -413 to +406
val = 'p:%s_cal %s' % (name, func)
val = f'p:{name}_cal {func}'
for i in sorted(args):
val += ' %s=%s' % (i, args[i])
val += f' {i}={args[i]}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.kprobeText refactored with the following changes:

Comment on lines -421 to +420
rejects = []
for name in sorted(self.kprobes):
if not self.testKprobe(self.kprobes[name]):
rejects.append(name)
rejects = [
name
for name in sorted(self.kprobes)
if not self.testKprobe(self.kprobes[name])
]

# remove all failed ones from the list
for name in rejects:
vprint('Skipping KPROBE: %s' % name)
vprint(f'Skipping KPROBE: {name}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.addKprobes refactored with the following changes:

Comment on lines -458 to +451
if linesack < linesout:
return False
return True
return linesack >= linesout
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.testKprobe refactored with the following changes:

Comment on lines -466 to +458
fp = open(file, mode)
fp.write(val)
fp.close()
with open(file, mode) as fp:
fp.write(val)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.fsetVal refactored with the following changes:

Comment on lines -478 to +469
fp = open(file, 'r')
res = fp.read()
fp.close()
with open(file, 'r') as fp:
res = fp.read()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.fgetVal refactored with the following changes:

Comment on lines -504 to +493
if name in funclist:
return True
return False
return name in funclist
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.isCallgraphFunc refactored with the following changes:

Comment on lines -876 to +915
slist = []
tmp = dict()
tmp = {}
for devname in list:
dev = list[devname]
tmp[dev['start']] = devname
for t in sorted(tmp):
slist.append(tmp[t])
return slist
return [tmp[t] for t in sorted(tmp)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.sortedDevices refactored with the following changes:

Comment on lines -889 to +926
if(dev['end'] < 0):
if (dev['end'] < 0):
for p in self.phases:
if self.dmesg[p]['end'] > dev['start']:
dev['end'] = self.dmesg[p]['end']
break
vprint('%s (%s): callback didnt return' % (devname, phase))
vprint(f'{devname} ({phase}): callback didnt return')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.fixupInitcalls refactored with the following changes:

Comment on lines -924 to +956
if(self.start <= start and self.end > start):
return True
return False
return self.start <= start and self.end > start
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.isInsideTimeline refactored with the following changes:

Comment on lines -979 to +1009
length = -1.0
if(start >= 0 and end >= 0):
length = end - start
length = end - start if (start >= 0 and end >= 0) else -1.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.newAction refactored with the following changes:

Comment on lines -996 to +1025
idlist = []
list = self.dmesg[phase]['list']
for devname in list:
if devname in devlist:
idlist.append(list[devname]['id'])
return idlist
return [list[devname]['id'] for devname in list if devname in devlist]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.deviceIDs refactored with the following changes:

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

print('gen_version_h: processing [%s]' % version_makefile)
print(f'gen_version_h: processing [{version_makefile}]')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function gen_version_h refactored with the following changes:

Comment on lines -144 to +139
print('scan_arch_kbuild: processing [%s]' % arch_asm_kbuild)
print(f'scan_arch_kbuild: processing [{arch_asm_kbuild}]')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function scan_arch_kbuild refactored with the following changes:

Comment on lines -268 to +258
match = abi_re.match(generated)

if match:
abi = match.group(1)
if match := abi_re.match(generated):
abi = match[1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function gen_arch_headers refactored with the following changes:

Comment on lines -335 to +322
print('error: expected prefix [%s] on header [%s]' % (prefix, h))
print(f'error: expected prefix [{prefix}] on header [{h}]')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function run_headers_install refactored with the following changes:

Comment on lines -444 to +451
print('find_out: module_dir_sep [%s]' % module_dir_sep)
print('find_out: prefix_sep [%s]' % prefix_sep)
print(f'find_out: module_dir_sep [{module_dir_sep}]')
print(f'find_out: prefix_sep [{prefix_sep}]')

error_count = 0

for full_src in full_srcs:
if verbose:
print('find_out: full_src [%s]' % full_src)
print(f'find_out: full_src [{full_src}]')

if not full_src.startswith(module_dir_sep):
print('error: expected %s to start with %s' % (full_src, module_dir_sep))
print(f'error: expected {full_src} to start with {module_dir_sep}')
error_count += 1
continue

local_src = full_src[len(module_dir_sep):]

if verbose:
print('find_out: local_src [%s]' % local_src)
print(f'find_out: local_src [{local_src}]')

if not local_src.startswith(prefix_sep):
print('error: expected %s to start with %s' % (local_src, prefix_sep))
print(f'error: expected {local_src} to start with {prefix_sep}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_out refactored with the following changes:

Comment on lines -335 to +327
if (isinstance(child , nodes.comment)
or isinstance(child, nodes.system_message)):
if isinstance(child, (nodes.comment, nodes.system_message)):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ListTableBuilder.parseRowItem refactored with the following changes:

Comment on lines -43 to +71
f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h"
print "Writing file: " + f

p = open(f, 'w');
if not p:
tcm_mod_err("Unable to open file: " + f)

buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_tpg {\n"
buf += " /* FC lport target portal group tag for TCM */\n"
buf += " u16 lport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n"
buf += " struct " + fabric_mod_name + "_lport *lport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_lport {\n"
buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n"
buf += " u64 lport_wwpn;\n"
buf += " /* ASCII formatted WWPN for FC Target Lport */\n"
buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n"
buf += " struct se_wwn lport_wwn;\n"
buf += "};\n"

ret = p.write(buf)
if ret:
tcm_mod_err("Unable to write f: " + f)

p.close()
f = f"{fabric_mod_dir_var}/{fabric_mod_name}_base.h"
global fabric_mod_port
with open(f, 'w') as p:
if not p:
tcm_mod_err(f"Unable to open file: {f}")

buf = f"#define {fabric_mod_name.upper()}" + "_VERSION \"v0.1\"\n"
buf += f"#define {fabric_mod_name.upper()}" + "_NAMELEN 32\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_tpg {\n"
buf += " /* FC lport target portal group tag for TCM */\n"
buf += " u16 lport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_lport */\n"
buf += " struct " + fabric_mod_name + "_lport *lport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_lport {\n"
buf += " /* Binary World Wide unique Port Name for FC Target Lport */\n"
buf += " u64 lport_wwpn;\n"
buf += " /* ASCII formatted WWPN for FC Target Lport */\n"
buf += " char lport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_lport() */\n"
buf += " struct se_wwn lport_wwn;\n"
buf += "};\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_FC_include refactored with the following changes:

Comment on lines -87 to +110
f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h"
print "Writing file: " + f

p = open(f, 'w');
if not p:
tcm_mod_err("Unable to open file: " + f)

buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_tpg {\n"
buf += " /* SAS port target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += "struct " + fabric_mod_name + "_tport {\n"
buf += " /* Binary World Wide unique Port Name for SAS Target port */\n"
buf += " u64 tport_wwpn;\n"
buf += " /* ASCII formatted WWPN for SAS Target port */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

ret = p.write(buf)
if ret:
tcm_mod_err("Unable to write f: " + f)

p.close()
f = f"{fabric_mod_dir_var}/{fabric_mod_name}_base.h"
global fabric_mod_port
with open(f, 'w') as p:
if not p:
tcm_mod_err(f"Unable to open file: {f}")

buf = f"#define {fabric_mod_name.upper()}" + "_VERSION \"v0.1\"\n"
buf += f"#define {fabric_mod_name.upper()}" + "_NAMELEN 32\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_tpg {\n"
buf += " /* SAS port target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += f"struct {fabric_mod_name}" + "_tport {\n"
buf += " /* Binary World Wide unique Port Name for SAS Target port */\n"
buf += " u64 tport_wwpn;\n"
buf += " /* ASCII formatted WWPN for SAS Target port */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_SAS_include refactored with the following changes:

Comment on lines -130 to +147
f = fabric_mod_dir_var + "/" + fabric_mod_name + "_base.h"
print "Writing file: " + f

p = open(f, 'w');
if not p:
tcm_mod_err("Unable to open file: " + f)

buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
buf += "\n"
buf += "struct " + fabric_mod_name + "_tpg {\n"
buf += " /* iSCSI target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += "struct " + fabric_mod_name + "_tport {\n"
buf += " /* ASCII formatted TargetName for IQN */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

ret = p.write(buf)
if ret:
tcm_mod_err("Unable to write f: " + f)

p.close()
f = f"{fabric_mod_dir_var}/{fabric_mod_name}_base.h"
global fabric_mod_port
with open(f, 'w') as p:
if not p:
tcm_mod_err(f"Unable to open file: {f}")

buf = f"#define {fabric_mod_name.upper()}" + "_VERSION \"v0.1\"\n"
buf += f"#define {fabric_mod_name.upper()}" + "_NAMELEN 32\n"
buf += "\n"
buf += f"struct {fabric_mod_name}" + "_tpg {\n"
buf += " /* iSCSI target portal group tag for TCM */\n"
buf += " u16 tport_tpgt;\n"
buf += " /* Pointer back to " + fabric_mod_name + "_tport */\n"
buf += " struct " + fabric_mod_name + "_tport *tport;\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tpg() */\n"
buf += " struct se_portal_group se_tpg;\n"
buf += "};\n\n"
buf += f"struct {fabric_mod_name}" + "_tport {\n"
buf += " /* ASCII formatted TargetName for IQN */\n"
buf += " char tport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
buf += " /* Returned by " + fabric_mod_name + "_make_tport() */\n"
buf += " struct se_wwn tport_wwn;\n"
buf += "};\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_iSCSI_include refactored with the following changes:

Comment on lines -183 to +338
+ "_drop_tpg(struct se_portal_group *se_tpg)\n"
)

buf += "{\n"
buf += " struct " + fabric_mod_name + "_tpg *tpg = container_of(se_tpg,\n"
buf += " struct " + fabric_mod_name + "_tpg, se_tpg);\n\n"
buf += " core_tpg_deregister(se_tpg);\n"
buf += " kfree(tpg);\n"
buf += "}\n\n"

buf += (
f"static struct se_wwn *{fabric_mod_name}_make_{fabric_mod_port}" + "(\n"
)

buf += " struct target_fabric_configfs *tf,\n"
buf += " struct config_group *group,\n"
buf += " const char *name)\n"
buf += "{\n"
buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + ";\n"

if proto_ident in ["FC", "SAS"]:
buf += " u64 wwpn = 0;\n\n"

buf += " /* if (" + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
buf += " return ERR_PTR(-EINVAL); */\n\n"
buf += " " + fabric_mod_port + " = kzalloc(sizeof(struct " + fabric_mod_name + "_" + fabric_mod_port + "), GFP_KERNEL);\n"
buf += " if (!" + fabric_mod_port + ") {\n"
buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_" + fabric_mod_port + "\");\n"
buf += " return ERR_PTR(-ENOMEM);\n"
buf += " }\n"

if proto_ident in ["FC", "SAS"]:
buf += " " + fabric_mod_port + "->" + fabric_mod_port + "_wwpn = wwpn;\n"

buf += " /* " + fabric_mod_name + "_format_wwn(&" + fabric_mod_port + "->" + fabric_mod_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n"
buf += " return &" + fabric_mod_port + "->" + fabric_mod_port + "_wwn;\n"
buf += "}\n\n"
buf += (
f"static void {fabric_mod_name}_drop_{fabric_mod_port}"
+ "(struct se_wwn *wwn)\n"
)

buf += "{\n"
buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + " *" + fabric_mod_port + " = container_of(wwn,\n"
buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n"
buf += " kfree(" + fabric_mod_port + ");\n"
buf += "}\n\n"

buf += (
f"static const struct target_core_fabric_ops {fabric_mod_name}"
+ "_ops = {\n"
)

buf += " .module = THIS_MODULE,\n"
buf += " .name = \"" + fabric_mod_name + "\",\n"
buf += " .get_fabric_name = " + fabric_mod_name + "_get_fabric_name,\n"
buf += " .tpg_get_wwn = " + fabric_mod_name + "_get_fabric_wwn,\n"
buf += " .tpg_get_tag = " + fabric_mod_name + "_get_tag,\n"
buf += " .tpg_check_demo_mode = " + fabric_mod_name + "_check_false,\n"
buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n"
buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n"
buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n"
buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n"
buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n"
buf += " .sess_get_index = " + fabric_mod_name + "_sess_get_index,\n"
buf += " .sess_get_initiator_sid = NULL,\n"
buf += " .write_pending = " + fabric_mod_name + "_write_pending,\n"
buf += " .write_pending_status = " + fabric_mod_name + "_write_pending_status,\n"
buf += " .set_default_node_attributes = " + fabric_mod_name + "_set_default_node_attrs,\n"
buf += " .get_cmd_state = " + fabric_mod_name + "_get_cmd_state,\n"
buf += " .queue_data_in = " + fabric_mod_name + "_queue_data_in,\n"
buf += " .queue_status = " + fabric_mod_name + "_queue_status,\n"
buf += " .queue_tm_rsp = " + fabric_mod_name + "_queue_tm_rsp,\n"
buf += " .aborted_task = " + fabric_mod_name + "_aborted_task,\n"
buf += " /*\n"
buf += " * Setup function pointers for generic logic in target_core_fabric_configfs.c\n"
buf += " */\n"
buf += " .fabric_make_wwn = " + fabric_mod_name + "_make_" + fabric_mod_port + ",\n"
buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n"
buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n"
buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n"
buf += "};\n\n"

buf += f"static int __init {fabric_mod_name}" + "_init(void)\n"
buf += "{\n"
buf += " return target_register_template(&" + fabric_mod_name + "_ops);\n"
buf += "};\n\n"

buf += f"static void __exit {fabric_mod_name}" + "_exit(void)\n"
buf += "{\n"
buf += " target_unregister_template(&" + fabric_mod_name + "_ops);\n"
buf += "};\n\n"

buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n"
buf += "MODULE_LICENSE(\"GPL\");\n"
buf += f"module_init({fabric_mod_name}" + "_init);\n"
buf += f"module_exit({fabric_mod_name}" + "_exit);\n"

if ret := p.write(buf):
tcm_mod_err(f"Unable to write f: {f}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_build_configfs refactored with the following changes:

Comment on lines 343 to -371

fabric_ops_api = f"{tcm_dir}include/target/target_core_fabric.h"

fabric_ops_api = tcm_dir + "include/target/target_core_fabric.h"

print "Using tcm_mod_scan_fabric_ops: " + fabric_ops_api
process_fo = 0;

p = open(fabric_ops_api, 'r')
with open(fabric_ops_api, 'r') as p:
line = p.readline()
while line:
if process_fo == 0 and re.search('struct target_core_fabric_ops {', line):
line = p.readline()
continue

if process_fo == 0:
process_fo = 1;
line = p.readline()
# Search for function pointer
if not re.search('\(\*', line):
continue

line = p.readline()
while line:
if process_fo == 0 and re.search('struct target_core_fabric_ops {', line):
line = p.readline()
continue
fabric_ops.append(line.rstrip())
continue

if process_fo == 0:
process_fo = 1;
line = p.readline()
# Search for function pointer
if not re.search('\(\*', line):
continue

fabric_ops.append(line.rstrip())
continue

line = p.readline()
# Search for function pointer
if not re.search('\(\*', line):
continue

fabric_ops.append(line.rstrip())

p.close()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tcm_mod_scan_fabric_ops refactored with the following changes:

Comment on lines -7 to +12
msrs = dict()
msrs = {}

with open(sys.argv[1] if len(sys.argv) > 1 else "msr-index.h", "r") as f:
for j in f:
m = re.match(r'#define (MSR_\w+)\s+(0x[0-9a-fA-F]+)', j)
if m:
msrs[int(m.group(2), 16)] = m.group(1)
if m := re.match(r'#define (MSR_\w+)\s+(0x[0-9a-fA-F]+)', j):
msrs[int(m[2], 16)] = m[1]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 7-35 refactored with the following changes:

Comment on lines -63 to +68
f = open(path, "r");
val = f.read();
f.close()
with open(path, "r") as f:
val = f.read();
return int(val)
except IOError as e:
print("I/O error({0}): {1}".format(e.errno, e.strerror))
print("Invalid path %s" % path)
print(f"Invalid path {path}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function read_sysfs_int refactored with the following changes:

Comment on lines -73 to +76
f = open(path, "r+")
f.write(val)
f.close()
with open(path, "r+") as f:
f.write(val)
except IOError as e:
print("I/O error({0}): {1}".format(e.errno, e.strerror))
print("Invalid path %s" % path)
print(f"Invalid path {path}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function write_sysfs_val refactored with the following changes:

Comment on lines -84 to +96
fname = test_name + '_' + size + '_' + str(iteration_max) + '.csv'
fname = f'{test_name}_{size}_{str(iteration_max)}.csv'

try:
# gather data set
date = str(datetime.datetime.now())
error = read_sysfs_int(sys_pfx + 'error')
request_min = read_sysfs_int(sys_pfx + 'requests_per_second_min')
request_max = read_sysfs_int(sys_pfx + 'requests_per_second_max')
request_avg = read_sysfs_int(sys_pfx + 'requests_per_second_avg')
latency_min = read_sysfs_int(sys_pfx + 'latency_min')
latency_max = read_sysfs_int(sys_pfx + 'latency_max')
latency_avg = read_sysfs_int(sys_pfx + 'latency_avg')
throughput_min = read_sysfs_int(sys_pfx + 'throughput_min')
throughput_max = read_sysfs_int(sys_pfx + 'throughput_max')
throughput_avg = read_sysfs_int(sys_pfx + 'throughput_avg')
error = read_sysfs_int(f'{sys_pfx}error')
request_min = read_sysfs_int(f'{sys_pfx}requests_per_second_min')
request_max = read_sysfs_int(f'{sys_pfx}requests_per_second_max')
request_avg = read_sysfs_int(f'{sys_pfx}requests_per_second_avg')
latency_min = read_sysfs_int(f'{sys_pfx}latency_min')
latency_max = read_sysfs_int(f'{sys_pfx}latency_max')
latency_avg = read_sysfs_int(f'{sys_pfx}latency_avg')
throughput_min = read_sysfs_int(f'{sys_pfx}throughput_min')
throughput_max = read_sysfs_int(f'{sys_pfx}throughput_max')
throughput_avg = read_sysfs_int(f'{sys_pfx}throughput_avg')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function log_csv refactored with the following changes:

Comment on lines -357 to +347
if re.match(self.kprobes[name]['mask'], target):
return True
return False
return bool(re.match(self.kprobes[name]['mask'], target))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.kprobeMatch refactored with the following changes:

Comment on lines -361 to +355
self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name,'mask': name}
self.kprobes[name] = {
'name': name,
'func': name,
'args': {},
'format': name,
'mask': name,
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.basicKprobe refactored with the following changes:

Comment on lines -367 to +365
archargs = 'args_'+platform.machine()
archargs = f'args_{platform.machine()}'
if archargs in k:
k['args'] = k[archargs]
else:
k['args'] = dict()
k['args'] = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.defaultKprobe refactored with the following changes:

Comment on lines -392 to +393
arglist = dict()
arglist = {}
# now process the args
for arg in sorted(args):
arglist[arg] = ''
m = re.match('.* '+arg+'=(?P<arg>.*) ', data);
if m:
arglist[arg] = m.group('arg')
else:
m = re.match('.* '+arg+'=(?P<arg>.*)', data);
if m:
arglist[arg] = m.group('arg')
if m := re.match(f'.* {arg}=(?P<arg>.*) ', data):
arglist[arg] = m['arg']
elif m := re.match(f'.* {arg}=(?P<arg>.*)', data):
arglist[arg] = m['arg']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.kprobeDisplayName refactored with the following changes:

Comment on lines -413 to +406
val = 'p:%s_cal %s' % (name, func)
val = f'p:{name}_cal {func}'
for i in sorted(args):
val += ' %s=%s' % (i, args[i])
val += f' {i}={args[i]}'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.kprobeText refactored with the following changes:

Comment on lines -421 to +420
rejects = []
for name in sorted(self.kprobes):
if not self.testKprobe(self.kprobes[name]):
rejects.append(name)
rejects = [
name
for name in sorted(self.kprobes)
if not self.testKprobe(self.kprobes[name])
]

# remove all failed ones from the list
for name in rejects:
vprint('Skipping KPROBE: %s' % name)
vprint(f'Skipping KPROBE: {name}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.addKprobes refactored with the following changes:

Comment on lines -458 to +451
if linesack < linesout:
return False
return True
return linesack >= linesout
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.testKprobe refactored with the following changes:

Comment on lines -466 to +458
fp = open(file, mode)
fp.write(val)
fp.close()
with open(file, mode) as fp:
fp.write(val)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.fsetVal refactored with the following changes:

Comment on lines -478 to +469
fp = open(file, 'r')
res = fp.read()
fp.close()
with open(file, 'r') as fp:
res = fp.read()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.fgetVal refactored with the following changes:

Comment on lines -504 to +493
if name in funclist:
return True
return False
return name in funclist
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SystemValues.isCallgraphFunc refactored with the following changes:

Comment on lines -876 to +915
slist = []
tmp = dict()
tmp = {}
for devname in list:
dev = list[devname]
tmp[dev['start']] = devname
for t in sorted(tmp):
slist.append(tmp[t])
return slist
return [tmp[t] for t in sorted(tmp)]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.sortedDevices refactored with the following changes:

Comment on lines -889 to +926
if(dev['end'] < 0):
if (dev['end'] < 0):
for p in self.phases:
if self.dmesg[p]['end'] > dev['start']:
dev['end'] = self.dmesg[p]['end']
break
vprint('%s (%s): callback didnt return' % (devname, phase))
vprint(f'{devname} ({phase}): callback didnt return')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.fixupInitcalls refactored with the following changes:

Comment on lines -924 to +956
if(self.start <= start and self.end > start):
return True
return False
return self.start <= start and self.end > start
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.isInsideTimeline refactored with the following changes:

Comment on lines -979 to +1009
length = -1.0
if(start >= 0 and end >= 0):
length = end - start
length = end - start if (start >= 0 and end >= 0) else -1.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.newAction refactored with the following changes:

Comment on lines -996 to +1025
idlist = []
list = self.dmesg[phase]['list']
for devname in list:
if devname in devlist:
idlist.append(list[devname]['id'])
return idlist
return [list[devname]['id'] for devname in list if devname in devlist]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Data.deviceIDs refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants