@@ -117,12 +117,12 @@ static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)
117117#endif
118118
119119static void reset_devices (void ) {
120- #if CIRCUITPY_BLEIO_HCI
120+ #if CIRCUITPY_BLEIO_HCI
121121 bleio_reset ();
122- #endif
122+ #endif
123123}
124124
125- STATIC void start_mp (supervisor_allocation * heap ) {
125+ STATIC void start_mp (supervisor_allocation * heap ) {
126126 autoreload_stop ();
127127 supervisor_workflow_reset ();
128128
@@ -135,13 +135,13 @@ STATIC void start_mp(supervisor_allocation* heap) {
135135 }
136136
137137
138- #if MICROPY_MAX_STACK_USAGE
138+ #if MICROPY_MAX_STACK_USAGE
139139 // _ezero (same as _ebss) is an int, so start 4 bytes above it.
140140 if (stack_get_bottom () != NULL ) {
141141 mp_stack_set_bottom (stack_get_bottom ());
142142 mp_stack_fill_with_sentinel ();
143143 }
144- #endif
144+ #endif
145145
146146 // Sync the file systems in case any used RAM from the GC to cache. As soon
147147 // as we re-init the GC all bets are off on the cache.
@@ -201,8 +201,8 @@ STATIC void stop_mp(void) {
201201
202202// Look for the first file that exists in the list of filenames, using mp_import_stat().
203203// Return its index. If no file found, return -1.
204- STATIC const char * first_existing_file_in_list (const char * const * filenames ) {
205- for (int i = 0 ; filenames [i ] != (char * )"" ; i ++ ) {
204+ STATIC const char * first_existing_file_in_list (const char * const * filenames ) {
205+ for (int i = 0 ; filenames [i ] != (char * )"" ; i ++ ) {
206206 mp_import_stat_t stat = mp_import_stat (filenames [i ]);
207207 if (stat == MP_IMPORT_STAT_FILE ) {
208208 return filenames [i ];
@@ -211,8 +211,8 @@ STATIC const char* first_existing_file_in_list(const char * const * filenames) {
211211 return NULL ;
212212}
213213
214- STATIC bool maybe_run_list (const char * const * filenames , pyexec_result_t * exec_result ) {
215- const char * filename = first_existing_file_in_list (filenames );
214+ STATIC bool maybe_run_list (const char * const * filenames , pyexec_result_t * exec_result ) {
215+ const char * filename = first_existing_file_in_list (filenames );
216216 if (filename == NULL ) {
217217 return false;
218218 }
@@ -226,10 +226,10 @@ STATIC bool maybe_run_list(const char * const * filenames, pyexec_result_t* exec
226226}
227227
228228STATIC void count_strn (void * data , const char * str , size_t len ) {
229- * (size_t * )data += len ;
229+ * (size_t * )data += len ;
230230}
231231
232- STATIC void cleanup_after_vm (supervisor_allocation * heap , mp_obj_t exception ) {
232+ STATIC void cleanup_after_vm (supervisor_allocation * heap , mp_obj_t exception ) {
233233 // Get the traceback of any exception from this run off the heap.
234234 // MP_OBJ_SENTINEL means "this run does not contribute to traceback storage, don't touch it"
235235 // MP_OBJ_NULL (=0) means "this run completed successfully, clear any stored traceback"
@@ -249,13 +249,12 @@ STATIC void cleanup_after_vm(supervisor_allocation* heap, mp_obj_t exception) {
249249 // making it fail, but at this point I believe they are not worth spending code on.
250250 if (prev_traceback_allocation != NULL ) {
251251 vstr_t vstr ;
252- vstr_init_fixed_buf (& vstr , traceback_len , (char * )prev_traceback_allocation -> ptr );
252+ vstr_init_fixed_buf (& vstr , traceback_len , (char * )prev_traceback_allocation -> ptr );
253253 mp_print_t print = {& vstr , (mp_print_strn_t )vstr_add_strn };
254254 mp_obj_print_exception (& print , exception );
255- ((char * )prev_traceback_allocation -> ptr )[traceback_len ] = '\0' ;
255+ ((char * )prev_traceback_allocation -> ptr )[traceback_len ] = '\0' ;
256256 }
257- }
258- else {
257+ } else {
259258 prev_traceback_allocation = NULL ;
260259 }
261260 }
@@ -335,17 +334,17 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
335334 uint8_t next_code_stickiness_situation = SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
336335
337336 if (safe_mode == NO_SAFE_MODE ) {
338- static const char * const supported_filenames [] = STRING_LIST (
337+ static const char * const supported_filenames [] = STRING_LIST (
339338 "code.txt" , "code.py" , "main.py" , "main.txt" );
340339 #if CIRCUITPY_FULL_BUILD
341- static const char * const double_extension_filenames [] = STRING_LIST (
340+ static const char * const double_extension_filenames [] = STRING_LIST (
342341 "code.txt.py" , "code.py.txt" , "code.txt.txt" ,"code.py.py" ,
343342 "main.txt.py" , "main.py.txt" , "main.txt.txt" ,"main.py.py" );
344343 #endif
345344
346345 stack_resize ();
347346 filesystem_flush ();
348- supervisor_allocation * heap = allocate_remaining_memory ();
347+ supervisor_allocation * heap = allocate_remaining_memory ();
349348
350349 // Prepare the VM state. Includes an alarm check/reset for sleep.
351350 start_mp (heap );
@@ -356,14 +355,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
356355
357356 // Check if a different run file has been allocated
358357 if (next_code_allocation ) {
359- ((next_code_info_t * )next_code_allocation -> ptr )-> options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
360- next_code_options = ((next_code_info_t * )next_code_allocation -> ptr )-> options ;
361- if (((next_code_info_t * )next_code_allocation -> ptr )-> filename [0 ] != '\0' ) {
362- const char * next_list [] = {((next_code_info_t * )next_code_allocation -> ptr )-> filename , "" };
358+ ((next_code_info_t * )next_code_allocation -> ptr )-> options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
359+ next_code_options = ((next_code_info_t * )next_code_allocation -> ptr )-> options ;
360+ if (((next_code_info_t * )next_code_allocation -> ptr )-> filename [0 ] != '\0' ) {
361+ const char * next_list [] = {((next_code_info_t * )next_code_allocation -> ptr )-> filename , "" };
363362 // This is where the user's python code is actually executed:
364363 found_main = maybe_run_list (next_list , & result );
365364 if (!found_main ) {
366- serial_write (((next_code_info_t * )next_code_allocation -> ptr )-> filename );
365+ serial_write (((next_code_info_t * )next_code_allocation -> ptr )-> filename );
367366 serial_write_compressed (translate (" not found.\n" ));
368367 }
369368 }
@@ -374,14 +373,14 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
374373 found_main = maybe_run_list (supported_filenames , & result );
375374 // If that didn't work, double check the extensions
376375 #if CIRCUITPY_FULL_BUILD
377- if (!found_main ){
376+ if (!found_main ) {
378377 found_main = maybe_run_list (double_extension_filenames , & result );
379378 if (found_main ) {
380379 serial_write_compressed (translate ("WARNING: Your code filename has two extensions\n" ));
381380 }
382381 }
383382 #else
384- (void ) found_main ;
383+ (void )found_main ;
385384 #endif
386385 }
387386
@@ -400,7 +399,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
400399 // the options because it can be treated like any other reason-for-stickiness bit. The
401400 // source is different though: it comes from the options that will apply to the next run,
402401 // while the rest of next_code_options is what applied to this run.
403- if (next_code_allocation != NULL && (((next_code_info_t * )next_code_allocation -> ptr )-> options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET )) {
402+ if (next_code_allocation != NULL && (((next_code_info_t * )next_code_allocation -> ptr )-> options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET )) {
404403 next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET ;
405404 }
406405
@@ -562,7 +561,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) {
562561 }
563562
564563 #if !CIRCUITPY_STATUS_LED
565- port_interrupt_after_ticks (time_to_epaper_refresh );
564+ port_interrupt_after_ticks (time_to_epaper_refresh );
566565 #endif
567566 #endif
568567
@@ -645,17 +644,17 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
645644 && safe_mode == NO_SAFE_MODE
646645 && MP_STATE_VM (vfs_mount_table ) != NULL ;
647646
648- static const char * const boot_py_filenames [] = STRING_LIST ("boot.py" , "boot.txt" );
647+ static const char * const boot_py_filenames [] = STRING_LIST ("boot.py" , "boot.txt" );
649648
650649 // Do USB setup even if boot.py is not run.
651650
652- supervisor_allocation * heap = allocate_remaining_memory ();
651+ supervisor_allocation * heap = allocate_remaining_memory ();
653652 start_mp (heap );
654653
655- #if CIRCUITPY_USB
654+ #if CIRCUITPY_USB
656655 // Set up default USB values after boot.py VM starts but before running boot.py.
657656 usb_set_defaults ();
658- #endif
657+ #endif
659658
660659 pyexec_result_t result = {0 , MP_OBJ_NULL , 0 };
661660
@@ -670,12 +669,12 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
670669 mp_printf (& mp_plat_print , "%s\nBoard ID:%s\n" , MICROPY_FULL_VERSION_INFO , CIRCUITPY_BOARD_ID );
671670
672671 bool found_boot = maybe_run_list (boot_py_filenames , & result );
673- (void ) found_boot ;
672+ (void )found_boot ;
674673
675674
676675 #ifdef CIRCUITPY_BOOT_OUTPUT_FILE
677676 // Get the base filesystem.
678- fs_user_mount_t * vfs = (fs_user_mount_t * ) MP_STATE_VM (vfs_mount_table )-> obj ;
677+ fs_user_mount_t * vfs = (fs_user_mount_t * )MP_STATE_VM (vfs_mount_table )-> obj ;
679678 FATFS * fs = & vfs -> fatfs ;
680679
681680 boot_output = NULL ;
@@ -684,7 +683,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
684683 if (f_open (fs , & boot_output_file , CIRCUITPY_BOOT_OUTPUT_FILE , FA_READ ) == FR_OK ) {
685684 char * file_contents = m_new (char , boot_text .alloc );
686685 UINT chars_read ;
687- if (f_read (& boot_output_file , file_contents , 1 + boot_text .len , & chars_read ) == FR_OK ) {
686+ if (f_read (& boot_output_file , file_contents , 1 + boot_text .len , & chars_read ) == FR_OK ) {
688687 write_boot_output =
689688 (chars_read != boot_text .len ) || (memcmp (boot_text .buf , file_contents , chars_read ) != 0 );
690689 }
@@ -708,7 +707,7 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
708707 #endif
709708 }
710709
711- #if CIRCUITPY_USB
710+ #if CIRCUITPY_USB
712711 // Some data needs to be carried over from the USB settings in boot.py
713712 // to the next VM, while the heap is still available.
714713 // Its size can vary, so save it temporarily on the stack,
@@ -717,21 +716,21 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
717716 size_t size = usb_boot_py_data_size ();
718717 uint8_t usb_boot_py_data [size ];
719718 usb_get_boot_py_data (usb_boot_py_data , size );
720- #endif
719+ #endif
721720
722721 cleanup_after_vm (heap , result .exception );
723722
724- #if CIRCUITPY_USB
723+ #if CIRCUITPY_USB
725724 // Now give back the data we saved from the heap going away.
726725 usb_return_boot_py_data (usb_boot_py_data , size );
727- #endif
726+ #endif
728727}
729728
730729STATIC int run_repl (void ) {
731730 int exit_code = PYEXEC_FORCED_EXIT ;
732731 stack_resize ();
733732 filesystem_flush ();
734- supervisor_allocation * heap = allocate_remaining_memory ();
733+ supervisor_allocation * heap = allocate_remaining_memory ();
735734 start_mp (heap );
736735
737736 #if CIRCUITPY_USB
@@ -876,7 +875,7 @@ void gc_collect(void) {
876875
877876 // This collects root pointers from the VFS mount table. Some of them may
878877 // have lost their references in the VM even though they are mounted.
879- gc_collect_root ((void * * )& MP_STATE_VM (vfs_mount_table ), sizeof (mp_vfs_mount_t ) / sizeof (mp_uint_t ));
878+ gc_collect_root ((void * * )& MP_STATE_VM (vfs_mount_table ), sizeof (mp_vfs_mount_t ) / sizeof (mp_uint_t ));
880879
881880 background_callback_gc_collect ();
882881
@@ -906,18 +905,20 @@ void gc_collect(void) {
906905
907906 // This naively collects all object references from an approximate stack
908907 // range.
909- gc_collect_root ((void * * )sp , ((uint32_t )port_stack_get_top () - sp ) / sizeof (uint32_t ));
908+ gc_collect_root ((void * * )sp , ((uint32_t )port_stack_get_top () - sp ) / sizeof (uint32_t ));
910909 gc_collect_end ();
911910}
912911
913912void NORETURN nlr_jump_fail (void * val ) {
914913 reset_into_safe_mode (MICROPY_NLR_JUMP_FAIL );
915- while (true) {}
914+ while (true) {
915+ }
916916}
917917
918918void NORETURN __fatal_error (const char * msg ) {
919919 reset_into_safe_mode (MICROPY_FATAL_ERROR );
920- while (true) {}
920+ while (true) {
921+ }
921922}
922923
923924#ifndef NDEBUG
0 commit comments