about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMax Horn <max@quendi.de>2021-02-05 10:56:45 +0100
committerLeah Neukirchen <leah@vuxu.org>2021-02-07 14:32:46 +0100
commit11d6ac4107bee4368bb2618e1f256822558e1ccc (patch)
tree8d6f016ed3bd5d66f3b824b0da1fdd365d0fc348
parent170ef3ee75835a2fe561ed6c749de78d5f223629 (diff)
downloadredo-c-11d6ac4107bee4368bb2618e1f256822558e1ccc.tar.gz
redo-c-11d6ac4107bee4368bb2618e1f256822558e1ccc.tar.xz
redo-c-11d6ac4107bee4368bb2618e1f256822558e1ccc.zip
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]
-rw-r--r--redo.c6
1 files 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);