mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-13 13:29:50 +04:00
Api Symbols: replace asserts with checks (#3507)
* Api Symbols: replace asserts with checks * Api Symbols: replace asserts with checks part 2 * Update no args function signatures with void, to help compiler to track incorrect usage * More unavoidable void * Update PVS config and code to make it happy * Format sources * nfc: fix checks * dead code cleanup & include fixes Co-authored-by: gornekich <n.gorbadey@gmail.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -12,7 +12,7 @@ struct BitBuffer {
|
||||
};
|
||||
|
||||
BitBuffer* bit_buffer_alloc(size_t capacity_bytes) {
|
||||
furi_assert(capacity_bytes);
|
||||
furi_check(capacity_bytes);
|
||||
|
||||
BitBuffer* buf = malloc(sizeof(BitBuffer));
|
||||
|
||||
@@ -26,7 +26,7 @@ BitBuffer* bit_buffer_alloc(size_t capacity_bytes) {
|
||||
}
|
||||
|
||||
void bit_buffer_free(BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
free(buf->data);
|
||||
free(buf->parity);
|
||||
@@ -34,7 +34,7 @@ void bit_buffer_free(BitBuffer* buf) {
|
||||
}
|
||||
|
||||
void bit_buffer_reset(BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
memset(buf->data, 0, buf->capacity_bytes);
|
||||
size_t parity_buf_size = (buf->capacity_bytes + BITS_IN_BYTE - 1) / BITS_IN_BYTE;
|
||||
@@ -43,50 +43,50 @@ void bit_buffer_reset(BitBuffer* buf) {
|
||||
}
|
||||
|
||||
void bit_buffer_copy(BitBuffer* buf, const BitBuffer* other) {
|
||||
furi_assert(buf);
|
||||
furi_assert(other);
|
||||
furi_check(buf);
|
||||
furi_check(other);
|
||||
|
||||
if(buf == other) return;
|
||||
|
||||
furi_assert(buf->capacity_bytes * BITS_IN_BYTE >= other->size_bits);
|
||||
furi_check(buf->capacity_bytes * BITS_IN_BYTE >= other->size_bits);
|
||||
|
||||
memcpy(buf->data, other->data, bit_buffer_get_size_bytes(other));
|
||||
buf->size_bits = other->size_bits;
|
||||
}
|
||||
|
||||
void bit_buffer_copy_right(BitBuffer* buf, const BitBuffer* other, size_t start_index) {
|
||||
furi_assert(buf);
|
||||
furi_assert(other);
|
||||
furi_assert(bit_buffer_get_size_bytes(other) > start_index);
|
||||
furi_assert(buf->capacity_bytes >= bit_buffer_get_size_bytes(other) - start_index);
|
||||
furi_check(buf);
|
||||
furi_check(other);
|
||||
furi_check(bit_buffer_get_size_bytes(other) > start_index);
|
||||
furi_check(buf->capacity_bytes >= bit_buffer_get_size_bytes(other) - start_index);
|
||||
|
||||
memcpy(buf->data, other->data + start_index, bit_buffer_get_size_bytes(other) - start_index);
|
||||
buf->size_bits = other->size_bits - start_index * BITS_IN_BYTE;
|
||||
}
|
||||
|
||||
void bit_buffer_copy_left(BitBuffer* buf, const BitBuffer* other, size_t end_index) {
|
||||
furi_assert(buf);
|
||||
furi_assert(other);
|
||||
furi_assert(bit_buffer_get_capacity_bytes(buf) >= end_index);
|
||||
furi_assert(bit_buffer_get_size_bytes(other) >= end_index);
|
||||
furi_check(buf);
|
||||
furi_check(other);
|
||||
furi_check(bit_buffer_get_capacity_bytes(buf) >= end_index);
|
||||
furi_check(bit_buffer_get_size_bytes(other) >= end_index);
|
||||
|
||||
memcpy(buf->data, other->data, end_index);
|
||||
buf->size_bits = end_index * BITS_IN_BYTE;
|
||||
}
|
||||
|
||||
void bit_buffer_copy_bytes(BitBuffer* buf, const uint8_t* data, size_t size_bytes) {
|
||||
furi_assert(buf);
|
||||
furi_assert(data);
|
||||
furi_assert(buf->capacity_bytes >= size_bytes);
|
||||
furi_check(buf);
|
||||
furi_check(data);
|
||||
furi_check(buf->capacity_bytes >= size_bytes);
|
||||
|
||||
memcpy(buf->data, data, size_bytes);
|
||||
buf->size_bits = size_bytes * BITS_IN_BYTE;
|
||||
}
|
||||
|
||||
void bit_buffer_copy_bits(BitBuffer* buf, const uint8_t* data, size_t size_bits) {
|
||||
furi_assert(buf);
|
||||
furi_assert(data);
|
||||
furi_assert(buf->capacity_bytes * BITS_IN_BYTE >= size_bits);
|
||||
furi_check(buf);
|
||||
furi_check(data);
|
||||
furi_check(buf->capacity_bytes * BITS_IN_BYTE >= size_bits);
|
||||
|
||||
size_t size_bytes = (size_bits + BITS_IN_BYTE - 1) / BITS_IN_BYTE;
|
||||
memcpy(buf->data, data, size_bytes);
|
||||
@@ -94,8 +94,8 @@ void bit_buffer_copy_bits(BitBuffer* buf, const uint8_t* data, size_t size_bits)
|
||||
}
|
||||
|
||||
void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size_t size_bits) {
|
||||
furi_assert(buf);
|
||||
furi_assert(data);
|
||||
furi_check(buf);
|
||||
furi_check(data);
|
||||
|
||||
size_t bits_processed = 0;
|
||||
size_t curr_byte = 0;
|
||||
@@ -104,7 +104,7 @@ void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size
|
||||
buf->size_bits = size_bits;
|
||||
buf->data[0] = data[0];
|
||||
} else {
|
||||
furi_assert(size_bits % (BITS_IN_BYTE + 1) == 0);
|
||||
furi_check(size_bits % (BITS_IN_BYTE + 1) == 0);
|
||||
while(bits_processed < size_bits) {
|
||||
buf->data[curr_byte] = data[bits_processed / BITS_IN_BYTE] >>
|
||||
(bits_processed % BITS_IN_BYTE);
|
||||
@@ -126,9 +126,9 @@ void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size
|
||||
}
|
||||
|
||||
void bit_buffer_write_bytes(const BitBuffer* buf, void* dest, size_t size_bytes) {
|
||||
furi_assert(buf);
|
||||
furi_assert(dest);
|
||||
furi_assert(bit_buffer_get_size_bytes(buf) <= size_bytes);
|
||||
furi_check(buf);
|
||||
furi_check(dest);
|
||||
furi_check(bit_buffer_get_size_bytes(buf) <= size_bytes);
|
||||
|
||||
memcpy(dest, buf->data, bit_buffer_get_size_bytes(buf));
|
||||
}
|
||||
@@ -138,14 +138,14 @@ void bit_buffer_write_bytes_with_parity(
|
||||
void* dest,
|
||||
size_t size_bytes,
|
||||
size_t* bits_written) {
|
||||
furi_assert(buf);
|
||||
furi_assert(dest);
|
||||
furi_assert(bits_written);
|
||||
furi_check(buf);
|
||||
furi_check(dest);
|
||||
furi_check(bits_written);
|
||||
|
||||
size_t buf_size_bytes = bit_buffer_get_size_bytes(buf);
|
||||
size_t buf_size_with_parity_bytes =
|
||||
(buf_size_bytes * (BITS_IN_BYTE + 1) + BITS_IN_BYTE) / BITS_IN_BYTE;
|
||||
furi_assert(buf_size_with_parity_bytes <= size_bytes);
|
||||
furi_check(buf_size_with_parity_bytes <= size_bytes);
|
||||
|
||||
uint8_t next_par_bit = 0;
|
||||
uint16_t curr_bit_pos = 0;
|
||||
@@ -177,53 +177,53 @@ void bit_buffer_write_bytes_mid(
|
||||
void* dest,
|
||||
size_t start_index,
|
||||
size_t size_bytes) {
|
||||
furi_assert(buf);
|
||||
furi_assert(dest);
|
||||
furi_assert(start_index + size_bytes <= bit_buffer_get_size_bytes(buf));
|
||||
furi_check(buf);
|
||||
furi_check(dest);
|
||||
furi_check(start_index + size_bytes <= bit_buffer_get_size_bytes(buf));
|
||||
|
||||
memcpy(dest, buf->data + start_index, size_bytes);
|
||||
}
|
||||
|
||||
bool bit_buffer_has_partial_byte(const BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
return (buf->size_bits % BITS_IN_BYTE) != 0;
|
||||
}
|
||||
|
||||
bool bit_buffer_starts_with_byte(const BitBuffer* buf, uint8_t byte) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
return bit_buffer_get_size_bytes(buf) && (buf->data[0] == byte);
|
||||
}
|
||||
|
||||
size_t bit_buffer_get_capacity_bytes(const BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
return buf->capacity_bytes;
|
||||
}
|
||||
|
||||
size_t bit_buffer_get_size(const BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
return buf->size_bits;
|
||||
}
|
||||
|
||||
size_t bit_buffer_get_size_bytes(const BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
return (buf->size_bits / BITS_IN_BYTE) + (buf->size_bits % BITS_IN_BYTE ? 1 : 0);
|
||||
}
|
||||
|
||||
uint8_t bit_buffer_get_byte(const BitBuffer* buf, size_t index) {
|
||||
furi_assert(buf);
|
||||
furi_assert(buf->capacity_bytes > index);
|
||||
furi_check(buf);
|
||||
furi_check(buf->capacity_bytes > index);
|
||||
|
||||
return buf->data[index];
|
||||
}
|
||||
|
||||
uint8_t bit_buffer_get_byte_from_bit(const BitBuffer* buf, size_t index_bits) {
|
||||
furi_assert(buf);
|
||||
furi_assert(buf->capacity_bytes * BITS_IN_BYTE > index_bits);
|
||||
furi_check(buf);
|
||||
furi_check(buf->capacity_bytes * BITS_IN_BYTE > index_bits);
|
||||
|
||||
const size_t byte_index = index_bits / BITS_IN_BYTE;
|
||||
const size_t bit_offset = index_bits % BITS_IN_BYTE;
|
||||
@@ -235,29 +235,29 @@ uint8_t bit_buffer_get_byte_from_bit(const BitBuffer* buf, size_t index_bits) {
|
||||
}
|
||||
|
||||
const uint8_t* bit_buffer_get_data(const BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
return buf->data;
|
||||
}
|
||||
|
||||
const uint8_t* bit_buffer_get_parity(const BitBuffer* buf) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
return buf->parity;
|
||||
}
|
||||
|
||||
void bit_buffer_set_byte(BitBuffer* buf, size_t index, uint8_t byte) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
const size_t size_bytes = bit_buffer_get_size_bytes(buf);
|
||||
furi_assert(size_bytes > index);
|
||||
furi_check(size_bytes > index);
|
||||
|
||||
buf->data[index] = byte;
|
||||
}
|
||||
|
||||
void bit_buffer_set_byte_with_parity(BitBuffer* buff, size_t index, uint8_t byte, bool parity) {
|
||||
furi_assert(buff);
|
||||
furi_assert(buff->size_bits / BITS_IN_BYTE > index);
|
||||
furi_check(buff);
|
||||
furi_check(buff->size_bits / BITS_IN_BYTE > index);
|
||||
|
||||
buff->data[index] = byte;
|
||||
if((index % BITS_IN_BYTE) == 0) {
|
||||
@@ -268,15 +268,15 @@ void bit_buffer_set_byte_with_parity(BitBuffer* buff, size_t index, uint8_t byte
|
||||
}
|
||||
|
||||
void bit_buffer_set_size(BitBuffer* buf, size_t new_size) {
|
||||
furi_assert(buf);
|
||||
furi_assert(buf->capacity_bytes * BITS_IN_BYTE >= new_size);
|
||||
furi_check(buf);
|
||||
furi_check(buf->capacity_bytes * BITS_IN_BYTE >= new_size);
|
||||
|
||||
buf->size_bits = new_size;
|
||||
}
|
||||
|
||||
void bit_buffer_set_size_bytes(BitBuffer* buf, size_t new_size_bytes) {
|
||||
furi_assert(buf);
|
||||
furi_assert(buf->capacity_bytes >= new_size_bytes);
|
||||
furi_check(buf);
|
||||
furi_check(buf->capacity_bytes >= new_size_bytes);
|
||||
|
||||
buf->size_bits = new_size_bytes * BITS_IN_BYTE;
|
||||
}
|
||||
@@ -286,43 +286,43 @@ void bit_buffer_append(BitBuffer* buf, const BitBuffer* other) {
|
||||
}
|
||||
|
||||
void bit_buffer_append_right(BitBuffer* buf, const BitBuffer* other, size_t start_index) {
|
||||
furi_assert(buf);
|
||||
furi_assert(other);
|
||||
furi_check(buf);
|
||||
furi_check(other);
|
||||
|
||||
const size_t size_bytes = bit_buffer_get_size_bytes(buf);
|
||||
const size_t other_size_bytes = bit_buffer_get_size_bytes(other) - start_index;
|
||||
|
||||
furi_assert(buf->capacity_bytes >= size_bytes + other_size_bytes);
|
||||
furi_check(buf->capacity_bytes >= size_bytes + other_size_bytes);
|
||||
|
||||
memcpy(buf->data + size_bytes, other->data + start_index, other_size_bytes);
|
||||
buf->size_bits += other->size_bits - start_index * BITS_IN_BYTE;
|
||||
}
|
||||
|
||||
void bit_buffer_append_byte(BitBuffer* buf, uint8_t byte) {
|
||||
furi_assert(buf);
|
||||
furi_check(buf);
|
||||
|
||||
const size_t data_size_bytes = bit_buffer_get_size_bytes(buf);
|
||||
const size_t new_data_size_bytes = data_size_bytes + 1;
|
||||
furi_assert(new_data_size_bytes <= buf->capacity_bytes);
|
||||
furi_check(new_data_size_bytes <= buf->capacity_bytes);
|
||||
|
||||
buf->data[data_size_bytes] = byte;
|
||||
buf->size_bits = new_data_size_bytes * BITS_IN_BYTE;
|
||||
}
|
||||
|
||||
void bit_buffer_append_bytes(BitBuffer* buf, const uint8_t* data, size_t size_bytes) {
|
||||
furi_assert(buf);
|
||||
furi_assert(data);
|
||||
furi_check(buf);
|
||||
furi_check(data);
|
||||
|
||||
const size_t buf_size_bytes = bit_buffer_get_size_bytes(buf);
|
||||
furi_assert(buf->capacity_bytes >= buf_size_bytes + size_bytes);
|
||||
furi_check(buf->capacity_bytes >= buf_size_bytes + size_bytes);
|
||||
|
||||
memcpy(&buf->data[buf_size_bytes], data, size_bytes);
|
||||
buf->size_bits += size_bytes * BITS_IN_BYTE;
|
||||
}
|
||||
|
||||
void bit_buffer_append_bit(BitBuffer* buf, bool bit) {
|
||||
furi_assert(buf);
|
||||
furi_assert(
|
||||
furi_check(buf);
|
||||
furi_check(
|
||||
bit_buffer_get_size_bytes(buf) <=
|
||||
(buf->capacity_bytes - (bit_buffer_has_partial_byte(buf) ? 0 : 1)));
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ struct CompressIcon {
|
||||
uint8_t decoded_buff[COMPRESS_ICON_DECODED_BUFF_SIZE];
|
||||
};
|
||||
|
||||
CompressIcon* compress_icon_alloc() {
|
||||
CompressIcon* compress_icon_alloc(void) {
|
||||
CompressIcon* instance = malloc(sizeof(CompressIcon));
|
||||
instance->decoder = heatshrink_decoder_alloc(
|
||||
COMPRESS_ICON_ENCODED_BUFF_SIZE,
|
||||
@@ -40,15 +40,15 @@ CompressIcon* compress_icon_alloc() {
|
||||
}
|
||||
|
||||
void compress_icon_free(CompressIcon* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
heatshrink_decoder_free(instance->decoder);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void compress_icon_decode(CompressIcon* instance, const uint8_t* icon_data, uint8_t** decoded_buff) {
|
||||
furi_assert(instance);
|
||||
furi_assert(icon_data);
|
||||
furi_assert(decoded_buff);
|
||||
furi_check(instance);
|
||||
furi_check(icon_data);
|
||||
furi_check(decoded_buff);
|
||||
|
||||
CompressHeader* header = (CompressHeader*)icon_data;
|
||||
if(header->is_compressed) {
|
||||
@@ -64,7 +64,7 @@ void compress_icon_decode(CompressIcon* instance, const uint8_t* icon_data, uint
|
||||
instance->decoded_buff,
|
||||
sizeof(instance->decoded_buff),
|
||||
&data_processed);
|
||||
furi_assert((res == HSDR_POLL_EMPTY) || (res == HSDR_POLL_MORE));
|
||||
furi_check((res == HSDR_POLL_EMPTY) || (res == HSDR_POLL_MORE));
|
||||
if(res != HSDR_POLL_MORE) {
|
||||
break;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ Compress* compress_alloc(uint16_t compress_buff_size) {
|
||||
}
|
||||
|
||||
void compress_free(Compress* compress) {
|
||||
furi_assert(compress);
|
||||
furi_check(compress);
|
||||
|
||||
heatshrink_encoder_free(compress->encoder);
|
||||
heatshrink_decoder_free(compress->decoder);
|
||||
|
||||
@@ -19,7 +19,7 @@ typedef struct CompressIcon CompressIcon;
|
||||
*
|
||||
* @return Compress Icon instance
|
||||
*/
|
||||
CompressIcon* compress_icon_alloc();
|
||||
CompressIcon* compress_icon_alloc(void);
|
||||
|
||||
/** Free icon compressor
|
||||
*
|
||||
|
||||
@@ -14,6 +14,8 @@ struct DirWalk {
|
||||
};
|
||||
|
||||
DirWalk* dir_walk_alloc(Storage* storage) {
|
||||
furi_check(storage);
|
||||
|
||||
DirWalk* dir_walk = malloc(sizeof(DirWalk));
|
||||
dir_walk->path = furi_string_alloc();
|
||||
dir_walk->file = storage_file_alloc(storage);
|
||||
@@ -24,6 +26,8 @@ DirWalk* dir_walk_alloc(Storage* storage) {
|
||||
}
|
||||
|
||||
void dir_walk_free(DirWalk* dir_walk) {
|
||||
furi_check(dir_walk);
|
||||
|
||||
storage_file_free(dir_walk->file);
|
||||
furi_string_free(dir_walk->path);
|
||||
DirIndexList_clear(dir_walk->index_list);
|
||||
@@ -31,15 +35,18 @@ void dir_walk_free(DirWalk* dir_walk) {
|
||||
}
|
||||
|
||||
void dir_walk_set_recursive(DirWalk* dir_walk, bool recursive) {
|
||||
furi_check(dir_walk);
|
||||
dir_walk->recursive = recursive;
|
||||
}
|
||||
|
||||
void dir_walk_set_filter_cb(DirWalk* dir_walk, DirWalkFilterCb cb, void* context) {
|
||||
furi_check(dir_walk);
|
||||
dir_walk->filter_cb = cb;
|
||||
dir_walk->filter_context = context;
|
||||
}
|
||||
|
||||
bool dir_walk_open(DirWalk* dir_walk, const char* path) {
|
||||
furi_check(dir_walk);
|
||||
furi_string_set(dir_walk->path, path);
|
||||
dir_walk->current_index = 0;
|
||||
return storage_dir_open(dir_walk->file, path);
|
||||
@@ -139,14 +146,17 @@ static DirWalkResult
|
||||
}
|
||||
|
||||
FS_Error dir_walk_get_error(DirWalk* dir_walk) {
|
||||
furi_check(dir_walk);
|
||||
return storage_file_get_error(dir_walk->file);
|
||||
}
|
||||
|
||||
DirWalkResult dir_walk_read(DirWalk* dir_walk, FuriString* return_path, FileInfo* fileinfo) {
|
||||
furi_check(dir_walk);
|
||||
return dir_walk_iter(dir_walk, return_path, fileinfo);
|
||||
}
|
||||
|
||||
void dir_walk_close(DirWalk* dir_walk) {
|
||||
furi_check(dir_walk);
|
||||
if(storage_file_is_open(dir_walk->file)) {
|
||||
storage_dir_close(dir_walk->file);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "hex.h"
|
||||
#include <furi.h>
|
||||
|
||||
bool hex_char_to_hex_nibble(char c, uint8_t* nibble) {
|
||||
furi_check(nibble);
|
||||
|
||||
if((c >= '0' && c <= '9')) {
|
||||
*nibble = c - '0';
|
||||
return true;
|
||||
@@ -16,6 +19,8 @@ bool hex_char_to_hex_nibble(char c, uint8_t* nibble) {
|
||||
}
|
||||
|
||||
bool hex_char_to_uint8(char hi, char low, uint8_t* value) {
|
||||
furi_check(value);
|
||||
|
||||
uint8_t hi_nibble_value, low_nibble_value;
|
||||
|
||||
if(hex_char_to_hex_nibble(hi, &hi_nibble_value) &&
|
||||
@@ -28,6 +33,9 @@ bool hex_char_to_uint8(char hi, char low, uint8_t* value) {
|
||||
}
|
||||
|
||||
bool hex_chars_to_uint8(const char* value_str, uint8_t* value) {
|
||||
furi_check(value_str);
|
||||
furi_check(value);
|
||||
|
||||
bool parse_success = false;
|
||||
while(*value_str && value_str[1]) {
|
||||
parse_success = hex_char_to_uint8(*value_str, value_str[1], value++);
|
||||
@@ -38,6 +46,9 @@ bool hex_chars_to_uint8(const char* value_str, uint8_t* value) {
|
||||
}
|
||||
|
||||
bool hex_chars_to_uint64(const char* value_str, uint64_t* value) {
|
||||
furi_check(value_str);
|
||||
furi_check(value);
|
||||
|
||||
uint8_t* _value = (uint8_t*)value;
|
||||
bool parse_success = false;
|
||||
|
||||
@@ -45,10 +56,14 @@ bool hex_chars_to_uint64(const char* value_str, uint64_t* value) {
|
||||
parse_success = hex_char_to_uint8(value_str[i * 2], value_str[i * 2 + 1], &_value[7 - i]);
|
||||
if(!parse_success) break;
|
||||
}
|
||||
|
||||
return parse_success;
|
||||
}
|
||||
|
||||
void uint8_to_hex_chars(const uint8_t* src, uint8_t* target, int length) {
|
||||
furi_check(src);
|
||||
furi_check(target);
|
||||
|
||||
const char chars[] = "0123456789ABCDEF";
|
||||
while(--length >= 0)
|
||||
target[length] = chars[(src[length >> 1] >> ((1 - (length & 1)) << 2)) & 0xF];
|
||||
|
||||
@@ -53,7 +53,7 @@ static bool keys_dict_read_key_line(KeysDict* instance, FuriString* line, bool*
|
||||
}
|
||||
|
||||
bool keys_dict_check_presence(const char* path) {
|
||||
furi_assert(path);
|
||||
furi_check(path);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
@@ -65,16 +65,13 @@ bool keys_dict_check_presence(const char* path) {
|
||||
}
|
||||
|
||||
KeysDict* keys_dict_alloc(const char* path, KeysDictMode mode, size_t key_size) {
|
||||
furi_assert(path);
|
||||
furi_assert(key_size > 0);
|
||||
furi_check(path);
|
||||
furi_check(key_size > 0);
|
||||
|
||||
KeysDict* instance = malloc(sizeof(KeysDict));
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
furi_assert(storage);
|
||||
|
||||
instance->stream = buffered_file_stream_alloc(storage);
|
||||
furi_assert(instance->stream);
|
||||
|
||||
FS_OpenMode open_mode = (mode == KeysDictModeOpenAlways) ? FSOM_OPEN_ALWAYS :
|
||||
FSOM_OPEN_EXISTING;
|
||||
@@ -116,8 +113,8 @@ KeysDict* keys_dict_alloc(const char* path, KeysDictMode mode, size_t key_size)
|
||||
}
|
||||
|
||||
void keys_dict_free(KeysDict* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->stream);
|
||||
furi_check(instance);
|
||||
furi_check(instance->stream);
|
||||
|
||||
buffered_file_stream_close(instance->stream);
|
||||
stream_free(instance->stream);
|
||||
@@ -157,14 +154,14 @@ static void keys_dict_str_to_int(KeysDict* instance, FuriString* key_str, uint64
|
||||
}
|
||||
|
||||
size_t keys_dict_get_total_keys(KeysDict* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
return instance->total_keys;
|
||||
}
|
||||
|
||||
bool keys_dict_rewind(KeysDict* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->stream);
|
||||
furi_check(instance);
|
||||
furi_check(instance->stream);
|
||||
|
||||
return stream_rewind(instance->stream);
|
||||
}
|
||||
@@ -185,10 +182,10 @@ static bool keys_dict_get_next_key_str(KeysDict* instance, FuriString* key) {
|
||||
}
|
||||
|
||||
bool keys_dict_get_next_key(KeysDict* instance, uint8_t* key, size_t key_size) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->stream);
|
||||
furi_assert(instance->key_size == key_size);
|
||||
furi_assert(key);
|
||||
furi_check(instance);
|
||||
furi_check(instance->stream);
|
||||
furi_check(instance->key_size == key_size);
|
||||
furi_check(key);
|
||||
|
||||
FuriString* temp_key = furi_string_alloc();
|
||||
|
||||
@@ -237,10 +234,10 @@ static bool keys_dict_is_key_present_str(KeysDict* instance, FuriString* key) {
|
||||
}
|
||||
|
||||
bool keys_dict_is_key_present(KeysDict* instance, const uint8_t* key, size_t key_size) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->stream);
|
||||
furi_assert(instance->key_size == key_size);
|
||||
furi_assert(key);
|
||||
furi_check(instance);
|
||||
furi_check(instance->stream);
|
||||
furi_check(instance->key_size == key_size);
|
||||
furi_check(key);
|
||||
|
||||
FuriString* temp_key = furi_string_alloc();
|
||||
|
||||
@@ -274,13 +271,12 @@ static bool keys_dict_add_key_str(KeysDict* instance, FuriString* key) {
|
||||
}
|
||||
|
||||
bool keys_dict_add_key(KeysDict* instance, const uint8_t* key, size_t key_size) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->stream);
|
||||
furi_assert(instance->key_size == key_size);
|
||||
furi_assert(key);
|
||||
furi_check(instance);
|
||||
furi_check(instance->stream);
|
||||
furi_check(instance->key_size == key_size);
|
||||
furi_check(key);
|
||||
|
||||
FuriString* temp_key = furi_string_alloc();
|
||||
furi_assert(temp_key);
|
||||
|
||||
keys_dict_int_to_str(instance, key, temp_key);
|
||||
bool key_added = keys_dict_add_key_str(instance, temp_key);
|
||||
@@ -293,10 +289,10 @@ bool keys_dict_add_key(KeysDict* instance, const uint8_t* key, size_t key_size)
|
||||
}
|
||||
|
||||
bool keys_dict_delete_key(KeysDict* instance, const uint8_t* key, size_t key_size) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->stream);
|
||||
furi_assert(instance->key_size == key_size);
|
||||
furi_assert(key);
|
||||
furi_check(instance);
|
||||
furi_check(instance->stream);
|
||||
furi_check(instance->key_size == key_size);
|
||||
furi_check(key);
|
||||
|
||||
bool key_removed = false;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "manchester_encoder.h"
|
||||
#include <stdio.h>
|
||||
#include <furi.h>
|
||||
|
||||
void manchester_encoder_reset(ManchesterEncoderState* state) {
|
||||
furi_check(state);
|
||||
state->step = 0;
|
||||
}
|
||||
|
||||
@@ -9,6 +11,9 @@ bool manchester_encoder_advance(
|
||||
ManchesterEncoderState* state,
|
||||
const bool curr_bit,
|
||||
ManchesterEncoderResult* result) {
|
||||
furi_check(state);
|
||||
furi_check(result);
|
||||
|
||||
bool advance = false;
|
||||
switch(state->step) {
|
||||
case 0:
|
||||
@@ -41,14 +46,16 @@ bool manchester_encoder_advance(
|
||||
advance = true;
|
||||
break;
|
||||
default:
|
||||
printf("DO CRASH HERE\r\n");
|
||||
// furi_crash
|
||||
furi_crash();
|
||||
break;
|
||||
}
|
||||
return advance;
|
||||
}
|
||||
|
||||
ManchesterEncoderResult manchester_encoder_finish(ManchesterEncoderState* state) {
|
||||
furi_check(state);
|
||||
|
||||
state->step = 0;
|
||||
|
||||
return (state->prev_bit << 1) + state->prev_bit;
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ void name_generator_make_auto(char* name, size_t max_name_size, const char* pref
|
||||
}
|
||||
|
||||
void name_generator_make_random(char* name, size_t max_name_size) {
|
||||
furi_assert(name);
|
||||
furi_assert(max_name_size);
|
||||
furi_check(name);
|
||||
furi_check(max_name_size);
|
||||
|
||||
uint8_t name_generator_left_i = rand() % COUNT_OF(name_generator_left);
|
||||
uint8_t name_generator_right_i = rand() % COUNT_OF(name_generator_right);
|
||||
@@ -55,9 +55,9 @@ void name_generator_make_random(char* name, size_t max_name_size) {
|
||||
}
|
||||
|
||||
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix) {
|
||||
furi_assert(name);
|
||||
furi_assert(max_name_size);
|
||||
furi_assert(prefix);
|
||||
furi_check(name);
|
||||
furi_check(max_name_size);
|
||||
furi_check(prefix);
|
||||
|
||||
DateTime dateTime;
|
||||
furi_hal_rtc_get_datetime(&dateTime);
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#include <stddef.h>
|
||||
|
||||
void path_extract_filename_no_ext(const char* path, FuriString* filename) {
|
||||
furi_check(path);
|
||||
furi_check(filename);
|
||||
|
||||
furi_string_set(filename, path);
|
||||
|
||||
size_t start_position = furi_string_search_rchar(filename, '/');
|
||||
@@ -21,6 +24,9 @@ void path_extract_filename_no_ext(const char* path, FuriString* filename) {
|
||||
}
|
||||
|
||||
void path_extract_filename(FuriString* path, FuriString* name, bool trim_ext) {
|
||||
furi_check(path);
|
||||
furi_check(name);
|
||||
|
||||
size_t filename_start = furi_string_search_rchar(path, '/');
|
||||
if(filename_start > 0) {
|
||||
filename_start++;
|
||||
@@ -35,6 +41,9 @@ void path_extract_filename(FuriString* path, FuriString* name, bool trim_ext) {
|
||||
}
|
||||
|
||||
void path_extract_extension(FuriString* path, char* ext, size_t ext_len_max) {
|
||||
furi_check(path);
|
||||
furi_check(ext);
|
||||
|
||||
size_t dot = furi_string_search_rchar(path, '.');
|
||||
size_t filename_start = furi_string_search_rchar(path, '/');
|
||||
|
||||
@@ -51,6 +60,9 @@ static inline void path_cleanup(FuriString* path) {
|
||||
}
|
||||
|
||||
void path_extract_basename(const char* path, FuriString* basename) {
|
||||
furi_check(path);
|
||||
furi_check(basename);
|
||||
|
||||
furi_string_set(basename, path);
|
||||
path_cleanup(basename);
|
||||
size_t pos = furi_string_search_rchar(basename, '/');
|
||||
@@ -60,6 +72,9 @@ void path_extract_basename(const char* path, FuriString* basename) {
|
||||
}
|
||||
|
||||
void path_extract_dirname(const char* path, FuriString* dirname) {
|
||||
furi_check(path);
|
||||
furi_check(dirname);
|
||||
|
||||
furi_string_set(dirname, path);
|
||||
path_cleanup(dirname);
|
||||
size_t pos = furi_string_search_rchar(dirname, '/');
|
||||
@@ -69,6 +84,9 @@ void path_extract_dirname(const char* path, FuriString* dirname) {
|
||||
}
|
||||
|
||||
void path_append(FuriString* path, const char* suffix) {
|
||||
furi_check(path);
|
||||
furi_check(suffix);
|
||||
|
||||
path_cleanup(path);
|
||||
FuriString* suffix_str;
|
||||
suffix_str = furi_string_alloc_set(suffix);
|
||||
@@ -79,6 +97,10 @@ void path_append(FuriString* path, const char* suffix) {
|
||||
}
|
||||
|
||||
void path_concat(const char* path, const char* suffix, FuriString* out_path) {
|
||||
furi_check(path);
|
||||
furi_check(suffix);
|
||||
furi_check(out_path);
|
||||
|
||||
furi_string_set(out_path, path);
|
||||
path_append(out_path, suffix);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ void pretty_format_bytes_hex_canonical(
|
||||
const char* line_prefix,
|
||||
const uint8_t* data,
|
||||
size_t data_size) {
|
||||
furi_assert(data);
|
||||
furi_check(data);
|
||||
|
||||
bool is_truncated = false;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ struct Profiler {
|
||||
ProfilerRecordDict_t records;
|
||||
};
|
||||
|
||||
Profiler* profiler_alloc() {
|
||||
Profiler* profiler_alloc(void) {
|
||||
Profiler* profiler = malloc(sizeof(Profiler));
|
||||
ProfilerRecordDict_init(profiler->records);
|
||||
return profiler;
|
||||
|
||||
@@ -6,7 +6,7 @@ extern "C" {
|
||||
|
||||
typedef struct Profiler Profiler;
|
||||
|
||||
Profiler* profiler_alloc();
|
||||
Profiler* profiler_alloc(void);
|
||||
|
||||
void profiler_free(Profiler* profiler);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <core/check.h>
|
||||
|
||||
void property_value_out(PropertyValueContext* ctx, const char* fmt, unsigned int nparts, ...) {
|
||||
furi_assert(ctx);
|
||||
furi_check(ctx);
|
||||
furi_string_reset(ctx->key);
|
||||
|
||||
va_list args;
|
||||
|
||||
@@ -8,6 +8,8 @@ struct ProtocolDict {
|
||||
};
|
||||
|
||||
ProtocolDict* protocol_dict_alloc(const ProtocolBase** protocols, size_t count) {
|
||||
furi_check(protocols);
|
||||
|
||||
ProtocolDict* dict = malloc(sizeof(ProtocolDict));
|
||||
dict->base = protocols;
|
||||
dict->count = count;
|
||||
@@ -21,6 +23,8 @@ ProtocolDict* protocol_dict_alloc(const ProtocolBase** protocols, size_t count)
|
||||
}
|
||||
|
||||
void protocol_dict_free(ProtocolDict* dict) {
|
||||
furi_check(dict);
|
||||
|
||||
for(size_t i = 0; i < dict->count; i++) {
|
||||
dict->base[i]->free(dict->data[i]);
|
||||
}
|
||||
@@ -34,8 +38,9 @@ void protocol_dict_set_data(
|
||||
size_t protocol_index,
|
||||
const uint8_t* data,
|
||||
size_t data_size) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_assert(dict->base[protocol_index]->get_data != NULL);
|
||||
furi_check(protocol_index < dict->count);
|
||||
furi_check(dict->base[protocol_index]->get_data != NULL);
|
||||
|
||||
uint8_t* protocol_data = dict->base[protocol_index]->get_data(dict->data[protocol_index]);
|
||||
size_t protocol_data_size = dict->base[protocol_index]->data_size;
|
||||
furi_check(data_size >= protocol_data_size);
|
||||
@@ -47,8 +52,9 @@ void protocol_dict_get_data(
|
||||
size_t protocol_index,
|
||||
uint8_t* data,
|
||||
size_t data_size) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_assert(dict->base[protocol_index]->get_data != NULL);
|
||||
furi_check(protocol_index < dict->count);
|
||||
furi_check(dict->base[protocol_index]->get_data != NULL);
|
||||
|
||||
uint8_t* protocol_data = dict->base[protocol_index]->get_data(dict->data[protocol_index]);
|
||||
size_t protocol_data_size = dict->base[protocol_index]->data_size;
|
||||
furi_check(data_size >= protocol_data_size);
|
||||
@@ -56,11 +62,12 @@ void protocol_dict_get_data(
|
||||
}
|
||||
|
||||
size_t protocol_dict_get_data_size(ProtocolDict* dict, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
return dict->base[protocol_index]->data_size;
|
||||
}
|
||||
|
||||
size_t protocol_dict_get_max_data_size(ProtocolDict* dict) {
|
||||
furi_check(dict);
|
||||
size_t max_data_size = 0;
|
||||
for(size_t i = 0; i < dict->count; i++) {
|
||||
size_t data_size = dict->base[i]->data_size;
|
||||
@@ -73,16 +80,18 @@ size_t protocol_dict_get_max_data_size(ProtocolDict* dict) {
|
||||
}
|
||||
|
||||
const char* protocol_dict_get_name(ProtocolDict* dict, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
return dict->base[protocol_index]->name;
|
||||
}
|
||||
|
||||
const char* protocol_dict_get_manufacturer(ProtocolDict* dict, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
return dict->base[protocol_index]->manufacturer;
|
||||
}
|
||||
|
||||
void protocol_dict_decoders_start(ProtocolDict* dict) {
|
||||
furi_check(dict);
|
||||
|
||||
for(size_t i = 0; i < dict->count; i++) {
|
||||
ProtocolDecoderStart fn = dict->base[i]->decoder.start;
|
||||
|
||||
@@ -93,11 +102,13 @@ void protocol_dict_decoders_start(ProtocolDict* dict) {
|
||||
}
|
||||
|
||||
uint32_t protocol_dict_get_features(ProtocolDict* dict, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
return dict->base[protocol_index]->features;
|
||||
}
|
||||
|
||||
ProtocolId protocol_dict_decoders_feed(ProtocolDict* dict, bool level, uint32_t duration) {
|
||||
furi_check(dict);
|
||||
|
||||
bool done = false;
|
||||
ProtocolId ready_protocol_id = PROTOCOL_NO;
|
||||
|
||||
@@ -122,6 +133,8 @@ ProtocolId protocol_dict_decoders_feed_by_feature(
|
||||
uint32_t feature,
|
||||
bool level,
|
||||
uint32_t duration) {
|
||||
furi_check(dict);
|
||||
|
||||
bool done = false;
|
||||
ProtocolId ready_protocol_id = PROTOCOL_NO;
|
||||
|
||||
@@ -149,7 +162,7 @@ ProtocolId protocol_dict_decoders_feed_by_id(
|
||||
size_t protocol_index,
|
||||
bool level,
|
||||
uint32_t duration) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
|
||||
ProtocolId ready_protocol_id = PROTOCOL_NO;
|
||||
ProtocolDecoderFeed fn = dict->base[protocol_index]->decoder.feed;
|
||||
@@ -164,7 +177,7 @@ ProtocolId protocol_dict_decoders_feed_by_id(
|
||||
}
|
||||
|
||||
bool protocol_dict_encoder_start(ProtocolDict* dict, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
ProtocolEncoderStart fn = dict->base[protocol_index]->encoder.start;
|
||||
|
||||
if(fn) {
|
||||
@@ -175,7 +188,7 @@ bool protocol_dict_encoder_start(ProtocolDict* dict, size_t protocol_index) {
|
||||
}
|
||||
|
||||
LevelDuration protocol_dict_encoder_yield(ProtocolDict* dict, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
ProtocolEncoderYield fn = dict->base[protocol_index]->encoder.yield;
|
||||
|
||||
if(fn) {
|
||||
@@ -186,7 +199,7 @@ LevelDuration protocol_dict_encoder_yield(ProtocolDict* dict, size_t protocol_in
|
||||
}
|
||||
|
||||
void protocol_dict_render_data(ProtocolDict* dict, FuriString* result, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
ProtocolRenderData fn = dict->base[protocol_index]->render_data;
|
||||
|
||||
if(fn) {
|
||||
@@ -195,7 +208,7 @@ void protocol_dict_render_data(ProtocolDict* dict, FuriString* result, size_t pr
|
||||
}
|
||||
|
||||
void protocol_dict_render_brief_data(ProtocolDict* dict, FuriString* result, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
ProtocolRenderData fn = dict->base[protocol_index]->render_brief_data;
|
||||
|
||||
if(fn) {
|
||||
@@ -204,11 +217,13 @@ void protocol_dict_render_brief_data(ProtocolDict* dict, FuriString* result, siz
|
||||
}
|
||||
|
||||
uint32_t protocol_dict_get_validate_count(ProtocolDict* dict, size_t protocol_index) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
return dict->base[protocol_index]->validate_count;
|
||||
}
|
||||
|
||||
ProtocolId protocol_dict_get_protocol_by_name(ProtocolDict* dict, const char* name) {
|
||||
furi_check(dict);
|
||||
furi_check(name);
|
||||
for(size_t i = 0; i < dict->count; i++) {
|
||||
if(strcmp(name, protocol_dict_get_name(dict, i)) == 0) {
|
||||
return i;
|
||||
@@ -218,9 +233,9 @@ ProtocolId protocol_dict_get_protocol_by_name(ProtocolDict* dict, const char* na
|
||||
}
|
||||
|
||||
bool protocol_dict_get_write_data(ProtocolDict* dict, size_t protocol_index, void* data) {
|
||||
furi_assert(protocol_index < dict->count);
|
||||
furi_check(protocol_index < dict->count);
|
||||
ProtocolWriteData fn = dict->base[protocol_index]->write_data;
|
||||
|
||||
furi_assert(fn);
|
||||
furi_check(fn);
|
||||
return fn(dict->data[protocol_index], data);
|
||||
}
|
||||
@@ -13,7 +13,7 @@ struct PulseJoiner {
|
||||
Pulse pulses[PULSE_MAX_COUNT];
|
||||
};
|
||||
|
||||
PulseJoiner* pulse_joiner_alloc() {
|
||||
PulseJoiner* pulse_joiner_alloc(void) {
|
||||
PulseJoiner* pulse_joiner = malloc(sizeof(PulseJoiner));
|
||||
|
||||
pulse_joiner->pulse_index = 0;
|
||||
|
||||
@@ -13,7 +13,7 @@ typedef struct PulseJoiner PulseJoiner;
|
||||
*
|
||||
* @return PulseJoiner*
|
||||
*/
|
||||
PulseJoiner* pulse_joiner_alloc();
|
||||
PulseJoiner* pulse_joiner_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free PulseJoiner
|
||||
|
||||
@@ -6,7 +6,7 @@ struct PulseGlue {
|
||||
int32_t next_hi_period;
|
||||
};
|
||||
|
||||
PulseGlue* pulse_glue_alloc() {
|
||||
PulseGlue* pulse_glue_alloc(void) {
|
||||
PulseGlue* pulse_glue = malloc(sizeof(PulseGlue));
|
||||
pulse_glue_reset(pulse_glue);
|
||||
return pulse_glue;
|
||||
|
||||
@@ -14,7 +14,7 @@ extern "C" {
|
||||
|
||||
typedef struct PulseGlue PulseGlue;
|
||||
|
||||
PulseGlue* pulse_glue_alloc();
|
||||
PulseGlue* pulse_glue_alloc(void);
|
||||
void pulse_glue_free(PulseGlue* pulse_glue);
|
||||
void pulse_glue_reset(PulseGlue* pulse_glue);
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ typedef struct {
|
||||
} SavedStructHeader;
|
||||
|
||||
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);
|
||||
furi_check(path);
|
||||
furi_check(data);
|
||||
furi_check(size);
|
||||
SavedStructHeader header;
|
||||
|
||||
FURI_LOG_I(TAG, "Saving \"%s\"", path);
|
||||
@@ -131,8 +131,8 @@ bool saved_struct_get_payload_size(
|
||||
uint8_t magic,
|
||||
uint8_t version,
|
||||
size_t* payload_size) {
|
||||
furi_assert(path);
|
||||
furi_assert(payload_size);
|
||||
furi_check(path);
|
||||
furi_check(payload_size);
|
||||
|
||||
SavedStructHeader header;
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
@@ -15,15 +15,15 @@ SimpleArray* simple_array_alloc(const SimpleArrayConfig* config) {
|
||||
}
|
||||
|
||||
void simple_array_free(SimpleArray* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
simple_array_reset(instance);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void simple_array_init(SimpleArray* instance, uint32_t count) {
|
||||
furi_assert(instance);
|
||||
furi_assert(count > 0);
|
||||
furi_check(instance);
|
||||
furi_check(count > 0);
|
||||
|
||||
simple_array_reset(instance);
|
||||
|
||||
@@ -39,7 +39,7 @@ void simple_array_init(SimpleArray* instance, uint32_t count) {
|
||||
}
|
||||
|
||||
void simple_array_reset(SimpleArray* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
|
||||
if(instance->data) {
|
||||
SimpleArrayReset reset = instance->config->reset;
|
||||
@@ -58,9 +58,9 @@ void simple_array_reset(SimpleArray* instance) {
|
||||
}
|
||||
|
||||
void simple_array_copy(SimpleArray* instance, const SimpleArray* other) {
|
||||
furi_assert(instance);
|
||||
furi_assert(other);
|
||||
furi_assert(instance->config == other->config);
|
||||
furi_check(instance);
|
||||
furi_check(other);
|
||||
furi_check(instance->config == other->config);
|
||||
|
||||
simple_array_reset(instance);
|
||||
|
||||
@@ -81,8 +81,8 @@ void simple_array_copy(SimpleArray* instance, const SimpleArray* other) {
|
||||
}
|
||||
|
||||
bool simple_array_is_equal(const SimpleArray* instance, const SimpleArray* other) {
|
||||
furi_assert(instance);
|
||||
furi_assert(other);
|
||||
furi_check(instance);
|
||||
furi_check(other);
|
||||
|
||||
// Equal if the same object
|
||||
if(instance == other) return true;
|
||||
@@ -93,29 +93,31 @@ bool simple_array_is_equal(const SimpleArray* instance, const SimpleArray* other
|
||||
}
|
||||
|
||||
uint32_t simple_array_get_count(const SimpleArray* instance) {
|
||||
furi_assert(instance);
|
||||
furi_check(instance);
|
||||
return instance->count;
|
||||
}
|
||||
|
||||
SimpleArrayElement* simple_array_get(SimpleArray* instance, uint32_t index) {
|
||||
furi_assert(instance);
|
||||
furi_assert(index < instance->count);
|
||||
furi_check(instance);
|
||||
furi_check(index < instance->count);
|
||||
|
||||
return instance->data + index * instance->config->type_size;
|
||||
}
|
||||
|
||||
const SimpleArrayElement* simple_array_cget(const SimpleArray* instance, uint32_t index) {
|
||||
furi_check(instance);
|
||||
return simple_array_get((SimpleArrayElement*)instance, index);
|
||||
}
|
||||
|
||||
SimpleArrayData* simple_array_get_data(SimpleArray* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->data);
|
||||
furi_check(instance);
|
||||
furi_check(instance->data);
|
||||
|
||||
return instance->data;
|
||||
}
|
||||
|
||||
const SimpleArrayData* simple_array_cget_data(const SimpleArray* instance) {
|
||||
furi_check(instance);
|
||||
return simple_array_get_data((SimpleArray*)instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,14 +58,14 @@ bool buffered_file_stream_open(
|
||||
const char* path,
|
||||
FS_AccessMode access_mode,
|
||||
FS_OpenMode open_mode) {
|
||||
furi_assert(_stream);
|
||||
furi_check(_stream);
|
||||
BufferedFileStream* stream = (BufferedFileStream*)_stream;
|
||||
furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable);
|
||||
return file_stream_open(stream->file_stream, path, access_mode, open_mode);
|
||||
}
|
||||
|
||||
bool buffered_file_stream_close(Stream* _stream) {
|
||||
furi_assert(_stream);
|
||||
furi_check(_stream);
|
||||
BufferedFileStream* stream = (BufferedFileStream*)_stream;
|
||||
furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable);
|
||||
bool success = false;
|
||||
@@ -80,21 +80,21 @@ bool buffered_file_stream_close(Stream* _stream) {
|
||||
}
|
||||
|
||||
bool buffered_file_stream_sync(Stream* _stream) {
|
||||
furi_assert(_stream);
|
||||
furi_check(_stream);
|
||||
BufferedFileStream* stream = (BufferedFileStream*)_stream;
|
||||
furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable);
|
||||
return stream->sync_pending ? buffered_file_stream_flush(stream) : true;
|
||||
}
|
||||
|
||||
FS_Error buffered_file_stream_get_error(Stream* _stream) {
|
||||
furi_assert(_stream);
|
||||
furi_check(_stream);
|
||||
BufferedFileStream* stream = (BufferedFileStream*)_stream;
|
||||
furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable);
|
||||
return file_stream_get_error(stream->file_stream);
|
||||
}
|
||||
|
||||
static void buffered_file_stream_free(BufferedFileStream* stream) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
buffered_file_stream_sync((Stream*)stream);
|
||||
stream_free(stream->file_stream);
|
||||
stream_cache_free(stream->cache);
|
||||
|
||||
@@ -35,6 +35,8 @@ const StreamVTable file_stream_vtable = {
|
||||
};
|
||||
|
||||
Stream* file_stream_alloc(Storage* storage) {
|
||||
furi_check(storage);
|
||||
|
||||
FileStream* stream = malloc(sizeof(FileStream));
|
||||
stream->file = storage_file_alloc(storage);
|
||||
stream->storage = storage;
|
||||
@@ -48,21 +50,21 @@ bool file_stream_open(
|
||||
const char* path,
|
||||
FS_AccessMode access_mode,
|
||||
FS_OpenMode open_mode) {
|
||||
furi_assert(_stream);
|
||||
furi_check(_stream);
|
||||
FileStream* stream = (FileStream*)_stream;
|
||||
furi_check(stream->stream_base.vtable == &file_stream_vtable);
|
||||
return storage_file_open(stream->file, path, access_mode, open_mode);
|
||||
}
|
||||
|
||||
bool file_stream_close(Stream* _stream) {
|
||||
furi_assert(_stream);
|
||||
furi_check(_stream);
|
||||
FileStream* stream = (FileStream*)_stream;
|
||||
furi_check(stream->stream_base.vtable == &file_stream_vtable);
|
||||
return storage_file_close(stream->file);
|
||||
}
|
||||
|
||||
FS_Error file_stream_get_error(Stream* _stream) {
|
||||
furi_assert(_stream);
|
||||
furi_check(_stream);
|
||||
FileStream* stream = (FileStream*)_stream;
|
||||
furi_check(stream->stream_base.vtable == &file_stream_vtable);
|
||||
return storage_file_get_error(stream->file);
|
||||
|
||||
@@ -7,22 +7,22 @@
|
||||
#define STREAM_BUFFER_SIZE (32U)
|
||||
|
||||
void stream_free(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
stream->vtable->free(stream);
|
||||
}
|
||||
|
||||
void stream_clean(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
stream->vtable->clean(stream);
|
||||
}
|
||||
|
||||
bool stream_eof(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream->vtable->eof(stream);
|
||||
}
|
||||
|
||||
bool stream_seek(Stream* stream, int32_t offset, StreamOffset offset_type) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream->vtable->seek(stream, offset, offset_type);
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@ static bool stream_seek_to_char_backward(Stream* stream, char c) {
|
||||
}
|
||||
|
||||
bool stream_seek_to_char(Stream* stream, char c, StreamDirection direction) {
|
||||
furi_check(stream);
|
||||
|
||||
const size_t old_position = stream_tell(stream);
|
||||
|
||||
bool result = false;
|
||||
@@ -103,22 +105,22 @@ bool stream_seek_to_char(Stream* stream, char c, StreamDirection direction) {
|
||||
}
|
||||
|
||||
size_t stream_tell(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream->vtable->tell(stream);
|
||||
}
|
||||
|
||||
size_t stream_size(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream->vtable->size(stream);
|
||||
}
|
||||
|
||||
size_t stream_write(Stream* stream, const uint8_t* data, size_t size) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream->vtable->write(stream, data, size);
|
||||
}
|
||||
|
||||
size_t stream_read(Stream* stream, uint8_t* data, size_t size) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream->vtable->read(stream, data, size);
|
||||
}
|
||||
|
||||
@@ -127,7 +129,7 @@ bool stream_delete_and_insert(
|
||||
size_t delete_size,
|
||||
StreamWriteCB write_callback,
|
||||
const void* ctx) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream->vtable->delete_and_insert(stream, delete_size, write_callback, ctx);
|
||||
}
|
||||
|
||||
@@ -139,13 +141,16 @@ typedef struct {
|
||||
} StreamWriteData;
|
||||
|
||||
static bool stream_write_struct(Stream* stream, const void* context) {
|
||||
furi_assert(stream);
|
||||
furi_assert(context);
|
||||
furi_check(stream);
|
||||
furi_check(context);
|
||||
const StreamWriteData* write_data = context;
|
||||
return (stream_write(stream, write_data->data, write_data->size) == write_data->size);
|
||||
}
|
||||
|
||||
bool stream_read_line(Stream* stream, FuriString* str_result) {
|
||||
furi_check(stream);
|
||||
furi_check(str_result);
|
||||
|
||||
furi_string_reset(str_result);
|
||||
uint8_t buffer[STREAM_BUFFER_SIZE];
|
||||
|
||||
@@ -180,28 +185,28 @@ bool stream_read_line(Stream* stream, FuriString* str_result) {
|
||||
}
|
||||
|
||||
bool stream_rewind(Stream* stream) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_seek(stream, 0, StreamOffsetFromStart);
|
||||
}
|
||||
|
||||
size_t stream_write_char(Stream* stream, char c) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_write(stream, (const uint8_t*)&c, 1);
|
||||
}
|
||||
|
||||
size_t stream_write_string(Stream* stream, FuriString* string) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_write(
|
||||
stream, (const uint8_t*)furi_string_get_cstr(string), furi_string_size(string));
|
||||
}
|
||||
|
||||
size_t stream_write_cstring(Stream* stream, const char* string) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_write(stream, (const uint8_t*)string, strlen(string));
|
||||
}
|
||||
|
||||
size_t stream_write_format(Stream* stream, const char* format, ...) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
size_t size;
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
@@ -211,7 +216,7 @@ size_t stream_write_format(Stream* stream, const char* format, ...) {
|
||||
}
|
||||
|
||||
size_t stream_write_vaformat(Stream* stream, const char* format, va_list args) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
FuriString* data;
|
||||
data = furi_string_alloc_vprintf(format, args);
|
||||
size_t size = stream_write_string(stream, data);
|
||||
@@ -221,28 +226,28 @@ size_t stream_write_vaformat(Stream* stream, const char* format, va_list args) {
|
||||
}
|
||||
|
||||
bool stream_insert(Stream* stream, const uint8_t* data, size_t size) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
StreamWriteData write_data = {.data = data, .size = size};
|
||||
return stream_delete_and_insert(stream, 0, stream_write_struct, &write_data);
|
||||
}
|
||||
|
||||
bool stream_insert_char(Stream* stream, char c) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_delete_and_insert_char(stream, 0, c);
|
||||
}
|
||||
|
||||
bool stream_insert_string(Stream* stream, FuriString* string) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_delete_and_insert_string(stream, 0, string);
|
||||
}
|
||||
|
||||
bool stream_insert_cstring(Stream* stream, const char* string) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_delete_and_insert_cstring(stream, 0, string);
|
||||
}
|
||||
|
||||
bool stream_insert_format(Stream* stream, const char* format, ...) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
bool result = stream_insert_vaformat(stream, format, args);
|
||||
@@ -252,31 +257,31 @@ bool stream_insert_format(Stream* stream, const char* format, ...) {
|
||||
}
|
||||
|
||||
bool stream_insert_vaformat(Stream* stream, const char* format, va_list args) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_delete_and_insert_vaformat(stream, 0, format, args);
|
||||
}
|
||||
|
||||
bool stream_delete_and_insert_char(Stream* stream, size_t delete_size, char c) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
StreamWriteData write_data = {.data = (uint8_t*)&c, .size = 1};
|
||||
return stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data);
|
||||
}
|
||||
|
||||
bool stream_delete_and_insert_string(Stream* stream, size_t delete_size, FuriString* string) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
StreamWriteData write_data = {
|
||||
.data = (uint8_t*)furi_string_get_cstr(string), .size = furi_string_size(string)};
|
||||
return stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data);
|
||||
}
|
||||
|
||||
bool stream_delete_and_insert_cstring(Stream* stream, size_t delete_size, const char* string) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
StreamWriteData write_data = {.data = (uint8_t*)string, .size = strlen(string)};
|
||||
return stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data);
|
||||
}
|
||||
|
||||
bool stream_delete_and_insert_format(Stream* stream, size_t delete_size, const char* format, ...) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
bool result = stream_delete_and_insert_vaformat(stream, delete_size, format, args);
|
||||
@@ -290,9 +295,9 @@ bool stream_delete_and_insert_vaformat(
|
||||
size_t delete_size,
|
||||
const char* format,
|
||||
va_list args) {
|
||||
furi_assert(stream);
|
||||
FuriString* data;
|
||||
data = furi_string_alloc_vprintf(format, args);
|
||||
furi_check(stream);
|
||||
|
||||
FuriString* data = furi_string_alloc_vprintf(format, args);
|
||||
StreamWriteData write_data = {
|
||||
.data = (uint8_t*)furi_string_get_cstr(data), .size = furi_string_size(data)};
|
||||
bool result = stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data);
|
||||
@@ -302,11 +307,14 @@ bool stream_delete_and_insert_vaformat(
|
||||
}
|
||||
|
||||
bool stream_delete(Stream* stream, size_t size) {
|
||||
furi_assert(stream);
|
||||
furi_check(stream);
|
||||
return stream_delete_and_insert(stream, size, NULL, NULL);
|
||||
}
|
||||
|
||||
size_t stream_copy(Stream* stream_from, Stream* stream_to, size_t size) {
|
||||
furi_check(stream_from);
|
||||
furi_check(stream_to);
|
||||
|
||||
uint8_t* buffer = malloc(STREAM_CACHE_SIZE);
|
||||
size_t copied = 0;
|
||||
|
||||
@@ -330,6 +338,9 @@ size_t stream_copy(Stream* stream_from, Stream* stream_to, size_t size) {
|
||||
}
|
||||
|
||||
size_t stream_copy_full(Stream* stream_from, Stream* stream_to) {
|
||||
furi_check(stream_from);
|
||||
furi_check(stream_to);
|
||||
|
||||
size_t was_written = 0;
|
||||
|
||||
do {
|
||||
@@ -342,6 +353,8 @@ size_t stream_copy_full(Stream* stream_from, Stream* stream_to) {
|
||||
}
|
||||
|
||||
bool stream_split(Stream* stream, Stream* stream_left, Stream* stream_right) {
|
||||
furi_check(stream);
|
||||
|
||||
bool result = false;
|
||||
size_t size = stream_size(stream);
|
||||
size_t tell = stream_tell(stream);
|
||||
@@ -363,6 +376,9 @@ bool stream_split(Stream* stream, Stream* stream_left, Stream* stream_right) {
|
||||
}
|
||||
|
||||
size_t stream_load_from_file(Stream* stream, Storage* storage, const char* path) {
|
||||
furi_check(stream);
|
||||
furi_check(storage);
|
||||
|
||||
size_t was_written = 0;
|
||||
Stream* file = file_stream_alloc(storage);
|
||||
|
||||
@@ -376,6 +392,9 @@ size_t stream_load_from_file(Stream* stream, Storage* storage, const char* path)
|
||||
}
|
||||
|
||||
size_t stream_save_to_file(Stream* stream, Storage* storage, const char* path, FS_OpenMode mode) {
|
||||
furi_check(stream);
|
||||
furi_check(storage);
|
||||
|
||||
size_t was_written = 0;
|
||||
Stream* file = file_stream_alloc(storage);
|
||||
|
||||
@@ -389,6 +408,8 @@ size_t stream_save_to_file(Stream* stream, Storage* storage, const char* path, F
|
||||
}
|
||||
|
||||
void stream_dump_data(Stream* stream) {
|
||||
furi_check(stream);
|
||||
|
||||
size_t size = stream_size(stream);
|
||||
size_t tell = stream_tell(stream);
|
||||
printf("stream %p\r\n", stream);
|
||||
|
||||
@@ -8,7 +8,7 @@ struct StreamCache {
|
||||
size_t position;
|
||||
};
|
||||
|
||||
StreamCache* stream_cache_alloc() {
|
||||
StreamCache* stream_cache_alloc(void) {
|
||||
StreamCache* cache = malloc(sizeof(StreamCache));
|
||||
cache->data_size = 0;
|
||||
cache->position = 0;
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef struct StreamCache StreamCache;
|
||||
* Allocate stream cache.
|
||||
* @return StreamCache* pointer to a StreamCache instance
|
||||
*/
|
||||
StreamCache* stream_cache_alloc();
|
||||
StreamCache* stream_cache_alloc(void);
|
||||
|
||||
/**
|
||||
* Free stream cache.
|
||||
|
||||
@@ -37,7 +37,7 @@ const StreamVTable string_stream_vtable = {
|
||||
.delete_and_insert = (StreamDeleteAndInsertFn)string_stream_delete_and_insert,
|
||||
};
|
||||
|
||||
Stream* string_stream_alloc() {
|
||||
Stream* string_stream_alloc(void) {
|
||||
StringStream* stream = malloc(sizeof(StringStream));
|
||||
stream->string = furi_string_alloc();
|
||||
stream->index = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@ extern "C" {
|
||||
* Allocate string stream
|
||||
* @return Stream*
|
||||
*/
|
||||
Stream* string_stream_alloc();
|
||||
Stream* string_stream_alloc(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ TarArchive* tar_archive_alloc(Storage* storage) {
|
||||
}
|
||||
|
||||
bool tar_archive_open(TarArchive* archive, const char* path, TarOpenMode mode) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
FS_AccessMode access_mode;
|
||||
FS_OpenMode open_mode;
|
||||
int mtar_access = 0;
|
||||
@@ -90,7 +90,7 @@ bool tar_archive_open(TarArchive* archive, const char* path, TarOpenMode mode) {
|
||||
}
|
||||
|
||||
void tar_archive_free(TarArchive* archive) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
if(mtar_is_open(&archive->tar)) {
|
||||
mtar_close(&archive->tar);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void tar_archive_free(TarArchive* archive) {
|
||||
}
|
||||
|
||||
void tar_archive_set_file_callback(TarArchive* archive, tar_unpack_file_cb callback, void* context) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
archive->unpack_cb = callback;
|
||||
archive->unpack_cb_context = context;
|
||||
}
|
||||
@@ -113,6 +113,7 @@ static int tar_archive_entry_counter(mtar_t* tar, const mtar_header_t* header, v
|
||||
}
|
||||
|
||||
int32_t tar_archive_get_entries_count(TarArchive* archive) {
|
||||
furi_check(archive);
|
||||
int32_t counter = 0;
|
||||
if(mtar_foreach(&archive->tar, tar_archive_entry_counter, &counter) != MTAR_ESUCCESS) {
|
||||
counter = -1;
|
||||
@@ -121,12 +122,12 @@ int32_t tar_archive_get_entries_count(TarArchive* archive) {
|
||||
}
|
||||
|
||||
bool tar_archive_dir_add_element(TarArchive* archive, const char* dirpath) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
return (mtar_write_dir_header(&archive->tar, dirpath) == MTAR_ESUCCESS);
|
||||
}
|
||||
|
||||
bool tar_archive_finalize(TarArchive* archive) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
return (mtar_finalize(&archive->tar) == MTAR_ESUCCESS);
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ bool tar_archive_store_data(
|
||||
const char* path,
|
||||
const uint8_t* data,
|
||||
const int32_t data_len) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
|
||||
return (
|
||||
tar_archive_file_add_header(archive, path, data_len) &&
|
||||
@@ -144,7 +145,7 @@ bool tar_archive_store_data(
|
||||
}
|
||||
|
||||
bool tar_archive_file_add_header(TarArchive* archive, const char* path, const int32_t data_len) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
|
||||
return (mtar_write_file_header(&archive->tar, path, data_len) == MTAR_ESUCCESS);
|
||||
}
|
||||
@@ -153,13 +154,13 @@ bool tar_archive_file_add_data_block(
|
||||
TarArchive* archive,
|
||||
const uint8_t* data_block,
|
||||
const int32_t block_len) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
|
||||
return (mtar_write_data(&archive->tar, data_block, block_len) == block_len);
|
||||
}
|
||||
|
||||
bool tar_archive_file_finalize(TarArchive* archive) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
return (mtar_end_data(&archive->tar) == MTAR_ESUCCESS);
|
||||
}
|
||||
|
||||
@@ -259,7 +260,7 @@ bool tar_archive_unpack_to(
|
||||
TarArchive* archive,
|
||||
const char* destination,
|
||||
Storage_name_converter converter) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
TarArchiveDirectoryOpParams param = {
|
||||
.archive = archive,
|
||||
.work_dir = destination,
|
||||
@@ -276,7 +277,7 @@ bool tar_archive_add_file(
|
||||
const char* fs_file_path,
|
||||
const char* archive_fname,
|
||||
const int32_t file_size) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
uint8_t* file_buffer = malloc(FILE_BLOCK_SIZE);
|
||||
bool success = false;
|
||||
File* src_file = storage_file_alloc(archive->storage);
|
||||
@@ -314,8 +315,9 @@ bool tar_archive_add_file(
|
||||
}
|
||||
|
||||
bool tar_archive_add_dir(TarArchive* archive, const char* fs_full_path, const char* path_prefix) {
|
||||
furi_assert(archive);
|
||||
furi_check(archive);
|
||||
furi_check(path_prefix);
|
||||
|
||||
File* directory = storage_file_alloc(archive->storage);
|
||||
FileInfo file_info;
|
||||
|
||||
@@ -376,9 +378,9 @@ bool tar_archive_unpack_file(
|
||||
TarArchive* archive,
|
||||
const char* archive_fname,
|
||||
const char* destination) {
|
||||
furi_assert(archive);
|
||||
furi_assert(archive_fname);
|
||||
furi_assert(destination);
|
||||
furi_check(archive);
|
||||
furi_check(archive_fname);
|
||||
furi_check(destination);
|
||||
if(mtar_find(&archive->tar, archive_fname) != MTAR_ESUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user