1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/fmt: uncrustify

This commit is contained in:
Marian Buschsieweke 2022-06-02 15:31:13 +02:00
parent 68dcf27eab
commit ceeb28fb69
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -74,6 +74,7 @@ size_t fmt_byte_hex(char *out, uint8_t byte)
size_t fmt_bytes_hex(char *out, const uint8_t *ptr, size_t n) size_t fmt_bytes_hex(char *out, const uint8_t *ptr, size_t n)
{ {
size_t len = n * 2; size_t len = n * 2;
if (out) { if (out) {
while (n--) { while (n--) {
out += fmt_byte_hex(out, *ptr++); out += fmt_byte_hex(out, *ptr++);
@ -86,6 +87,7 @@ size_t fmt_bytes_hex(char *out, const uint8_t *ptr, size_t n)
size_t fmt_strlen(const char *str) size_t fmt_strlen(const char *str)
{ {
const char *tmp = str; const char *tmp = str;
while (*tmp) { while (*tmp) {
tmp++; tmp++;
} }
@ -95,6 +97,7 @@ size_t fmt_strlen(const char *str)
size_t fmt_strnlen(const char *str, size_t maxlen) size_t fmt_strnlen(const char *str, size_t maxlen)
{ {
const char *tmp = str; const char *tmp = str;
while (*tmp && maxlen--) { while (*tmp && maxlen--) {
tmp++; tmp++;
} }
@ -104,9 +107,11 @@ size_t fmt_strnlen(const char *str, size_t maxlen)
size_t fmt_str(char *out, const char *str) size_t fmt_str(char *out, const char *str)
{ {
int len = 0; int len = 0;
if (!out) { if (!out) {
len = fmt_strlen(str); len = fmt_strlen(str);
} else { }
else {
char c; char c;
while ((c = *str++)) { while ((c = *str++)) {
*out++ = c; *out++ = c;
@ -119,6 +124,7 @@ size_t fmt_str(char *out, const char *str)
size_t fmt_bytes_hex_reverse(char *out, const uint8_t *ptr, size_t n) size_t fmt_bytes_hex_reverse(char *out, const uint8_t *ptr, size_t n)
{ {
size_t i = n; size_t i = n;
while (i--) { while (i--) {
out += fmt_byte_hex(out, ptr[i]); out += fmt_byte_hex(out, ptr[i]);
} }
@ -270,6 +276,7 @@ size_t fmt_s64_dec(char *out, int64_t val)
{ {
unsigned negative = (val < 0); unsigned negative = (val < 0);
uint64_t sval; uint64_t sval;
if (negative) { if (negative) {
if (out) { if (out) {
*out++ = '-'; *out++ = '-';
@ -286,6 +293,7 @@ size_t fmt_s32_dec(char *out, int32_t val)
{ {
unsigned negative = (val < 0); unsigned negative = (val < 0);
uint32_t sval; uint32_t sval;
if (negative) { if (negative) {
if (out) { if (out) {
*out++ = '-'; *out++ = '-';
@ -460,6 +468,7 @@ size_t fmt_to_lower(char *out, const char *str)
uint32_t scn_u32_dec(const char *str, size_t n) uint32_t scn_u32_dec(const char *str, size_t n)
{ {
uint32_t res = 0; uint32_t res = 0;
while (n--) { while (n--) {
char c = *str++; char c = *str++;
if (!fmt_is_digit(c)) { if (!fmt_is_digit(c)) {
@ -527,6 +536,7 @@ void print_u32_dec(uint32_t val)
{ {
char buf[10]; /* "4294967295" */ char buf[10]; /* "4294967295" */
size_t len = fmt_u32_dec(buf, val); size_t len = fmt_u32_dec(buf, val);
print(buf, len); print(buf, len);
} }
@ -534,12 +544,14 @@ void print_s32_dec(int32_t val)
{ {
char buf[11]; /* "-2147483648" */ char buf[11]; /* "-2147483648" */
size_t len = fmt_s32_dec(buf, val); size_t len = fmt_s32_dec(buf, val);
print(buf, len); print(buf, len);
} }
void print_byte_hex(uint8_t byte) void print_byte_hex(uint8_t byte)
{ {
char buf[2]; char buf[2];
fmt_byte_hex(buf, byte); fmt_byte_hex(buf, byte);
print(buf, sizeof(buf)); print(buf, sizeof(buf));
} }
@ -547,6 +559,7 @@ void print_byte_hex(uint8_t byte)
void print_u32_hex(uint32_t val) void print_u32_hex(uint32_t val)
{ {
char buf[8]; char buf[8];
fmt_u32_hex(buf, val); fmt_u32_hex(buf, val);
print(buf, sizeof(buf)); print(buf, sizeof(buf));
} }
@ -561,6 +574,7 @@ void print_u64_dec(uint64_t val)
{ {
char buf[20]; /* "18446744073709551615" */ char buf[20]; /* "18446744073709551615" */
size_t len = fmt_u64_dec(buf, val); size_t len = fmt_u64_dec(buf, val);
print(buf, len); print(buf, len);
} }
@ -568,6 +582,7 @@ void print_s64_dec(uint64_t val)
{ {
char buf[20]; /* "-9223372036854775808" */ char buf[20]; /* "-9223372036854775808" */
size_t len = fmt_s64_dec(buf, val); size_t len = fmt_s64_dec(buf, val);
print(buf, len); print(buf, len);
} }
@ -575,6 +590,7 @@ void print_float(float f, unsigned precision)
{ {
char buf[19]; char buf[19];
size_t len = fmt_float(buf, f, precision); size_t len = fmt_float(buf, f, precision);
print(buf, len); print(buf, len);
} }