From 11d6ac4107bee4368bb2618e1f256822558e1ccc Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 5 Feb 2021 10:56:45 +0100 Subject: Fix some compiler warnings On non-Linux systems (e.g. macOS, BSD), st.st_ctime may not be of the right type for PRIx64 ; so just cast it to an uint64_t, which is the type PRIx64 corresponds to. Also, clang may warn about `"/"+(*dirprefix ? 0 : 1)`, suspecting a coding error. Using `(*dirprefix ? "/" : "")` is unambiguous and also easier to grok for some people (e.g. myself ;-)). Closes: #9 [via git-merge-pr] --- redo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/redo.c b/redo.c index 6f2f9d3..141434c 100644 --- a/redo.c +++ b/redo.c @@ -337,7 +337,7 @@ datefile(int fd) struct stat st; fstat(fd, &st); - snprintf(hexdate, sizeof hexdate, "%016" PRIx64, st.st_ctime); + snprintf(hexdate, sizeof hexdate, "%016" PRIx64, (uint64_t)st.st_ctime); return hexdate; } @@ -662,9 +662,9 @@ run_script(char *target, int implicit) dirprefix++; snprintf(temp_target, sizeof temp_target, - "%s%s%s", dirprefix, "/"+(*dirprefix ? 0 : 1), temp_target_base); + "%s%s%s", dirprefix, (*dirprefix ? "/" : ""), temp_target_base); snprintf(rel_target, sizeof rel_target, - "%s%s%s", dirprefix, "/"+(*dirprefix ? 0 : 1), target); + "%s%s%s", dirprefix, (*dirprefix ? "/" : ""), target); if (dirprefix) setenv("REDO_DIRPREFIX", dirprefix, 1); -- cgit 1.4.1