diff mbox series

[02/26] libxfs: refactor NSEC_PER_SEC

Message ID 160375525913.881414.1818734123140314548.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfsprogs: widen timestamps to deal with y2038 | expand

Commit Message

Darrick J. Wong Oct. 26, 2020, 11:34 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Clean up all the open-coded and duplicate definitions of time unit
conversion factors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
---
 include/platform_defs.h.in |    3 +++
 repair/dinode.c            |    2 +-
 scrub/common.c             |    2 --
 scrub/progress.c           |    1 -
 4 files changed, 4 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Oct. 29, 2020, 9:44 a.m. UTC | #1
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/include/platform_defs.h.in b/include/platform_defs.h.in
index 1f7ceafb1fbc..a11b58719380 100644
--- a/include/platform_defs.h.in
+++ b/include/platform_defs.h.in
@@ -80,4 +80,7 @@  typedef unsigned short umode_t;
 
 extern int	platform_nproc(void);
 
+#define NSEC_PER_SEC	(1000000000ULL)
+#define NSEC_PER_USEC	(1000ULL)
+
 #endif	/* __XFS_PLATFORM_DEFS_H__ */
diff --git a/repair/dinode.c b/repair/dinode.c
index 028a23cd5c8c..95e57b5318b5 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -2170,7 +2170,7 @@  check_nsec(
 	struct xfs_timestamp	*t,
 	int			*dirty)
 {
-	if (be32_to_cpu(t->t_nsec) < 1000000000)
+	if (be32_to_cpu(t->t_nsec) < NSEC_PER_SEC)
 		return;
 
 	do_warn(
diff --git a/scrub/common.c b/scrub/common.c
index c4699b6ad1e3..49a87f412c4d 100644
--- a/scrub/common.c
+++ b/scrub/common.c
@@ -288,8 +288,6 @@  scrub_nproc_workqueue(
  * Sleep for 100us * however many -b we got past the initial one.
  * This is an (albeit clumsy) way to throttle scrub activity.
  */
-#define NSEC_PER_SEC	1000000000ULL
-#define NSEC_PER_USEC	1000ULL
 void
 background_sleep(void)
 {
diff --git a/scrub/progress.c b/scrub/progress.c
index d8130ca5f93c..15247b7c6d1b 100644
--- a/scrub/progress.c
+++ b/scrub/progress.c
@@ -110,7 +110,6 @@  progress_report(
 	fflush(pt.fp);
 }
 
-#define NSEC_PER_SEC	(1000000000)
 static void *
 progress_report_thread(void *arg)
 {