Remove execute permissions from *.c and *.h files (#1651)

* Add permission fix (no execute bit for source files) to fbt lint|format
* Remove execute bit from 59 source files using fbt format
* Also list which permissions are unwanted in lint.py
* Also remove exec permissions from lib/../rfal_nfc.c

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Walter Doekes 2022-08-29 18:20:57 +02:00 committed by GitHub
parent 274f17ed5a
commit 611b7e15ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 41 additions and 18 deletions

0
applications/bad_usb/views/bad_usb_view.h Executable file → Normal file
View file

0
applications/bt/bt_debug_app/views/bt_carrier_test.c Executable file → Normal file
View file

0
applications/bt/bt_debug_app/views/bt_test.c Executable file → Normal file
View file

0
applications/bt/bt_debug_app/views/bt_test.h Executable file → Normal file
View file

0
applications/bt/bt_hid_app/views/bt_hid_keynote.c Executable file → Normal file
View file

0
applications/bt/bt_hid_app/views/bt_hid_media.c Executable file → Normal file
View file

0
applications/bt/bt_settings_app/bt_settings_app.c Executable file → Normal file
View file

0
applications/bt/bt_settings_app/bt_settings_app.h Executable file → Normal file
View file

View file

View file

0
applications/cli/cli_i.h Executable file → Normal file
View file

0
applications/gpio/views/gpio_test.c Executable file → Normal file
View file

0
applications/gpio/views/gpio_test.h Executable file → Normal file
View file

0
applications/gpio/views/gpio_usb_uart.h Executable file → Normal file
View file

0
applications/gui/canvas.h Executable file → Normal file
View file

0
applications/gui/modules/dialog_ex.c Executable file → Normal file
View file

0
applications/gui/modules/menu.h Executable file → Normal file
View file

0
applications/gui/modules/text_box.c Executable file → Normal file
View file

0
applications/gui/modules/text_box.h Executable file → Normal file
View file

0
applications/gui/modules/variable_item_list.h Executable file → Normal file
View file

0
applications/gui/modules/widget.h Executable file → Normal file
View file

View file

View file

View file

0
applications/gui/scene_manager.c Executable file → Normal file
View file

0
applications/gui/scene_manager.h Executable file → Normal file
View file

0
applications/gui/scene_manager_i.h Executable file → Normal file
View file

0
applications/gui/view_dispatcher.h Executable file → Normal file
View file

0
applications/nfc/helpers/nfc_emv_parser.c Executable file → Normal file
View file

0
applications/nfc/helpers/nfc_emv_parser.h Executable file → Normal file
View file

0
applications/nfc/nfc_cli.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_config.h Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_delete.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_delete_success.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_emulate_uid.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_file_select.c Executable file → Normal file
View file

View file

0
applications/nfc/scenes/nfc_scene_read_card_success.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_set_atqa.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_set_sak.c Executable file → Normal file
View file

0
applications/nfc/scenes/nfc_scene_set_uid.c Executable file → Normal file
View file

0
applications/picopass/picopass_worker.h Executable file → Normal file
View file

0
applications/picopass/scenes/picopass_scene.c Executable file → Normal file
View file

0
applications/picopass/scenes/picopass_scene_config.h Executable file → Normal file
View file

View file

0
applications/power/battery_test_app/battery_test_app.c Executable file → Normal file
View file

0
applications/power/power_service/power_i.h Executable file → Normal file
View file

0
applications/system/system_settings.h Executable file → Normal file
View file

0
lib/ST25RFAL002/source/rfal_nfc.c Executable file → Normal file
View file

0
lib/nfc/nfc_worker.h Executable file → Normal file
View file

0
lib/nfc/protocols/emv.h Executable file → Normal file
View file

0
lib/nfc/protocols/nfca.c Executable file → Normal file
View file

View file

@ -88,7 +88,7 @@ class Main(App):
def _fix_filename(self, filename: str):
return filename.replace("-", "_")
def _replace_occurance(self, sources: list, old: str, new: str):
def _replace_occurrence(self, sources: list, old: str, new: str):
old = old.encode()
new = new.encode()
for source in sources:
@ -102,7 +102,7 @@ class Main(App):
pattern = re.compile(SOURCE_CODE_FILE_PATTERN)
good = []
bad = []
# Check sources for invalid filesname
# Check sources for invalid filenames
for source in sources:
basename = os.path.basename(source)
if not pattern.match(basename):
@ -113,40 +113,63 @@ class Main(App):
bad.append((source, basename, new_basename))
else:
good.append(source)
# Notify about errors or replace all occurances
# Notify about errors or replace all occurrences
if dry_run:
if len(bad) > 0:
self.logger.error(f"Found {len(bad)} incorrectly named files")
self.logger.info(bad)
return False
else:
# Replace occurances in text files
# Replace occurrences in text files
for source, old, new in bad:
self._replace_occurance(sources, old, new)
self._replace_occurrence(sources, old, new)
# Rename files
for source, old, new in bad:
shutil.move(source, source.replace(old, new))
return True
def check(self):
def _apply_file_permissions(self, sources: list, dry_run: bool = False):
execute_permissions = 0o111
pattern = re.compile(SOURCE_CODE_FILE_PATTERN)
good = []
bad = []
# Check sources for unexpected execute permissions
for source in sources:
st = os.stat(source)
perms_too_many = st.st_mode & execute_permissions
if perms_too_many:
good_perms = st.st_mode & ~perms_too_many
bad.append((source, oct(perms_too_many), good_perms))
else:
good.append(source)
# Notify or fix
if dry_run:
if len(bad) > 0:
self.logger.error(f"Found {len(bad)} incorrect permissions")
self.logger.info([record[0:2] for record in bad])
return False
else:
for source, perms_too_many, new_perms in bad:
os.chmod(source, new_perms)
return True
def _perform(self, dry_run: bool):
result = 0
sources = self._find_sources(self.args.input)
if not self._format_sources(sources, dry_run=True):
result |= 0b01
if not self._apply_file_naming_convention(sources, dry_run=True):
result |= 0b10
if not self._format_sources(sources, dry_run=dry_run):
result |= 0b001
if not self._apply_file_naming_convention(sources, dry_run=dry_run):
result |= 0b010
if not self._apply_file_permissions(sources, dry_run=dry_run):
result |= 0b100
self._check_folders(self.args.input)
return result
def check(self):
return self._perform(dry_run=True)
def format(self):
result = 0
sources = self._find_sources(self.args.input)
if not self._format_sources(sources):
result |= 0b01
if not self._apply_file_naming_convention(sources):
result |= 0b10
self._check_folders(self.args.input)
return result
return self._perform(dry_run=False)
if __name__ == "__main__":