Skip to contentSkip to conversation

nfsdcltrack: Use uint64_t instead of time_t

PATCH In review Steve Dickson 2 participants 4 messages Jul 28, 2021 – Jul 31, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsdcltrack: Use uint64_t instead of time_t

With recent commits (4f2a5b64,5a53426c) that fixed compile errors on x86_64 machines, caused similar errors on i686 machines.

The variable type that was being used was a time_t, which changes size between architects, which caused the compile error.

Changing the variable to uint64_t fixed the issue.

---
 utils/nfsdcltrack/nfsdcltrack.c | 2 +-
 utils/nfsdcltrack/sqlite.c      | 2 +-
 utils/nfsdcltrack/sqlite.h      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
utils/nfsdcltrack/nfsdcltrack.c +1 -1
index 0b37c094..7c1c4bcc 100644
@@ -508,7 +508,7 @@ cltrack_gracedone(const char *timestr)
 {
 	int ret;
 	char *tail;
-	time_t gracetime;
+	uint64_t gracetime;
 
 
 	ret = sqlite_prepare_dbh(storagedir);
utils/nfsdcltrack/sqlite.c +1 -1
index cea4a411..cf0c6a45 100644
@@ -540,7 +540,7 @@ out_err:
  * remove any client records that were not reclaimed since grace_start.
  */
 int
-sqlite_remove_unreclaimed(time_t grace_start)
+sqlite_remove_unreclaimed(uint64_t grace_start)
 {
 	int ret;
 	char *err = NULL;
utils/nfsdcltrack/sqlite.h +1 -1
index 06e7c044..ba8cdfa8 100644
@@ -26,7 +26,7 @@ int sqlite_insert_client(const unsigned char *clname, const size_t namelen,
 int sqlite_remove_client(const unsigned char *clname, const size_t namelen);
 int sqlite_check_client(const unsigned char *clname, const size_t namelen,
 				const bool has_session);
-int sqlite_remove_unreclaimed(const time_t grace_start);
+int sqlite_remove_unreclaimed(const uint64_t grace_start);
 int sqlite_query_reclaiming(const time_t grace_start);
 
 #endif /* _SQLITE_H */
Signature · 1 line
2.31.1
maintainer
#1 lore raw
Quoted 22 lines · Steve Dickson

With recent commits (4f2a5b64,5a53426c) that fixed compile errors on x86_64 machines, caused similar errors on i686 machines.

The variable type that was being used was a time_t, which changes size between architects, which caused the compile error.

Changing the variable to uint64_t fixed the issue.

---
 utils/nfsdcltrack/nfsdcltrack.c | 2 +-
 utils/nfsdcltrack/sqlite.c      | 2 +-
 utils/nfsdcltrack/sqlite.h      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
utils/nfsdcltrack/nfsdcltrack.c +0 -0
index 0b37c094..7c1c4bcc 100644

utils/nfsdcltrack/nfsdcltrack.c cltrack_gracedone(const char *timestr) · line 512

Quoted 6 lines
utils/nfsdcltrack/nfsdcltrack.c +1 -1
@@ -508,7 +508,7 @@ cltrack_gracedone(const char *timestr)
 {
 	int ret;
 	char *tail;
-	time_t gracetime;
+	uint64_t gracetime;
 

Hmm.. time_t is a long:

    typedef __kernel_long_t __kernel_time_t;

...but the kernel is converting this value from a time64_t which is s64.
Should the above be int64_t instead of being unsigned? The kernel should never send down a negative value, but if you're trying to match up types then that might be cleaner.

Quoted 28 lines
utils/nfsdcltrack/nfsdcltrack.c +0 -0
 	ret = sqlite_prepare_dbh(storagedir);
utils/nfsdcltrack/sqlite.c +1 -1
index cea4a411..cf0c6a45 100644
@@ -540,7 +540,7 @@ out_err:
  * remove any client records that were not reclaimed since grace_start.
  */
 int
-sqlite_remove_unreclaimed(time_t grace_start)
+sqlite_remove_unreclaimed(uint64_t grace_start)
 {
 	int ret;
 	char *err = NULL;
utils/nfsdcltrack/sqlite.h +1 -1
index 06e7c044..ba8cdfa8 100644
@@ -26,7 +26,7 @@ int sqlite_insert_client(const unsigned char *clname, const size_t namelen,
 int sqlite_remove_client(const unsigned char *clname, const size_t namelen);
 int sqlite_check_client(const unsigned char *clname, const size_t namelen,
 				const bool has_session);
-int sqlite_remove_unreclaimed(const time_t grace_start);
+int sqlite_remove_unreclaimed(const uint64_t grace_start);
 int sqlite_query_reclaiming(const time_t grace_start);
 
 #endif /* _SQLITE_H */
Signature · 1 line
Jeff Layton <[email protected]>
#2 lore raw
Quoted 32 lines · Jeff Layton
Quoted 22 lines · Steve Dickson

With recent commits (4f2a5b64,5a53426c) that fixed compile errors on x86_64 machines, caused similar errors on i686 machines.

The variable type that was being used was a time_t, which changes size between architects, which caused the compile error.

Changing the variable to uint64_t fixed the issue.

---
  utils/nfsdcltrack/nfsdcltrack.c | 2 +-
  utils/nfsdcltrack/sqlite.c      | 2 +-
  utils/nfsdcltrack/sqlite.h      | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)
utils/nfsdcltrack/nfsdcltrack.c +0 -0
index 0b37c094..7c1c4bcc 100644

utils/nfsdcltrack/nfsdcltrack.c cltrack_gracedone(const char *timestr) · line 512

Quoted 6 lines
utils/nfsdcltrack/nfsdcltrack.c +1 -1
@@ -508,7 +508,7 @@ cltrack_gracedone(const char *timestr)
  {
  	int ret;
  	char *tail;
-	time_t gracetime;
+	uint64_t gracetime;
 

Hmm.. time_t is a long:

Quoted 7 lines
     typedef __kernel_long_t __kernel_time_t;

...but the kernel is converting this value from a time64_t which is s64.

Should the above be int64_t instead of being unsigned? The kernel should never send down a negative value, but if you're trying to match up types then that might be cleaner.

The patch I took to fix the printfs on 64-bits platforms used the PRIu64 inttype interface so I was just keeping things constant by using a uint64_t.

The answer to your question is yes... int64 is all that is needed... but I don't in really matters...

steved.

Quoted 30 lines
Quoted 29 lines
utils/nfsdcltrack/nfsdcltrack.c +0 -0
  	ret = sqlite_prepare_dbh(storagedir);
utils/nfsdcltrack/sqlite.c +1 -1
index cea4a411..cf0c6a45 100644
@@ -540,7 +540,7 @@ out_err:
   * remove any client records that were not reclaimed since grace_start.
   */
  int
-sqlite_remove_unreclaimed(time_t grace_start)
+sqlite_remove_unreclaimed(uint64_t grace_start)
  {
  	int ret;
  	char *err = NULL;
utils/nfsdcltrack/sqlite.h +1 -1
index 06e7c044..ba8cdfa8 100644
@@ -26,7 +26,7 @@ int sqlite_insert_client(const unsigned char *clname, const size_t namelen,
  int sqlite_remove_client(const unsigned char *clname, const size_t namelen);
  int sqlite_check_client(const unsigned char *clname, const size_t namelen,
  				const bool has_session);
-int sqlite_remove_unreclaimed(const time_t grace_start);
+int sqlite_remove_unreclaimed(const uint64_t grace_start);
  int sqlite_query_reclaiming(const time_t grace_start);
 
  #endif /* _SQLITE_H */
#3 lore raw
In reply to Steve Dickson
Quoted 11 lines · Steve Dickson

With recent commits (4f2a5b64,5a53426c) that fixed compile errors on x86_64 machines, caused similar errors on i686 machines.

The variable type that was being used was a time_t, which changes size between architects, which caused the compile error.

Changing the variable to uint64_t fixed the issue.

Committed....

steved.

Quoted 46 lines
---
  utils/nfsdcltrack/nfsdcltrack.c | 2 +-
  utils/nfsdcltrack/sqlite.c      | 2 +-
  utils/nfsdcltrack/sqlite.h      | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)
utils/nfsdcltrack/nfsdcltrack.c +1 -1
index 0b37c094..7c1c4bcc 100644
@@ -508,7 +508,7 @@ cltrack_gracedone(const char *timestr)
  {
  	int ret;
  	char *tail;
-	time_t gracetime;
+	uint64_t gracetime;
 
 
  	ret = sqlite_prepare_dbh(storagedir);
utils/nfsdcltrack/sqlite.c +1 -1
index cea4a411..cf0c6a45 100644
@@ -540,7 +540,7 @@ out_err:
   * remove any client records that were not reclaimed since grace_start.
   */
  int
-sqlite_remove_unreclaimed(time_t grace_start)
+sqlite_remove_unreclaimed(uint64_t grace_start)
  {
  	int ret;
  	char *err = NULL;
utils/nfsdcltrack/sqlite.h +1 -1
index 06e7c044..ba8cdfa8 100644
@@ -26,7 +26,7 @@ int sqlite_insert_client(const unsigned char *clname, const size_t namelen,
  int sqlite_remove_client(const unsigned char *clname, const size_t namelen);
  int sqlite_check_client(const unsigned char *clname, const size_t namelen,
  				const bool has_session);
-int sqlite_remove_unreclaimed(const time_t grace_start);
+int sqlite_remove_unreclaimed(const uint64_t grace_start);
  int sqlite_query_reclaiming(const time_t grace_start);
 
  #endif /* _SQLITE_H */