acst

Tracks changes and corruption in files using xattr-based checksums.
git clone https://noxz.tech/git/acst.git
Log | Files | Tags | LICENSE

commit: e71687267e37d04a718ca071589fab1898267c1a
parent: c1ac4581f1f0591e854fc2f6d7f61c5bfbcae54b
author: Chris Noxz <chris@noxz.tech>
date:   Sun, 10 Jul 2022 16:22:45 +0200
Fix logical error when comparing timestamp

The error caused a negative time difference between ns to flag as backdated
even if difference between s is positive.
Macst.c6+++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/acst.c b/acst.c
@@ -86,9 +86,9 @@ file_state(int fd, xa_t *xa_s, xa_t *xa_a)
 
 	/* compare stored and actual timestamp */
 	xa_a->tcmp = (
-		  (int)(xa_s->s - xa_a->s) > 0 || (int)(xa_s->ns - xa_a->ns) > 0 ? 1
-		: (int)(xa_s->s - xa_a->s) < 0 || (int)(xa_s->ns - xa_a->ns) < 0 ? -1
-		: 0
+	      xa_s->s != xa_a->s ? (int)(xa_s->s - xa_a->s)
+	    : xa_s->ns != xa_a->ns ? (int)(xa_s->ns - xa_a->ns)
+	    : 0
 	);
 
 	return (