summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2023-10-04 18:46:48 +0200
committerAlejandro Colomar <alx@kernel.org>2023-10-20 21:05:33 +0200
commitc5e5fee6062c7b98a171a146c0a247074433ae90 (patch)
tree085270a2187e03c7247f941d9e21e519c996375a
parent2a558bd8cbd5b070e79cf7694c00c28eb71a9c99 (diff)
lib/copydir.c: Use goto to reduce a conditional branch
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r--lib/copydir.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/copydir.c b/lib/copydir.c
index 4c1b78be..36f2004d 100644
--- a/lib/copydir.c
+++ b/lib/copydir.c
@@ -335,27 +335,28 @@ static int copy_tree_impl (const struct path_info *src, const struct path_info *
if ((NULL == src_name) || (NULL == dst_name)) {
err = -1;
- } else {
- /*
- * Build the filename for both the source and
- * the destination files.
- */
- struct path_info src_entry, dst_entry;
+ goto skip;
+ }
+ /*
+ * Build the filename for both the source and
+ * the destination files.
+ */
+ struct path_info src_entry, dst_entry;
- (void) snprintf (src_name, src_len, "%s/%s", src->full_path, ent->d_name);
- (void) snprintf (dst_name, dst_len, "%s/%s", dst->full_path, ent->d_name);
+ (void) snprintf (src_name, src_len, "%s/%s", src->full_path, ent->d_name);
+ (void) snprintf (dst_name, dst_len, "%s/%s", dst->full_path, ent->d_name);
- src_entry.full_path = src_name;
- src_entry.dirfd = dirfd(dir);
- src_entry.name = ent->d_name;
+ src_entry.full_path = src_name;
+ src_entry.dirfd = dirfd(dir);
+ src_entry.name = ent->d_name;
- dst_entry.full_path = dst_name;
- dst_entry.dirfd = dst_fd;
- dst_entry.name = ent->d_name;
+ dst_entry.full_path = dst_name;
+ dst_entry.dirfd = dst_fd;
+ dst_entry.name = ent->d_name;
- err = copy_entry(&src_entry, &dst_entry, reset_selinux,
- old_uid, new_uid, old_gid, new_gid);
- }
+ err = copy_entry(&src_entry, &dst_entry, reset_selinux,
+ old_uid, new_uid, old_gid, new_gid);
+skip:
free (src_name);
free (dst_name);
}