Skip to content

Commit 1531863

Browse files
elliot-wdtlcfriedt
authored andcommitted
logging: count file with index 0 as log file too
Fixes zephyrproject-rtos#36667 If you had a single log file with index 0 created and you reboot the log backend wasn't counting it and was overwiting it. If you filled that file up before rebooting then it worked as expected, creating a new file at the next index on each boot. Signed-off-by: Elliot Revell-Nash <[email protected]>
1 parent 70393b3 commit 1531863

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/logging/log_backend_fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static int get_log_file_id(struct fs_dirent *ent)
239239

240240
num = atoi(ent->name + LOG_PREFIX_LEN);
241241

242-
if (num <= MAX_FILE_NUMERAL && num > 0) {
242+
if (num <= MAX_FILE_NUMERAL && num >= 0) {
243243
return num;
244244
}
245245

@@ -277,7 +277,7 @@ static int allocate_new_file(struct fs_file_t *file)
277277
}
278278

279279
file_num = get_log_file_id(&ent);
280-
if (file_num > 0) {
280+
if (file_num >= 0) {
281281

282282
if (file_num > max) {
283283
max = file_num;

0 commit comments

Comments
 (0)