Fixes in asprintf usage.
This commit is contained in:
parent
433ec4c9de
commit
098b7bbfb3
@ -353,13 +353,15 @@ static int _inode_search(FAR struct inode_search_s *desc)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
|
||||
asprintf(&buffer,
|
||||
"%s/%s", desc->relpath, name);
|
||||
if (buffer != NULL)
|
||||
ret = asprintf(&buffer,
|
||||
"%s/%s", desc->relpath,
|
||||
name);
|
||||
if (ret > 0)
|
||||
{
|
||||
lib_free(desc->buffer);
|
||||
desc->buffer = buffer;
|
||||
relpath = buffer;
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -481,8 +483,8 @@ int inode_search(FAR struct inode_search_s *desc)
|
||||
|
||||
if (*desc->path != '/')
|
||||
{
|
||||
asprintf(&desc->buffer, "%s/%s", _inode_getcwd(), desc->path);
|
||||
if (desc->buffer == NULL)
|
||||
ret = asprintf(&desc->buffer, "%s/%s", _inode_getcwd(), desc->path);
|
||||
if (ret < 0)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@ -600,7 +600,13 @@ int dir_allocate(FAR struct file *filep, FAR const char *relpath)
|
||||
}
|
||||
|
||||
inode_getpath(inode, path_prefix);
|
||||
asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath);
|
||||
ret = asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath);
|
||||
if (ret < 0)
|
||||
{
|
||||
dir->fd_path = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
filep->f_inode = &g_dir_inode;
|
||||
filep->f_priv = dir;
|
||||
inode_addref(&g_dir_inode);
|
||||
|
@ -128,9 +128,10 @@ next_subdir:
|
||||
*/
|
||||
|
||||
subdirname = basename((FAR char *)oldpath);
|
||||
asprintf(&subdir, "%s/%s", newpath, subdirname);
|
||||
if (subdir == NULL)
|
||||
ret = asprintf(&subdir, "%s/%s", newpath, subdirname);
|
||||
if (ret < 0)
|
||||
{
|
||||
subdir = NULL;
|
||||
ret = -ENOMEM;
|
||||
goto errout;
|
||||
}
|
||||
@ -369,10 +370,11 @@ next_subdir:
|
||||
}
|
||||
else
|
||||
{
|
||||
asprintf(&subdir, "%s/%s", newrelpath,
|
||||
subdirname);
|
||||
if (subdir == NULL)
|
||||
ret = asprintf(&subdir, "%s/%s", newrelpath,
|
||||
subdirname);
|
||||
if (ret < 0)
|
||||
{
|
||||
subdir = NULL;
|
||||
ret = -ENOMEM;
|
||||
goto errout_with_newinode;
|
||||
}
|
||||
|
@ -74,9 +74,10 @@ FAR char *tempnam(FAR const char *dir, FAR const char *pfx)
|
||||
{
|
||||
FAR char *template;
|
||||
FAR char *path;
|
||||
int ret;
|
||||
|
||||
asprintf(&template, "%s/%s-XXXXXX", dir, pfx);
|
||||
if (template)
|
||||
ret = asprintf(&template, "%s/%s-XXXXXX", dir, pfx);
|
||||
if (ret > 0)
|
||||
{
|
||||
path = mktemp(template);
|
||||
if (path != NULL)
|
||||
|
@ -1112,7 +1112,11 @@ static int dir_notempty(const char *dirpath, const char *name,
|
||||
int ret;
|
||||
|
||||
ret = asprintf(&path, "%s/%s", dirpath, name);
|
||||
UNUSED(ret);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: asprintf() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* stat() should not fail for any reason */
|
||||
|
||||
@ -1142,7 +1146,11 @@ static int process_direntry(const char *dirpath, const char *name,
|
||||
int ret;
|
||||
|
||||
ret = asprintf(&path, "%s/%s", dirpath, name);
|
||||
UNUSED(ret);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: asprintf() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = stat(path, &buf);
|
||||
if (ret < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user