Skip to content

Commit f2f845d

Browse files
committed
Fix Coverity issues
1 parent 5746b32 commit f2f845d

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

cmd/core/cmd_st.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ err_t cmdStCrc(octet crc[32], const char* prefix)
347347
state = buf + MAX2(buf_size, count);
348348
// определить имя исполняемого модуля
349349
code = cmdSysModulePath(name, &count);
350-
ERR_CALL_CHECK(code);
350+
ERR_CALL_HANDLE(code, cmdBlobClose(stack));
351351
// открыть исполнямый модуль
352352
code = cmdFileOpen(file, name, "rb");
353353
ERR_CALL_HANDLE(code, cmdBlobClose(stack));

cmd/core/cmd_sys.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
\brief Command-line interface to Bee2: system environment
55
\project bee2/cmd
66
\created 2025.04.20
7-
\version 2025.04.21
7+
\version 2025.04.23
88
\copyright The Bee2 authors
99
\license Licensed under the Apache License, Version 2.0 (see LICENSE.txt).
1010
*******************************************************************************
@@ -31,7 +31,7 @@ err_t cmdSysExePath(char* path, size_t* count)
3131
// определить длину пути
3232
if (!path)
3333
{
34-
len = wai_getExecutablePath(path, 0, 0);
34+
len = wai_getExecutablePath(0, 0, 0);
3535
if (len < 0)
3636
return ERR_SYS;
3737
if (++len <= 0 || (int)(size_t)len != len)
@@ -60,7 +60,7 @@ err_t cmdSysModulePath(char* path, size_t* count)
6060
// определить длину пути
6161
if (!path)
6262
{
63-
len = wai_getModulePath(path, 0, 0);
63+
len = wai_getModulePath(0, 0, 0);
6464
if (len < 0)
6565
return ERR_SYS;
6666
if (++len <= 0 || (int)(size_t)len != len)

test/core/file_test.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
\brief Tests for file management functions
55
\project bee2/test
66
\created 2025.04.13
7-
\version 2025.04.15
7+
\version 2025.04.23
88
\copyright The Bee2 authors
99
\license Licensed under the Apache License, Version 2.0 (see LICENSE.txt).
1010
*******************************************************************************
@@ -37,30 +37,29 @@ bool_t fileTest()
3737
// запись
3838
if (fileWrite( &len, beltH(), 12, file) != ERR_OK ||
3939
len != 12 || fileTell(file) != 12 ||
40-
!fileFlush(file))
41-
return FALSE;
40+
!fileFlush(file) ||
4241
// перемещение указателя
43-
if (!fileSeek(file, 20, SEEK_END) || fileTell(file) != 32 ||
42+
!fileSeek(file, 20, SEEK_END) || fileTell(file) != 32 ||
4443
!fileSeek(file, 7, SEEK_SET) || fileTell(file) != 7 ||
45-
!fileSeek(file, 8, SEEK_CUR) || fileTell(file) != 15)
46-
return FALSE;
44+
!fileSeek(file, 8, SEEK_CUR) || fileTell(file) != 15 ||
4745
// запись 2
48-
if (fileWrite2(file, beltH() + 12, 20) != 20 ||
49-
fileTell(file) != 35)
50-
return FALSE;
46+
fileWrite2(file, beltH() + 12, 20) != 20 ||
47+
fileTell(file) != 35 ||
5148
// чтение
52-
if (!fileSeek(file, 0, SEEK_SET) || fileTell(file) != 0 ||
49+
!fileSeek(file, 0, SEEK_SET) || fileTell(file) != 0 ||
5350
fileRead(&len, buf, sizeof(buf), file) != ERR_MAX ||
5451
len != 35 ||
5552
!memEq(buf, beltH(), 12) ||
5653
!memIsZero(buf + 12, 3) ||
57-
!memEq(buf + 15, beltH() + 12, 20))
58-
return FALSE;
54+
!memEq(buf + 15, beltH() + 12, 20) ||
5955
// чтение 2
60-
if (!fileSeek(file, 0, SEEK_SET) || fileTell(file) != 0 ||
56+
!fileSeek(file, 0, SEEK_SET) || fileTell(file) != 0 ||
6157
fileRead2(buf1, sizeof(buf1), file) != 35 ||
6258
!memEq(buf, buf1, 35))
59+
{
60+
fileClose(file);
6361
return FALSE;
62+
}
6463
// запись / чтение строки
6564
hexFrom(str, buf, 10);
6665
if (!filePuts(file, str) || fileTell(file) != 35 + 20 ||
@@ -70,7 +69,10 @@ bool_t fileTest()
7069
!fileSeek(file, 35, SEEK_SET) ||
7170
!fileGets(str1, sizeof(str1), file) ||
7271
!strEq(str, str1))
72+
{
73+
fileClose(file);
7374
return FALSE;
75+
}
7476
// закрыть файл
7577
if (!fileClose(file))
7678
return FALSE;

0 commit comments

Comments
 (0)