system: nxstyle fixes

fixes for errors reported by the nxstyle tool

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea
2021-06-10 18:40:35 +02:00
committed by Xiang Xiao
parent 395b0094a5
commit aa581fe5ce
31 changed files with 821 additions and 373 deletions

View File

@@ -114,7 +114,6 @@ static FAR char *stkmon_isolate_value(FAR char *line)
****************************************************************************/
static int stkmon_process_directory(FAR struct dirent *entryp)
{
FAR char *filepath;
FAR char *endptr;
@@ -132,12 +131,14 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
/* Read the task status to get the task name */
filepath = NULL;
ret = asprintf(&filepath, CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/status",
ret = asprintf(&filepath,
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/status",
entryp->d_name);
if (ret < 0 || filepath == NULL)
{
errcode = errno;
fprintf(stderr, "Stack Monitor: Failed to create path to status file: %d\n",
fprintf(stderr,
"Stack Monitor: Failed to create path to status file: %d\n",
errcode);
return -errcode;
}
@@ -185,12 +186,14 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
stack_used = 0;
filepath = NULL;
ret = asprintf(&filepath, CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/stack",
ret = asprintf(&filepath,
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/stack",
entryp->d_name);
if (ret < 0 || filepath == NULL)
{
errcode = errno;
fprintf(stderr, "Stack Monitor: Failed to create path to stack file: %d\n",
fprintf(stderr,
"Stack Monitor: Failed to create path to stack file: %d\n",
errcode);
ret = -EINVAL;
goto errout_with_name;
@@ -223,7 +226,8 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
stack_size = (uint32_t)strtoul(tmpstr, &endptr, 10);
if (*endptr != '\0')
{
fprintf(stderr, "Stack Monitor: Bad numeric value %s\n", tmpstr);
fprintf(stderr,
"Stack Monitor: Bad numeric value %s\n", tmpstr);
ret = -EINVAL;
goto errout_with_stream;
}
@@ -243,7 +247,8 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
stack_used = (uint32_t)strtoul(tmpstr, &endptr, 10);
if (*endptr != '\0')
{
fprintf(stderr, "Stack Monitor: Bad numeric value %s\n", tmpstr);
fprintf(stderr,
"Stack Monitor: Bad numeric value %s\n", tmpstr);
ret = -EINVAL;
goto errout_with_stream;
}
@@ -254,9 +259,11 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
/* Finally, output the stack info that we gleaned from the procfs */
#if CONFIG_TASK_NAME_SIZE > 0
printf("%5s %6lu %6lu %s\n", entryp->d_name, stack_size, stack_used, name);
printf("%5s %6lu %6lu %s\n",
entryp->d_name, stack_size, stack_used, name);
#else
printf("%5s %6lu %6lu\n", entryp->d_name, stack_size, stack_used);
printf("%5s %6lu %6lu\n",
entryp->d_name, stack_size, stack_used);
#endif
ret = OK;
@@ -274,6 +281,7 @@ errout_with_name:
free(name);
}
#endif
return ret;
}
@@ -333,7 +341,8 @@ static int stackmonitor_daemon(int argc, char **argv)
if (++errcount > 100)
{
fprintf(stderr, "Stack Monitor: Too many errors ... exiting\n");
fprintf(stderr,
"Stack Monitor: Too many errors ... exiting\n");
exitcode = EXIT_FAILURE;
break;
}
@@ -373,13 +382,14 @@ static int stackmonitor_daemon(int argc, char **argv)
{
/* Failed to process the thread directory */
fprintf(stderr,
"Stack Monitor: Failed to process sub-directory: %s\n",
fprintf(stderr, "Stack Monitor: "
"Failed to process sub-directory: %s\n",
entryp->d_name);
if (++errcount > 100)
{
fprintf(stderr, "Stack Monitor: Too many errors ... exiting\n");
fprintf(stderr,
"Stack Monitor: Too many errors ... exiting\n");
exitcode = EXIT_FAILURE;
break;
}
@@ -421,11 +431,13 @@ int main(int argc, char **argv)
ret = task_create("Stack Monitor", CONFIG_SYSTEM_STACKMONITOR_PRIORITY,
CONFIG_SYSTEM_STACKMONITOR_STACKSIZE,
(main_t)stackmonitor_daemon, (FAR char * const *)NULL);
(main_t)stackmonitor_daemon,
(FAR char * const *)NULL);
if (ret < 0)
{
int errcode = errno;
printf("Stack Monitor ERROR: Failed to start the stack monitor: %d\n",
printf("Stack Monitor ERROR: "
"Failed to start the stack monitor: %d\n",
errcode);
}
else