Skip to content

Commit f73e06d

Browse files
committed
minor function API improvement
1 parent f486ead commit f73e06d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,24 +102,24 @@ void reset_mp(void) {
102102

103103
// Look for the first file that exists in the list of filenames, using mp_import_stat().
104104
// Return its index. If no file found, return -1.
105-
int first_existing_file_in_list(const char ** filenames) {
105+
const char* first_existing_file_in_list(const char ** filenames) {
106106
for (int i = 0; filenames[i] != (char*)""; i++) {
107107
mp_import_stat_t stat = mp_import_stat(filenames[i]);
108108
if (stat == MP_IMPORT_STAT_FILE) {
109-
return i;
109+
return filenames[i];
110110
}
111111
}
112-
return -1;
112+
return NULL;
113113
}
114114

115115
bool maybe_run_list(const char ** filenames, pyexec_result_t* exec_result) {
116-
int i = first_existing_file_in_list(filenames);
117-
if (i == -1) {
116+
const char* filename = first_existing_file_in_list(filenames);
117+
if (filename == NULL) {
118118
return false;
119119
}
120-
mp_hal_stdout_tx_str(filenames[i]);
120+
mp_hal_stdout_tx_str(filename);
121121
mp_hal_stdout_tx_str(MSG_OUTPUT_SUFFIX);
122-
pyexec_file(filenames[i], exec_result);
122+
pyexec_file(filename, exec_result);
123123
return true;
124124
}
125125

@@ -281,7 +281,7 @@ int __attribute__((used)) main(void) {
281281
// Get the base filesystem.
282282
FATFS *fs = &((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs;
283283

284-
bool have_boot_py = first_existing_file_in_list(boot_py_filenames) != -1;
284+
bool have_boot_py = first_existing_file_in_list(boot_py_filenames) != NULL;
285285

286286
bool skip_boot_output = false;
287287

0 commit comments

Comments
 (0)