Some "#if" directives were used incorrectly. Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs") Signed-off-by: Gao Xiang <hsiang...@linux.alibaba.com> --- include/erofs/defs.h | 3 +++ lib/tar.c | 11 +++++------ 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/erofs/defs.h b/include/erofs/defs.h index 310a6ab..e462338 100644 --- a/include/erofs/defs.h +++ b/include/erofs/defs.h @@ -332,15 +332,18 @@ unsigned long __roundup_pow_of_two(unsigned long n) #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atim.tv_nsec) #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctim.tv_nsec) #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtim.tv_nsec) +#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtim.tv_nsec = (val) #elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC) /* macOS */ #define ST_ATIM_NSEC(stbuf) ((stbuf)->st_atimensec) #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimensec) #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimensec) +#define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimensec = (val) #else #define ST_ATIM_NSEC(stbuf) 0 #define ST_CTIM_NSEC(stbuf) 0 #define ST_MTIM_NSEC(stbuf) 0 +#define ST_MTIM_NSEC_SET(stbuf, val) do { } while (0) #endif #define __erofs_likely(x) __builtin_expect(!!(x), 1) diff --git a/lib/tar.c b/lib/tar.c index cefda37..a9b425e 100644 --- a/lib/tar.c +++ b/lib/tar.c @@ -490,9 +490,9 @@ int tarerofs_parse_pax_header(struct erofs_iostream *ios, ret = -EIO; goto out; } -#if ST_MTIM_NSEC - ST_MTIM_NSEC(&eh->st) = n; -#endif + ST_MTIM_NSEC_SET(&eh->st, n); + } else { + ST_MTIM_NSEC_SET(&eh->st, 0); } eh->use_mtime = true; } else if (!strncmp(kv, "size=", @@ -733,13 +733,12 @@ restart: if (eh.use_mtime) { st.st_mtime = eh.st.st_mtime; -#if ST_MTIM_NSEC - ST_MTIM_NSEC(&st) = ST_MTIM_NSEC(&eh.st); -#endif + ST_MTIM_NSEC_SET(&st, ST_MTIM_NSEC(&eh.st)); } else { st.st_mtime = tarerofs_parsenum(th->mtime, sizeof(th->mtime)); if (errno) goto invalid_tar; + ST_MTIM_NSEC_SET(&st, 0); } if (th->typeflag <= '7' && !eh.path) { -- 2.43.5