Skip to content

Commit 12ba9df

Browse files
ulfalizergalak
authored andcommitted
scripts: Remove unused variables in all Python scripts
Discovered with pylint3. Use the placeholder name '_' for unproblematic unused variables. It's what I'm used to, and pylint knows not to flag it. Python tip: for i in range(n): some_list.append(0) can be replaced with some_list += n*[0] Similarly, 3*'\t' gives '\t\t\t'. (Relevant here because pylint flagged the loop index as unused.) To do integer division in Python 3, use // instead of /. Signed-off-by: Ulf Magnusson <[email protected]>
1 parent 399c04c commit 12ba9df

File tree

15 files changed

+19
-26
lines changed

15 files changed

+19
-26
lines changed

arch/common/gen_isr_tables.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ def main():
223223
intlist = read_intlist(args.intlist)
224224
nvec = intlist["num_vectors"]
225225
offset = intlist["offset"]
226-
prefix = endian_prefix()
227226

228227
spurious_handler = "&z_irq_spurious"
229228
sw_irq_handler = "ISR_WRAPPER"

arch/x86/gen_mmu_x86.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def page_directory_create_binary_file(self):
394394
self.output_offset += struct.calcsize(page_entry_format)
395395

396396
def page_table_create_binary_file(self):
397-
for pdpte, pde_info in sorted(self.list_of_pdpte.items()):
397+
for _, pde_info in sorted(self.list_of_pdpte.items()):
398398
for pde, pte_info in sorted(pde_info.pd_entries.items()):
399399
pe_info = pte_info.page_entries_info[0]
400400
start_addr = pe_info.start_addr & ~0x1FFFFF

arch/xtensa/core/xtensa_intgen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def cprint(s):
2929
return
3030
if s.find("}") >= 0:
3131
cindent -= 1
32-
for xx in range(cindent):
33-
s = "\t" + s
32+
s = cindent*"\t" + s
3433
print(s)
3534
if s.find("{") >= 0:
3635
cindent += 1

boards/xtensa/intel_s1000_crb/support/create_board_img.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ def main():
188188
ipc_load_fw(SRAM_SIZE, FLASH_PART_TABLE_OFFSET)
189189

190190
# pad zeros until FLASH_PART_TABLE_OFFSET
191-
num_zero_pad = (FLASH_PART_TABLE_OFFSET / 4) - len(flash_content)
192-
for x in range(int(num_zero_pad)):
193-
flash_content.append(0)
191+
num_zero_pad = FLASH_PART_TABLE_OFFSET // 4 - len(flash_content)
192+
flash_content += num_zero_pad * [0]
194193

195194
# read contents of firmware input file and change the endianness
196195
with open(args.in_file, "rb") as in_fp:
@@ -203,8 +202,7 @@ def main():
203202
write_buf.append(read_buf[itr*4 + 0])
204203

205204
# pad zeros until the sector boundary
206-
for x in range(zeropad_size):
207-
write_buf.append(0)
205+
write_buf += zeropad_size*[0]
208206

209207
# Generate the file which should be downloaded to Flash
210208
with open(args.out_file, "wb") as out_fp:

doc/extensions/local_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def copy_if_modified(src_path, dst_path):
5757
return
5858

5959
src_path_len = len(src_path)
60-
for root, dirs, files in os.walk(src_path):
60+
for root, _, files in os.walk(src_path):
6161
for src_file_name in files:
6262
src_file_path = os.path.join(root, src_file_name)
6363
dst_file_path = os.path.join(dst_path + root[src_path_len:], src_file_name)

doc/extensions/zephyr/application.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ def run(self):
164164
if v != 'all']
165165
# Build the command content as a list, then convert to string.
166166
content = []
167-
lit = []
168167
cd_to = zephyr_app or app
169168
tool_comment = None
170169
if len(tools) > 1:
@@ -336,7 +335,6 @@ def _generate_cmake(self, **kwargs):
336335
zephyr_app = kwargs['zephyr_app']
337336
host_os = kwargs['host_os']
338337
build_dir = kwargs['build_dir']
339-
source_dir = kwargs['source_dir']
340338
skip_config = kwargs['skip_config']
341339
compact = kwargs['compact']
342340
generator = kwargs['generator']

ext/hal/nxp/mcux/scripts/import_mcux_sdk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ def import_sdk(directory):
6565

6666
device_src = os.path.join(directory, 'devices', device)
6767
device_pattern = "|".join([device, 'fsl_device_registers'])
68-
[device_headers, ignore] = get_files(device_src, device_pattern)
68+
device_headers, _ = get_files(device_src, device_pattern)
6969

7070
drivers_src = os.path.join(directory, 'devices', device, 'drivers')
7171
drivers_pattern = "fsl_clock|fsl_iomuxc"
7272
[device_drivers, shared_drivers] = get_files(drivers_src, drivers_pattern)
7373

7474
xip_boot_src = os.path.join(directory, 'devices', device, 'xip')
7575
xip_boot_pattern = ".*"
76-
[xip_boot, ignore] = get_files(xip_boot_src, xip_boot_pattern)
76+
xip_boot, _ = get_files(xip_boot_src, xip_boot_pattern)
7777

7878
print('Importing {} device headers to {}'.format(device, device_dst))
7979
copy_files(device_headers, device_dst)
@@ -93,7 +93,7 @@ def import_sdk(directory):
9393

9494
xip_config_src = os.path.join(board_src, 'xip')
9595
xip_config_pattern = ".*"
96-
[xip_config, ignore] = get_files(xip_config_src, xip_config_pattern)
96+
xip_config, _ = get_files(xip_config_src, xip_config_pattern)
9797

9898
print('Importing {} xip config to {}'.format(board, board_dst))
9999
copy_files(xip_config, board_dst)

scripts/elf_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def find_kobjects(self, syms):
386386

387387
# Step 1: collect all type information.
388388
for CU in di.iter_CUs():
389-
for idx, die in enumerate(CU.iter_DIEs()):
389+
for die in CU.iter_DIEs():
390390
# Unions are disregarded, kernel objects should never be union
391391
# members since the memory is not dedicated to that object and
392392
# could be something else

scripts/filter-known-issues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def config_import_path(path):
8989
"""
9090
file_regex = re.compile(".*\.conf$")
9191
try:
92-
for dirpath, dirnames, filenames in os.walk(path):
92+
for dirpath, _, filenames in os.walk(path):
9393
for _filename in sorted(filenames):
9494
filename = os.path.join(dirpath, _filename)
9595
if not file_regex.search(_filename):

scripts/gen_app_partitions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def find_obj_file_partitions(filename, partitions):
128128

129129
def parse_obj_files(partitions):
130130
# Iterate over all object files to find partitions
131-
for dirpath, dirs, files in os.walk(args.directory):
131+
for dirpath, _, files in os.walk(args.directory):
132132
for filename in files:
133133
if re.match(".*\.obj$",filename):
134134
fullname = os.path.join(dirpath, filename)
@@ -143,7 +143,7 @@ def parse_elf_file(partitions):
143143
if isinstance(s, SymbolTableSection)]
144144

145145
for section in symbol_tbls:
146-
for nsym, symbol in enumerate(section.iter_symbols()):
146+
for symbol in section.iter_symbols():
147147
if symbol['st_shndx'] != "SHN_ABS":
148148
continue
149149

@@ -206,7 +206,6 @@ def parse_args():
206206

207207
def main():
208208
parse_args()
209-
linker_file = args.output
210209
partitions = {}
211210

212211
if args.directory is not None:

0 commit comments

Comments
 (0)