mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07: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:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user