lint: satisfy some nullability annotations

This commit is contained in:
2025-06-11 14:40:21 +02:00
parent 4e18df55bf
commit 2bdb57390d
5 changed files with 50 additions and 47 deletions

View File

@@ -7,18 +7,8 @@
#include "desktop.h"
#include "macros.h"
#define NOK \
{ \
ret = -1; \
break; \
}
#define NOKFKEY \
{ \
free(key); \
NOK \
}
int read_desktop(FILE* fd, void* ctx,
struct status (*cb)(void* ctx, char* NULLABLE table, char* key,
struct status (*cb)(void* ctx, char* table, char* key,
char* value)) {
char* table_name = NULL;
@@ -47,7 +37,10 @@ int read_desktop(FILE* fd, void* ctx,
// impossible with a min len of 1 (empty line)
if (eq_idx == 0) continue;
// Check its not end
if (buf[eq_idx] != '=') NOK;
if (buf[eq_idx] != '=') {
ret = -1;
break;
}
// Key & Value
char* key = buf;
@@ -64,11 +57,8 @@ int read_desktop(FILE* fd, void* ctx,
}
}
free(table_name);
if (table_name != NULL) free(table_name);
if (buf != NULL) free(buf);
return ret;
}
#undef NOK
#undef NOKFKEY
// NOLINTEND(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,readability-function-cognitive-complexity)