nfs-utils: print time in 64-bit
Subsystems (2)
PATCH 1/2 nfs-utils: print time in 64-bit
musl 1.2.0 defines time_t as 64-bit, even under 32-bit OSes.
Fixes -Wformat errors.
Signed-off-by Rosen Penev <[email protected]>
--- support/nfs/cacheio.c | 3 ++- utils/idmapd/idmapd.c | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-)
support/nfs/cacheio.c +2 -1
@@ -20,6 +20,7 @@#endif #include <nfslib.h> +#include <inttypes.h> #include <stdio.h> #include <stdio_ext.h> #include <string.h>
@@ -238,7 +239,7 @@ cache_flush(int force) stb.st_mtime > now) stb.st_mtime =time (0 ); -sprintf (stime,"%ld\n" , stb.st_mtime); +sprintf (stime,"%" PRId64"\n" , (int64_t )stb.st_mtime);for (c=0 ; cachelist[c]; c++) {int fd;sprintf (path,"/proc/net/rpc/%s/flush" , cachelist[c]);
utils/idmapd/idmapd.c +6 -5
@@ -54,6 +54,7 @@#include <dirent.h> #include <unistd.h> #include <netdb.h> +#include <inttypes.h> #include <signal.h> #include <stdio.h> #include <stdlib.h>
@@ -172,7 +173,7 @@ flush_nfsd_cache(char *path, time_t now)int fd;char stime[32 ]; -sprintf (stime,"%ld\n" , now); +sprintf (stime,"%" PRId64"\n" , (int64_t )now); fd =open (path,O_RDWR );if (fd ==-1 )return -1 ;
@@ -625,8 +626,8 @@ nfsdcb(int UNUSED(fd), short which, void *data)/* Name */ addfield (&bp, &bsiz, im.im_name);/* expiry */ -snprintf (buf1,sizeof (buf1),"%lu" , -time (NULL ) + cache_entry_expiration); +snprintf (buf1,sizeof (buf1),"%" PRId64, + (int64_t )time (NULL ) + cache_entry_expiration);addfield (&bp, &bsiz, buf1);/* Note that we don't want to write the id if the mapping * failed; instead, by leaving it off, we write a negative
@@ -653,8 +654,8 @@ nfsdcb(int UNUSED(fd), short which, void *data)snprintf (buf1,sizeof (buf1),"%u" , im.im_id);addfield (&bp, &bsiz, buf1);/* expiry */ -snprintf (buf1,sizeof (buf1),"%lu" , -time (NULL ) + cache_entry_expiration); +snprintf (buf1,sizeof (buf1),"%" PRId64, + (int64_t )time (NULL ) + cache_entry_expiration);addfield (&bp, &bsiz, buf1);/* Note we're ignoring the status field in this case; we'll * just map to nobody instead. */
Signature · 1 line
2.25.1
PATCH 2/2 nfs-utils: tools: use nls.h
libintl.h is not available everywhere. This fixes compilation.
Signed-off-by Rosen Penev <[email protected]>
--- tools/rpcgen/rpc_main.c | 2 +- tools/rpcgen/rpc_scan.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/rpcgen/rpc_main.c +1 -1
@@ -42,7 +42,6 @@#include <stdio.h> #include <string.h> #include <unistd.h> -#include <libintl.h> #include <locale.h> #include <ctype.h> #include <sys/types.h>
@@ -54,6 +53,7 @@#include "rpc_util.h" #include "rpc_scan.h" #include "proto.h" +#include "nls.h" #ifndef _#define _ (String) gettext (String)
tools/rpcgen/rpc_scan.c +1 -1
@@ -37,11 +37,11 @@#include <stdio.h> #include <ctype.h> #include <string.h> -#include <libintl.h> #include "rpc_scan.h" #include "rpc_parse.h" #include "rpc_util.h" #include "proto.h" +#include "nls.h" #ifndef _#define _ (String) gettext (String)
Signature · 1 line
2.25.1
Re: [PATCH 2/2] nfs-utils: tools: use nls.h
Quoted 3 lines · Rosen Penev
libintl.his not available everywhere. This fixes compilation.Signed-off-by Rosen Penev <[email protected]>
Committed... (tag: nfs-utils-2-4-4-rc3)
steved.
Quoted 43 lines
--- tools/rpcgen/rpc_main.c | 2 +- tools/rpcgen/rpc_scan.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/rpcgen/rpc_main.c +1
-1@@ -42,7 +42,6 @@#include <stdio.h> #include <string.h> #include <unistd.h> -#include <libintl.h> #include <locale.h> #include <ctype.h> #include <sys/types.h> @@ -54,6 +53,7 @@#include "rpc_util.h" #include "rpc_scan.h" #include "proto.h" +#include "nls.h" #ifndef _#define _ (String) gettext (String)tools/rpcgen/rpc_scan.c +1
-1@@ -37,11 +37,11 @@#include <stdio.h> #include <ctype.h> #include <string.h> -#include <libintl.h> #include "rpc_scan.h" #include "rpc_parse.h" #include "rpc_util.h" #include "proto.h" +#include "nls.h" #ifndef _#define _ (String) gettext (String)
Quoted 5 lines · Rosen Penev
musl 1.2.0 defines
time_tas 64-bit, even under 32-bit OSes.Fixes -Wformat errors.
Signed-off-by Rosen Penev <[email protected]>
Committed... (tag: nfs-utils-2-4-4-rc3)
steved.
Quoted 70 lines
--- support/nfs/cacheio.c | 3 ++- utils/idmapd/idmapd.c | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-)support/nfs/cacheio.c +2
-1@@ -20,6 +20,7 @@#endif #include <nfslib.h> +#include <inttypes.h> #include <stdio.h> #include <stdio_ext.h> #include <string.h> @@ -238,7 +239,7 @@ cache_flush(int force) stb.st_mtime > now) stb.st_mtime =time (0 ); -sprintf (stime,"%ld\n" , stb.st_mtime); +sprintf (stime,"%" PRId64"\n" , (int64_t )stb.st_mtime);for (c=0 ; cachelist[c]; c++) {int fd;sprintf (path,"/proc/net/rpc/%s/flush" , cachelist[c]);utils/idmapd/idmapd.c +6
-5@@ -54,6 +54,7 @@#include <dirent.h> #include <unistd.h> #include <netdb.h> +#include <inttypes.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -172,7 +173,7 @@ flush_nfsd_cache(char *path, time_t now)int fd;char stime[32 ]; -sprintf (stime,"%ld\n" , now); +sprintf (stime,"%" PRId64"\n" , (int64_t )now); fd =open (path,O_RDWR );if (fd ==-1 )return -1 ;@@ -625,8 +626,8 @@ nfsdcb(int UNUSED(fd), short which, void *data)/* Name */ addfield (&bp, &bsiz, im.im_name);/* expiry */ -snprintf (buf1,sizeof (buf1),"%lu" , -time (NULL ) + cache_entry_expiration); +snprintf (buf1,sizeof (buf1),"%" PRId64, + (int64_t )time (NULL ) + cache_entry_expiration);addfield (&bp, &bsiz, buf1);/* Note that we don't want to write the id if the mapping * failed; instead, by leaving it off, we write a negative @@ -653,8 +654,8 @@ nfsdcb(int UNUSED(fd), short which, void *data)snprintf (buf1,sizeof (buf1),"%u" , im.im_id);addfield (&bp, &bsiz, buf1);/* expiry */ -snprintf (buf1,sizeof (buf1),"%lu" , -time (NULL ) + cache_entry_expiration); +snprintf (buf1,sizeof (buf1),"%" PRId64, + (int64_t )time (NULL ) + cache_entry_expiration);addfield (&bp, &bsiz, buf1);/* Note we're ignoring the status field in this case; we'll * just map to nobody instead. */