Skip to content

Commit

Permalink
Merge pull request #178 from cgwalters/clang-analyzer-fixes-trivial
Browse files Browse the repository at this point in the history
A few smaller/more obvious fixes from running `clang-analyzer`
  • Loading branch information
alexlarsson authored Aug 29, 2023
2 parents f8db698 + 9e46d05 commit c15e9b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 0 additions & 2 deletions libcomposefs/lcfs-writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ int lcfs_compute_tree(struct lcfs_ctx_s *ctx, struct lcfs_node_s *root)
ctx->min_mtim_nsec = root->inode.st_mtim_nsec;
ctx->has_acl = false;

node = root;

for (node = root, index = 0; node != NULL; node = node->next, index++) {
if ((node->inode.st_mode & S_IFMT) != S_IFDIR &&
node->children_size != 0) {
Expand Down
12 changes: 5 additions & 7 deletions tools/mkcomposefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,13 @@ static int ensure_dir(const char *path, mode_t mode)

static int mkdir_parents(const char *pathname, int mode)
{
cleanup_free char *fn = NULL;
char *p;

fn = strdup(pathname);
cleanup_free char *fn = strdup(pathname);
if (fn == NULL) {
errno = ENOMEM;
return -1;
}

p = fn;
char *p = fn;
while (*p == '/')
p++;

Expand Down Expand Up @@ -322,7 +319,7 @@ static int fill_payload(struct lcfs_node_s *node, const char *path, size_t len,
char target[PATH_MAX + 1];
ssize_t s = readlink(path, target, sizeof(target));
if (s < 0)
return ret;
return s;

target[s] = '\0';
ret = lcfs_node_set_payload(node, target);
Expand Down Expand Up @@ -569,7 +566,7 @@ int main(int argc, char **argv)
cleanup_free char *cwd_cleanup = NULL;
cleanup_free char *tmp_pathbuf = NULL;
cleanup_free char *absolute_prefix = NULL;
char *cwd = "";
const char *cwd = "";
int r;

if (dir_path[0] != '/') {
Expand All @@ -578,6 +575,7 @@ int main(int argc, char **argv)
error(EXIT_FAILURE, errno,
"retrieve current working directory");
}
(void)cwd_cleanup; // This is just used for cleanup
r = join_paths(&tmp_pathbuf, cwd, dir_path);
if (r < 0)
error(EXIT_FAILURE, errno, "compute directory path");
Expand Down

0 comments on commit c15e9b1

Please sign in to comment.