From: Paul Eggert Date: Mon, 31 Jan 2022 16:42:07 +0000 (-0800) Subject: cp: simplify cp/install/ln/mv pacification X-Git-Tag: v9.1~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f21ccfb02c7233d2d36d49a6198be1c1f1fe938a;p=thirdparty%2Fcoreutils.git cp: simplify cp/install/ln/mv pacification * src/copy.c (dest_info_free, src_info_free) [lint]: Remove. All uses removed. (copy_internal): Pacify only Clang and Coverity; GCC doesn’t need it. * src/cp-hash.c (forget_all) [lint]: Remove. All uses removed. * src/cp.c, src/install.c, src/ln.c, src/mv.c (main): Use main_exit, not return. --- diff --git a/src/copy.c b/src/copy.c index 4a7d9b5d9c..33a26c36a3 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1759,16 +1759,6 @@ dest_info_init (struct cp_options *x) xalloc_die (); } -#ifdef lint -extern void -dest_info_free (struct cp_options *x) -{ - if (x->dest_info) - hash_free (x->dest_info); - x->dest_info = NULL; -} -#endif - /* Initialize the hash table implementing a set of F_triple entries corresponding to source files listed on the command line. */ extern void @@ -1793,16 +1783,6 @@ src_info_init (struct cp_options *x) xalloc_die (); } -#ifdef lint -extern void -src_info_free (struct cp_options *x) -{ - if (x->src_info) - hash_free (x->src_info); - x->src_info = NULL; -} -#endif - /* When effecting a move (e.g., for mv(1)), and given the name DST_NAME aka DST_DIRFD+DST_RELNAME of the destination and a corresponding stat buffer, DST_SB, return @@ -2014,13 +1994,13 @@ copy_internal (char const *src_name, char const *dst_name, return false; } } -#ifdef lint else { +#if defined lint && (defined __clang__ || defined __COVERITY__) assert (x->move_mode); memset (&src_sb, 0, sizeof src_sb); - } #endif + } /* Detect the case in which the same source file appears more than once on the command line and no backup option has been selected. diff --git a/src/cp-hash.c b/src/cp-hash.c index 3a3a074903..e566a4c4ad 100644 --- a/src/cp-hash.c +++ b/src/cp-hash.c @@ -153,14 +153,3 @@ hash_init (void) if (src_to_dest == NULL) xalloc_die (); } - -/* Reset the hash structure in the global variable 'htab' to - contain no entries. */ - -#ifdef lint -extern void -forget_all (void) -{ - hash_free (src_to_dest); -} -#endif diff --git a/src/cp-hash.h b/src/cp-hash.h index 72870fa6d8..989fcc53b2 100644 --- a/src/cp-hash.h +++ b/src/cp-hash.h @@ -1,5 +1,4 @@ void hash_init (void); -void forget_all (void); void forget_created (ino_t ino, dev_t dev); char *remember_copied (char const *node, ino_t ino, dev_t dev) _GL_ATTRIBUTE_NONNULL (); diff --git a/src/cp.c b/src/cp.c index d680eb01d2..5084037f15 100644 --- a/src/cp.c +++ b/src/cp.c @@ -735,11 +735,6 @@ do_copy (int n_files, char **file, char const *target_directory, free (dst_name); } - -#ifdef lint - dest_info_free (x); - src_info_free (x); -#endif } else /* !target_directory */ { @@ -1218,9 +1213,5 @@ main (int argc, char **argv) ok = do_copy (argc - optind, argv + optind, target_directory, no_target_directory, &x); -#ifdef lint - forget_all (); -#endif - - return ok ? EXIT_SUCCESS : EXIT_FAILURE; + main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/install.c b/src/install.c index a27a5343b4..38e26a8878 100644 --- a/src/install.c +++ b/src/install.c @@ -1023,11 +1023,8 @@ main (int argc, char **argv) i == 0 && mkdir_and_install, &target_dirfd)) exit_status = EXIT_FAILURE; -#ifdef lint - dest_info_free (&x); -#endif } } - return exit_status; + main_exit (exit_status); } diff --git a/src/ln.c b/src/ln.c index 5a05c078ce..bb46958533 100644 --- a/src/ln.c +++ b/src/ln.c @@ -674,15 +674,9 @@ main (int argc, char **argv) ok &= do_link (file[i], destdir_fd, dest_base, dest, -1); free (dest); } - -#ifdef lint - if (dest_set) - hash_free (dest_set); - dest_set = NULL; -#endif } else ok = do_link (file[0], AT_FDCWD, file[1], file[1], link_errno); - return ok ? EXIT_SUCCESS : EXIT_FAILURE; + main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/mv.c b/src/mv.c index fcf32cd436..21018a0d33 100644 --- a/src/mv.c +++ b/src/mv.c @@ -487,10 +487,6 @@ main (int argc, char **argv) ok &= do_move (source, dest, target_dirfd, dest_relname, &x); free (dest); } - -#ifdef lint - dest_info_free (&x); -#endif } else { @@ -498,5 +494,5 @@ main (int argc, char **argv) ok = do_move (file[0], file[1], AT_FDCWD, file[1], &x); } - return ok ? EXIT_SUCCESS : EXIT_FAILURE; + main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); }