1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-13 13:29:50 +04:00

Naming and coding style convention, new linter tool. (#945)

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379245 additions and 373421 deletions

View File

@@ -13,11 +13,7 @@ typedef struct {
uint32_t timestamp;
} SavedStructHeader;
bool saved_struct_save(const char* path,
void* data,
size_t size,
uint8_t magic,
uint8_t version) {
bool saved_struct_save(const char* path, void* data, size_t size, uint8_t magic, uint8_t version) {
furi_assert(path);
furi_assert(data);
furi_assert(size);
@@ -32,10 +28,7 @@ bool saved_struct_save(const char* path,
bool saved = storage_file_open(file, path, FSAM_WRITE, FSOM_CREATE_ALWAYS);
if(!saved) {
FURI_LOG_E(
TAG,
"Open failed \"%s\". Error: \'%s\'",
path,
storage_file_get_error_desc(file));
TAG, "Open failed \"%s\". Error: \'%s\'", path, storage_file_get_error_desc(file));
result = false;
}
@@ -58,10 +51,7 @@ bool saved_struct_save(const char* path,
if(bytes_count != (size + sizeof(header))) {
FURI_LOG_E(
TAG,
"Write failed \"%s\". Error: \'%s\'",
path,
storage_file_get_error_desc(file));
TAG, "Write failed \"%s\". Error: \'%s\'", path, storage_file_get_error_desc(file));
result = false;
}
}
@@ -72,11 +62,7 @@ bool saved_struct_save(const char* path,
return result;
}
bool saved_struct_load(const char* path,
void* data,
size_t size,
uint8_t magic,
uint8_t version) {
bool saved_struct_load(const char* path, void* data, size_t size, uint8_t magic, uint8_t version) {
FURI_LOG_I(TAG, "Loading \"%s\"", path);
SavedStructHeader header;
@@ -86,16 +72,13 @@ bool saved_struct_load(const char* path,
File* file = storage_file_alloc(storage);
bool result = true;
bool loaded = storage_file_open(file, path, FSAM_READ, FSOM_OPEN_EXISTING);
if (!loaded) {
if(!loaded) {
FURI_LOG_E(
TAG,
"Failed to read \"%s\". Error: %s",
path,
storage_file_get_error_desc(file));
TAG, "Failed to read \"%s\". Error: %s", path, storage_file_get_error_desc(file));
result = false;
}
if (result) {
if(result) {
uint16_t bytes_count = storage_file_read(file, &header, sizeof(SavedStructHeader));
bytes_count += storage_file_read(file, data_read, size);
@@ -126,16 +109,12 @@ bool saved_struct_load(const char* path,
if(header.checksum != checksum) {
FURI_LOG_E(
TAG,
"Checksum(%d != %d) mismatch of file \"%s\"",
header.checksum,
checksum,
path);
TAG, "Checksum(%d != %d) mismatch of file \"%s\"", header.checksum, checksum, path);
result = false;
}
}
if (result) {
if(result) {
memcpy(data, data_read, size);
}
@@ -146,4 +125,3 @@ bool saved_struct_load(const char* path,
return result;
}