Skip to content

Commit 3d65f25

Browse files
committed
Merge branch 'clang-fmt'
2 parents 70d4f3c + 0f7b4ff commit 3d65f25

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/hardware-fakes/src/fake_memory.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
#include <memory/memory.h>
1818
#include <memory/memory_shared.h>
1919
#include <stdio.h>
20+
#include <stdlib.h>
2021
#include <string.h>
2122
#include <sys/stat.h>
22-
#include <stdlib.h>
23-
2423

2524
#define FAKE_MEMORY_ENV_VAR "FAKE_MEMORY_FILEPATH"
2625
#define SHARED_SUFFIX "shared"
@@ -39,7 +38,7 @@ static void _init_file_if_needed(
3938
{
4039
char path[512];
4140
int written = snprintf(path, sizeof(path), "%s_%s", base_path, suffix);
42-
if (written <0 || (size_t) written >= sizeof(path)) {
41+
if (written < 0 || (size_t)written >= sizeof(path)) {
4342
fprintf(stderr, "file path %s_%s too long\n", base_path, suffix);
4443
exit(EXIT_FAILURE);
4544
}
@@ -67,9 +66,11 @@ void fake_memory_factoryreset(void)
6766

6867
const char* base_path = getenv(FAKE_MEMORY_ENV_VAR);
6968
if (base_path) {
70-
_init_file_if_needed(base_path, SHARED_SUFFIX, _memory_shared_data, sizeof(_memory_shared_data));
69+
_init_file_if_needed(
70+
base_path, SHARED_SUFFIX, _memory_shared_data, sizeof(_memory_shared_data));
7171
_init_file_if_needed(base_path, APP_SUFFIX, _memory_app_data, sizeof(_memory_app_data));
72-
_init_file_if_needed(base_path, EEPROM_SUFFIX, _memory_smarteeprom, sizeof(_memory_smarteeprom));
72+
_init_file_if_needed(
73+
base_path, EEPROM_SUFFIX, _memory_smarteeprom, sizeof(_memory_smarteeprom));
7374
}
7475
}
7576

@@ -115,7 +116,7 @@ static void _write_file_chunk(const char* suffix, uint32_t offset, const uint8_t
115116
return;
116117
}
117118
int written = snprintf(path, sizeof(path), "%s_%s", base_path, suffix);
118-
if (written <0 || (size_t) written >= sizeof(path)) {
119+
if (written < 0 || (size_t)written >= sizeof(path)) {
119120
fprintf(stderr, "file path %s_%s too long\n", base_path, suffix);
120121
exit(EXIT_FAILURE);
121122
}
@@ -137,7 +138,7 @@ static void _read_file_chunk(const char* suffix, uint32_t offset, uint8_t* chunk
137138
return;
138139
}
139140
int written = snprintf(path, sizeof(path), "%s_%s", base_path, suffix);
140-
if (written <0 || (size_t) written >= sizeof(path)) {
141+
if (written < 0 || (size_t)written >= sizeof(path)) {
141142
fprintf(stderr, "file path %s_%s too long\n", base_path, suffix);
142143
exit(EXIT_FAILURE);
143144
}

0 commit comments

Comments
 (0)