From a6ca96fa08ba675767eb579af4149ecfb3011774 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 8 Dec 2022 22:04:15 -0500 Subject: [PATCH] Fix printf for 32bit systems --- libfuse/lib/fuse.c | 45 +++++++++++++++++++++++---------------------- src/num.cpp | 27 ++++++++++++++------------- src/policy_lfs.cpp | 1 - 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/libfuse/lib/fuse.c b/libfuse/lib/fuse.c index ee900198..1c910443 100644 --- a/libfuse/lib/fuse.c +++ b/libfuse/lib/fuse.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -3853,32 +3854,32 @@ metrics_log_nodes_info(struct fuse *f_, lfmp_lock(&f_->node_fmp); snprintf(buf,sizeof(buf), - "time: %zu\n" - "sizeof(node): %zu\n" - "node id_table size: %zu\n" - "node id_table usage: %zu\n" - "node id_table total allocated memory: %zu\n" - "node name_table size: %zu\n" - "node name_table usage: %zu\n" - "node name_table total allocated memory: %zu\n" - "node memory pool slab count: %zu\n" + "time: %"PRIu64"\n" + "sizeof(node): %"PRIu64"\n" + "node id_table size: %"PRIu64"\n" + "node id_table usage: %"PRIu64"\n" + "node id_table total allocated memory: %"PRIu64"\n" + "node name_table size: %"PRIu64"\n" + "node name_table usage: %"PRIu64"\n" + "node name_table total allocated memory: %"PRIu64"\n" + "node memory pool slab count: %"PRIu64"\n" "node memory pool usage ratio: %f\n" - "node memory pool avail objs: %zu\n" - "node memory pool total allocated memory: %zu\n" + "node memory pool avail objs: %"PRIu64"\n" + "node memory pool total allocated memory: %"PRIu64"\n" "\n" , - time(NULL), - sizeof(struct node), - f_->id_table.size, - f_->id_table.use, - (f_->id_table.size * sizeof(struct node*)), - f_->name_table.size, - f_->name_table.use, - (f_->name_table.size * sizeof(struct node*)), - fmp_slab_count(&f_->node_fmp.fmp), + (uint64_t)time(NULL), + (uint64_t)sizeof(struct node), + (uint64_t)f_->id_table.size, + (uint64_t)f_->id_table.use, + (uint64_t)(f_->id_table.size * sizeof(struct node*)), + (uint64_t)f_->name_table.size, + (uint64_t)f_->name_table.use, + (uint64_t)(f_->name_table.size * sizeof(struct node*)), + (uint64_t)fmp_slab_count(&f_->node_fmp.fmp), fmp_slab_usage_ratio(&f_->node_fmp.fmp), - fmp_avail_objs(&f_->node_fmp.fmp), - fmp_total_allocated_memory(&f_->node_fmp.fmp) + (uint64_t)fmp_avail_objs(&f_->node_fmp.fmp), + (uint64_t)fmp_total_allocated_memory(&f_->node_fmp.fmp) ); lfmp_unlock(&f_->node_fmp); diff --git a/src/num.cpp b/src/num.cpp index 667be092..7bfaf89b 100644 --- a/src/num.cpp +++ b/src/num.cpp @@ -16,17 +16,18 @@ #include "ef.hpp" -#include -#include - +#include #include #include #include -#define KB (1024UL) -#define MB (KB * 1024UL) -#define GB (MB * 1024UL) -#define TB (GB * 1024UL) +#include +#include + +#define KB (1024ULL) +#define MB (KB * 1024ULL) +#define GB (MB * 1024ULL) +#define TB (GB * 1024ULL) namespace num @@ -116,17 +117,17 @@ namespace num char buf[64]; if(bytes_ < KB) - sprintf(buf,"%lu",bytes_); + sprintf(buf,"%" PRIu64 "",bytes_); ef(((bytes_ / TB) * TB) == bytes_) - sprintf(buf,"%luT",bytes_ / TB); + sprintf(buf,"%" PRIu64 "T",bytes_ / TB); ef(((bytes_ / GB) * GB) == bytes_) - sprintf(buf,"%luG",bytes_ / GB); + sprintf(buf,"%" PRIu64 "G",bytes_ / GB); ef(((bytes_ / MB) * MB) == bytes_) - sprintf(buf,"%luM",bytes_ / MB); + sprintf(buf,"%" PRIu64 "M",bytes_ / MB); ef(((bytes_ / KB) * KB) == bytes_) - sprintf(buf,"%luK",bytes_ / KB); + sprintf(buf,"%" PRIu64 "K",bytes_ / KB); else - sprintf(buf,"%lu",bytes_); + sprintf(buf,"%" PRIu64 "",bytes_); return std::string(buf); } diff --git a/src/policy_lfs.cpp b/src/policy_lfs.cpp index ace2a1bf..9a931007 100644 --- a/src/policy_lfs.cpp +++ b/src/policy_lfs.cpp @@ -40,7 +40,6 @@ namespace lfs int error; uint64_t lfs; fs::info_t info; - const Branch *branch; const string *basepath; error = ENOENT;