Fixes in asprintf usage.

This commit is contained in:
Fotis Panagiotopoulos
2023-04-12 18:42:28 +03:00
committed by Xiang Xiao
parent cf54069487
commit c50ff7ff61
7 changed files with 42 additions and 39 deletions

View File

@@ -121,7 +121,6 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
FILE *stream;
unsigned long stack_size;
unsigned long stack_used;
int errcode;
int len;
int ret;
@@ -134,13 +133,11 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
ret = asprintf(&filepath,
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/status",
entryp->d_name);
if (ret < 0 || filepath == NULL)
if (ret < 0)
{
errcode = errno;
fprintf(stderr,
"Stack Monitor: Failed to create path to status file: %d\n",
errcode);
return -errcode;
"Stack Monitor: Failed to create path to status file\n");
return -ENOMEM;
}
/* Open the status file */
@@ -189,12 +186,10 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
ret = asprintf(&filepath,
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/stack",
entryp->d_name);
if (ret < 0 || filepath == NULL)
if (ret < 0)
{
errcode = errno;
fprintf(stderr,
"Stack Monitor: Failed to create path to stack file: %d\n",
errcode);
"Stack Monitor: Failed to create path to stack file\n");
ret = -EINVAL;
goto errout_with_name;
}