Merge pull request #278 from giuseppe/fix-static-analysis

src: fix some defects found by static analysis
This commit is contained in:
Daniel J Walsh 2021-03-04 15:39:49 -05:00 committed by GitHub
commit d085fa9ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 9 deletions

View File

@ -64,6 +64,7 @@ jobs:
sudo mkdir -p /lower /upper /mnt
sudo sh -c "(cd /; git clone https://github.com/amir73il/unionmount-testsuite.git)"
sudo go get github.com/containers/storage
sudo GOPATH=$GOPATH sh -c "(cd /root/go/src/github.com/containers/storage; make tests/tools/build/ffjson; cp tests/tools/build/ffjson /usr/bin)"
sudo GOPATH=$GOPATH sh -c "(cd /root/go/src/github.com/containers/storage; sed -i -e 's|^AUTOTAGS.*$|AUTOTAGS := exclude_graphdriver_devicemapper exclude_graphdriver_btrfs|' Makefile; make GO111MODULE=on containers-storage)"
- name: run autogen.sh

13
main.c
View File

@ -179,7 +179,7 @@ print_stats (int sig)
char fmt[128];
int l = snprintf (fmt, sizeof (fmt) - 1, "# INODES: %zu\n# NODES: %zu\n", stats.inodes, stats.nodes);
fmt[l] = '\0';
write (STDERR_FILENO, fmt, l + 1);
(void) write (STDERR_FILENO, fmt, l + 1);
}
static double
@ -1398,7 +1398,7 @@ make_ovl_node (struct ovl_data *lo, const char *path, struct ovl_layer *layer, c
ret = calloc (1, sizeof (*ret));
if (ret == NULL)
return NULL;
return NULL;
ret->parent = parent;
ret->layer = layer;
@ -1562,7 +1562,6 @@ static struct ovl_node *
insert_node (struct ovl_node *parent, struct ovl_node *item, bool replace)
{
struct ovl_node *old = NULL, *prev_parent = item->parent;
int is_dir = node_dirp (item);
int ret;
if (prev_parent)
@ -5022,7 +5021,7 @@ do_fsync (fuse_req_t req, fuse_ino_t ino, int datasync, int fd)
}
if (fd < 0)
strcpy (path, node->path);
strncpy (path, node->path, PATH_MAX);
if (! do_fsync)
{
@ -5423,7 +5422,11 @@ load_default_plugins ()
if (dent->d_type != DT_DIR)
{
char *new_plugins = NULL;
asprintf (&new_plugins, "%s/%s:%s", PKGLIBEXECDIR, dent->d_name, plugins);
if (asprintf (&new_plugins, "%s/%s:%s", PKGLIBEXECDIR, dent->d_name, plugins) < 0)
{
free (plugins);
return NULL;
}
free (plugins);
plugins = new_plugins;
}

View File

@ -207,7 +207,7 @@ sleep_pid=$!
rm merged/toremove
grep 12345 /proc/$sleep_pid/fd/0
RUN touch merged/a merged/b
RUN chmod 6 merged/a
RUN mv merged/a merged/x
RUN mv merged/b merged/a
touch merged/a merged/b
chmod 6 merged/a
mv merged/a merged/x
mv merged/b merged/a

View File

@ -18,7 +18,9 @@
#ifndef UTILS_H
# define UTILS_H
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
# include <config.h>