summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell
diff options
context:
space:
mode:
authorRyan Long <ryan.long@oarcorp.com>2021-03-12 12:14:47 -0500
committerJoel Sherrill <joel@rtems.org>2021-04-08 17:58:19 -0500
commitfbc764403f4436e1863a8a2a386a9a290dd14129 (patch)
tree038593ccf009ae42ec28d1a364ee5852aa2243da /cpukit/libmisc/shell
parentcpukit/include: Remove telnetd.h (diff)
downloadrtems-fbc764403f4436e1863a8a2a386a9a290dd14129.tar.bz2
main_cp.c: Unused value (CID #1255344)
CID 1255344: Unused value in copy(). Closes #4339
Diffstat (limited to 'cpukit/libmisc/shell')
-rw-r--r--cpukit/libmisc/shell/main_cp.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/main_cp.c b/cpukit/libmisc/shell/main_cp.c
index cddbc95ce3..913ece184f 100644
--- a/cpukit/libmisc/shell/main_cp.c
+++ b/cpukit/libmisc/shell/main_cp.c
@@ -310,11 +310,31 @@ copy(rtems_shell_cp_globals* cp_globals,
case FTS_ERR:
warnx("%s: %s",
curr->fts_path, strerror(curr->fts_errno));
+ #ifdef __rtems__
+ /*
+ * Coverity spotted that badcp is set by each loop
+ * iteration so setting it right before continue
+ * results in the value being unused. See CID 1255344
+ *
+ * The current NetBSD source (v1.62) was checked and
+ * the same issue appears to apply although the
+ * variable names have changed since this was imported
+ * to RTEMS.
+ *
+ * This pattern exists in multiple places in this file.
+ */
+ rval = 1;
+ #else
badcp = rval = 1;
+ #endif
continue;
case FTS_DC: /* Warn, continue. */
warnx("%s: directory causes a cycle", curr->fts_path);
+ #ifdef __rtems__
+ rval = 1;
+ #else
badcp = rval = 1;
+ #endif
continue;
default:
;
@@ -366,7 +386,11 @@ copy(rtems_shell_cp_globals* cp_globals,
if (target_mid - to.p_path + nlen >= PATH_MAX) {
warnx("%s%s: name too long (not copied)",
to.p_path, p);
+ #ifdef __rtems__
+ rval = 1;
+ #else
badcp = rval = 1;
+ #endif
continue;
}
(void)strncat(target_mid, p, nlen);
@@ -418,7 +442,11 @@ copy(rtems_shell_cp_globals* cp_globals,
to_stat.st_ino == curr->fts_statp->st_ino) {
warnx("%s and %s are identical (not copied).",
to.p_path, curr->fts_path);
+ #ifdef __rtems__
+ rval = 1;
+ #else
badcp = rval = 1;
+ #endif
if (S_ISDIR(curr->fts_statp->st_mode))
(void)fts_set(ftsp, curr, FTS_SKIP);
continue;
@@ -428,7 +456,11 @@ copy(rtems_shell_cp_globals* cp_globals,
warnx("cannot overwrite directory %s with "
"non-directory %s",
to.p_path, curr->fts_path);
+ #ifdef __rtems__
+ rval = 1;
+ #else
badcp = rval = 1;
+ #endif
continue;
}
dne = 0;