main: fix warnings reported by lgtm.com

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2019-07-29 13:35:07 +02:00
parent cf86b89adc
commit 56cc4d3d61
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
2 changed files with 11 additions and 13 deletions

View File

@ -1215,7 +1215,6 @@ hash_print (const Hash_table *table)
for (cursor = bucket; cursor; cursor = cursor->next) for (cursor = bucket; cursor; cursor = cursor->next)
{ {
char const *s = cursor->data; char const *s = cursor->data;
/* FIXME */
if (s) if (s)
printf (" %s\n", s); printf (" %s\n", s);
} }

21
main.c
View File

@ -1095,11 +1095,11 @@ safe_read_xattr (char **ret, int sfd, const char *name, size_t initial_size)
buffer = tmp; buffer = tmp;
} }
buffer[s] == '\0';
if (s <= 0) if (s <= 0)
return s; return s;
buffer[s] = '\0';
/* Change owner. */ /* Change owner. */
*ret = buffer; *ret = buffer;
buffer = NULL; buffer = NULL;
@ -1148,10 +1148,10 @@ make_ovl_node (const char *path, struct ovl_layer *layer, const char *name, ino_
{ {
struct stat st; struct stat st;
struct ovl_layer *it; struct ovl_layer *it;
cleanup_free char *path = NULL; cleanup_free char *npath = NULL;
path = strdup (ret->path); npath = strdup (ret->path);
if (path == NULL) if (npath == NULL)
return NULL; return NULL;
for (it = layer; it; it = it->next) for (it = layer; it; it = it->next)
@ -1160,11 +1160,11 @@ make_ovl_node (const char *path, struct ovl_layer *layer, const char *name, ino_
bool stat_only = false; bool stat_only = false;
cleanup_free char *val = NULL; cleanup_free char *val = NULL;
cleanup_free char *origin = NULL; cleanup_free char *origin = NULL;
cleanup_close int fd = TEMP_FAILURE_RETRY (openat (it->fd, path, O_RDONLY|O_NONBLOCK|O_NOFOLLOW)); cleanup_close int fd = TEMP_FAILURE_RETRY (openat (it->fd, npath, O_RDONLY|O_NONBLOCK|O_NOFOLLOW));
if (fd < 0) if (fd < 0)
{ {
/* It is a symlink, read only the ino. */ /* It is a symlink, read only the ino. */
if (errno == ELOOP && fstatat (it->fd, path, &st, AT_SYMLINK_NOFOLLOW) == 0) if (errno == ELOOP && fstatat (it->fd, npath, &st, AT_SYMLINK_NOFOLLOW) == 0)
{ {
ret->ino = st.st_ino; ret->ino = st.st_ino;
ret->last_layer = it; ret->last_layer = it;
@ -1219,8 +1219,8 @@ make_ovl_node (const char *path, struct ovl_layer *layer, const char *name, ino_
s = safe_read_xattr (&origin, fd, ORIGIN_XATTR, PATH_MAX); s = safe_read_xattr (&origin, fd, ORIGIN_XATTR, PATH_MAX);
if (s > 0) if (s > 0)
{ {
free (path); free (npath);
path = origin; npath = origin;
origin = NULL; origin = NULL;
} }
@ -4411,7 +4411,6 @@ ovl_ioctl (fuse_req_t req, fuse_ino_t ino, unsigned int cmd, void *arg,
{ {
case FS_IOC_GETVERSION: case FS_IOC_GETVERSION:
case FS_IOC_GETFLAGS: case FS_IOC_GETFLAGS:
if (fi->fh >= 0)
fd = fi->fh; fd = fi->fh;
break; break;
@ -4534,7 +4533,7 @@ ovl_copy_file_range (fuse_req_t req, fuse_ino_t ino_in, off_t off_in, struct fus
} }
fd_dest = TEMP_FAILURE_RETRY (openat (node_dirfd (dnode), dnode->path, O_NONBLOCK|O_NOFOLLOW|O_WRONLY)); fd_dest = TEMP_FAILURE_RETRY (openat (node_dirfd (dnode), dnode->path, O_NONBLOCK|O_NOFOLLOW|O_WRONLY));
if (fd < 0) if (fd_dest < 0)
{ {
fuse_reply_err (req, errno); fuse_reply_err (req, errno);
return; return;