Cast int to size_t before adding instead of casting the result.

Quiets PVS-Studio warning V1028.
This commit is contained in:
Todd C. Miller
2023-08-21 12:50:31 -06:00
parent 9f05bfd298
commit c6987aa26e
6 changed files with 9 additions and 8 deletions

View File

@@ -1551,11 +1551,11 @@ find_sessions(const char *dir, regex_t *re, const char *user, const char *tty)
/* Check for dir with a log file. */
if (lstat(pathbuf, &sb) == 0 && S_ISREG(sb.st_mode)) {
pathbuf[sdlen + (size_t)(len - 4)] = '\0';
pathbuf[sdlen + (size_t)len - 4] = '\0';
list_session(&lbuf, pathbuf, re, user, tty);
} else {
/* Strip off "/log" and recurse if a non-log dir. */
pathbuf[sdlen + (size_t)(len - 4)] = '\0';
pathbuf[sdlen + (size_t)len - 4] = '\0';
if (checked_type ||
(lstat(pathbuf, &sb) == 0 && S_ISDIR(sb.st_mode)))
find_sessions(pathbuf, re, user, tty);