addressing few gcc 13 analyser warnings.

This commit is contained in:
David Carlier 2023-04-23 09:32:33 +01:00
parent f67b65c00a
commit 571f3f6fec
2 changed files with 15 additions and 12 deletions

View File

@ -575,10 +575,13 @@ void
Sys_RemoveDir(const char *path) Sys_RemoveDir(const char *path)
{ {
char filepath[MAX_OSPATH]; char filepath[MAX_OSPATH];
DIR *directory = opendir(path);
struct dirent *file; struct dirent *file;
DIR *directory;
if (Sys_IsDir(path)) if (Sys_IsDir(path))
{
directory = opendir(path);
if (directory)
{ {
while ((file = readdir(directory)) != NULL) while ((file = readdir(directory)) != NULL)
{ {
@ -590,6 +593,7 @@ Sys_RemoveDir(const char *path)
Sys_Remove(path); Sys_Remove(path);
} }
} }
}
qboolean qboolean
Sys_Realpath(const char *in, char *out, size_t size) Sys_Realpath(const char *in, char *out, size_t size)

View File

@ -5458,9 +5458,8 @@ PlayerDirectoryList(void)
} }
// malloc directories // malloc directories
char** data = (char**)malloc(num * sizeof(char*)); char** data = (char**)calloc(num, sizeof(char*));
YQ2_COM_CHECK_OOM(data, "malloc()", num * sizeof(char*)) YQ2_COM_CHECK_OOM(data, "calloc()", num * sizeof(char*))
memset(data, 0, num * sizeof(char*));
s_directory.data = data; s_directory.data = data;
s_directory.num = num; s_directory.num = num;
@ -5509,8 +5508,8 @@ PlayerModelList(void)
qboolean result = true; qboolean result = true;
// malloc models // malloc models
data = (char**)malloc(MAX_PLAYERMODELS * sizeof(char*)); data = (char**)calloc(MAX_PLAYERMODELS, sizeof(char*));
memset(data, 0, MAX_PLAYERMODELS * sizeof(char*)); YQ2_COM_CHECK_OOM(data, "calloc()", MAX_PLAYERMODELS * sizeof(char*))
s_modelname.data = data; s_modelname.data = data;
s_modelname.num = 0; s_modelname.num = 0;