Skip to content

Commit

Permalink
Fix printf for 32bit systems
Browse files Browse the repository at this point in the history
  • Loading branch information
trapexit committed Dec 9, 2022
1 parent a449829 commit a6ca96f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
45 changes: 23 additions & 22 deletions libfuse/lib/fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
Expand Down Expand Up @@ -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);

Expand Down
27 changes: 14 additions & 13 deletions src/num.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@

#include "ef.hpp"

#include <cstdint>
#include <string>

#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define KB (1024UL)
#define MB (KB * 1024UL)
#define GB (MB * 1024UL)
#define TB (GB * 1024UL)
#include <cstdint>
#include <string>

#define KB (1024ULL)
#define MB (KB * 1024ULL)
#define GB (MB * 1024ULL)
#define TB (GB * 1024ULL)


namespace num
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/policy_lfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace lfs
int error;
uint64_t lfs;
fs::info_t info;
const Branch *branch;
const string *basepath;

error = ENOENT;
Expand Down

0 comments on commit a6ca96f

Please sign in to comment.