Fixes in asprintf usage.
This commit is contained in:
parent
cf54069487
commit
c50ff7ff61
@ -413,6 +413,8 @@ bool CResize::setWindowSize(FAR struct nxgl_size_s *size)
|
|||||||
|
|
||||||
void CResize::updateSizeLabel(FAR struct nxgl_size_s &windowSize)
|
void CResize::updateSizeLabel(FAR struct nxgl_size_s &windowSize)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
// Do nothing if the size has not changed
|
// Do nothing if the size has not changed
|
||||||
|
|
||||||
struct nxgl_size_s labelSize;
|
struct nxgl_size_s labelSize;
|
||||||
@ -424,8 +426,8 @@ void CResize::updateSizeLabel(FAR struct nxgl_size_s &windowSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FAR char *str;
|
FAR char *str;
|
||||||
asprintf(&str, " %4d x %-4d ", windowSize.w, windowSize.h);
|
ret = asprintf(&str, " %4d x %-4d ", windowSize.w, windowSize.h);
|
||||||
if (str == (FAR char *)0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
twmerr("ERROR: Failed to get size string\n");
|
twmerr("ERROR: Failed to get size string\n");
|
||||||
return;
|
return;
|
||||||
|
@ -382,7 +382,10 @@ void CTwm4Nx::genMqName(void)
|
|||||||
unsigned long randvalue =
|
unsigned long randvalue =
|
||||||
(unsigned long)std::random() & 0x00fffffful;
|
(unsigned long)std::random() & 0x00fffffful;
|
||||||
|
|
||||||
std::asprintf(&m_queueName, "Twm4Nx%06lu", randvalue);
|
if (std::asprintf(&m_queueName, "Twm4Nx%06lu", randvalue) < 0)
|
||||||
|
{
|
||||||
|
m_queueName = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,7 +247,10 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
|
|||||||
|
|
||||||
else if (relpath[1] == '/')
|
else if (relpath[1] == '/')
|
||||||
{
|
{
|
||||||
asprintf(&ptr, "%s%s", homedir, &relpath[1]);
|
if (asprintf(&ptr, "%s%s", homedir, &relpath[1]) < 0)
|
||||||
|
{
|
||||||
|
ptr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hmmm... this pretty much guaranteed to fail */
|
/* Hmmm... this pretty much guaranteed to fail */
|
||||||
@ -264,7 +267,10 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
|
|||||||
|
|
||||||
else if (strncmp(relpath, "./", 2) == 0)
|
else if (strncmp(relpath, "./", 2) == 0)
|
||||||
{
|
{
|
||||||
asprintf(&ptr, "%s%s", curdir, relpath + 1);
|
if (asprintf(&ptr, "%s%s", curdir, relpath + 1) < 0)
|
||||||
|
{
|
||||||
|
ptr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for an absolute path */
|
/* Check for an absolute path */
|
||||||
@ -278,7 +284,10 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
asprintf(&ptr, "%s/%s", curdir, relpath);
|
if (asprintf(&ptr, "%s/%s", curdir, relpath) < 0)
|
||||||
|
{
|
||||||
|
ptr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -1007,12 +1007,13 @@ static ssize_t ftpd_response(int sd, int timeout, FAR const char *fmt, ...)
|
|||||||
FAR char *buffer;
|
FAR char *buffer;
|
||||||
ssize_t bytessent;
|
ssize_t bytessent;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
int ret;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vasprintf(&buffer, fmt, ap);
|
ret = vasprintf(&buffer, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (buffer == NULL)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
@ -2417,8 +2418,8 @@ static int fptd_listscan(FAR struct ftpd_session_s *session, FAR char *path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(&temp, "%s/%s", path, entry->d_name);
|
ret = asprintf(&temp, "%s/%s", path, entry->d_name);
|
||||||
if (temp == NULL)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,6 @@ static int critmon_process_directory(FAR struct dirent *entryp)
|
|||||||
FAR char *maxrun;
|
FAR char *maxrun;
|
||||||
FAR char *endptr;
|
FAR char *endptr;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
int errcode;
|
|
||||||
int len;
|
int len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -134,13 +133,11 @@ static int critmon_process_directory(FAR struct dirent *entryp)
|
|||||||
ret = asprintf(&filepath,
|
ret = asprintf(&filepath,
|
||||||
CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/status",
|
CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/status",
|
||||||
entryp->d_name);
|
entryp->d_name);
|
||||||
if (ret < 0 || filepath == NULL)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = errno;
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Csection Monitor: Failed to create path to status file: %d\n",
|
"Csection Monitor: Failed to create path to status file\n");
|
||||||
errcode);
|
return -ENOMEM;
|
||||||
return -errcode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the status file */
|
/* Open the status file */
|
||||||
@ -187,12 +184,10 @@ static int critmon_process_directory(FAR struct dirent *entryp)
|
|||||||
ret = asprintf(&filepath,
|
ret = asprintf(&filepath,
|
||||||
CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/critmon",
|
CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/%s/critmon",
|
||||||
entryp->d_name);
|
entryp->d_name);
|
||||||
if (ret < 0 || filepath == NULL)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = errno;
|
|
||||||
fprintf(stderr, "Csection Monitor: "
|
fprintf(stderr, "Csection Monitor: "
|
||||||
"Failed to create path to Csection file: %d\n",
|
"Failed to create path to Csection file\n");
|
||||||
errcode);
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto errout_with_name;
|
goto errout_with_name;
|
||||||
}
|
}
|
||||||
@ -324,12 +319,10 @@ static void critmon_global_crit(void)
|
|||||||
|
|
||||||
ret = asprintf(&filepath,
|
ret = asprintf(&filepath,
|
||||||
CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/critmon");
|
CONFIG_SYSTEM_CRITMONITOR_MOUNTPOINT "/critmon");
|
||||||
if (ret < 0 || filepath == NULL)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = errno;
|
|
||||||
fprintf(stderr, "Csection Monitor: "
|
fprintf(stderr, "Csection Monitor: "
|
||||||
"Failed to create path to Csection file: %d\n",
|
"Failed to create path to Csection file\n");
|
||||||
errcode);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,6 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
|
|||||||
FILE *stream;
|
FILE *stream;
|
||||||
unsigned long stack_size;
|
unsigned long stack_size;
|
||||||
unsigned long stack_used;
|
unsigned long stack_used;
|
||||||
int errcode;
|
|
||||||
int len;
|
int len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -134,13 +133,11 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
|
|||||||
ret = asprintf(&filepath,
|
ret = asprintf(&filepath,
|
||||||
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/status",
|
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/status",
|
||||||
entryp->d_name);
|
entryp->d_name);
|
||||||
if (ret < 0 || filepath == NULL)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = errno;
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Stack Monitor: Failed to create path to status file: %d\n",
|
"Stack Monitor: Failed to create path to status file\n");
|
||||||
errcode);
|
return -ENOMEM;
|
||||||
return -errcode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the status file */
|
/* Open the status file */
|
||||||
@ -189,12 +186,10 @@ static int stkmon_process_directory(FAR struct dirent *entryp)
|
|||||||
ret = asprintf(&filepath,
|
ret = asprintf(&filepath,
|
||||||
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/stack",
|
CONFIG_SYSTEM_STACKMONITOR_MOUNTPOINT "/%s/stack",
|
||||||
entryp->d_name);
|
entryp->d_name);
|
||||||
if (ret < 0 || filepath == NULL)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = errno;
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Stack Monitor: Failed to create path to stack file: %d\n",
|
"Stack Monitor: Failed to create path to stack file\n");
|
||||||
errcode);
|
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto errout_with_name;
|
goto errout_with_name;
|
||||||
}
|
}
|
||||||
|
@ -1143,8 +1143,8 @@ static int zmr_parsefilename(FAR struct zmr_state_s *pzmr,
|
|||||||
|
|
||||||
/* Extend the relative path to the file storage directory */
|
/* Extend the relative path to the file storage directory */
|
||||||
|
|
||||||
asprintf(&pzmr->filename, "%s/%s", pzmr->pathname, namptr);
|
ret = asprintf(&pzmr->filename, "%s/%s", pzmr->pathname, namptr);
|
||||||
if (!pzmr->filename)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
zmdbg("ERROR: Failed to allocate full path %s/%s\n",
|
zmdbg("ERROR: Failed to allocate full path %s/%s\n",
|
||||||
CONFIG_SYSTEM_ZMODEM_MOUNTPOINT, namptr);
|
CONFIG_SYSTEM_ZMODEM_MOUNTPOINT, namptr);
|
||||||
@ -1331,9 +1331,9 @@ static int zmr_parsefilename(FAR struct zmr_state_s *pzmr,
|
|||||||
{
|
{
|
||||||
/* Create a candidate file name */
|
/* Create a candidate file name */
|
||||||
|
|
||||||
asprintf(&candidate, "%s_%" PRId32, pzmr->filename,
|
ret = asprintf(&candidate, "%s_%" PRId32, pzmr->filename,
|
||||||
++uniqno);
|
++uniqno);
|
||||||
if (!candidate)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
zmdbg("ERROR: Failed to allocate candidate %s_%d\n",
|
zmdbg("ERROR: Failed to allocate candidate %s_%d\n",
|
||||||
pzmr->filename, uniqno);
|
pzmr->filename, uniqno);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user