Skip to content

Commit dde15c1

Browse files
committed
Fix format specifiers in printf statements by using platform independent format macros (i.e. PRId64)
1 parent 7596556 commit dde15c1

19 files changed

Lines changed: 427 additions & 242 deletions

File tree

libCacheSim/bin/MRC/SHARDS.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void generate_shards_mrc(struct PARAM *params, char *path) {
9999
params->reader->init_params.sampler->sampling_ratio = 1.0;
100100
params->reader->sampler->sampling_ratio = 1.0;
101101
uint64_t n_req = get_num_of_req(params->reader);
102-
printf("n_req: %lu\n", n_req);
102+
printf("n_req: %" PRIu64 "\n", n_req);
103103
params->reader->init_params.sampler->sampling_ratio = params->rate;
104104
params->reader->sampler->sampling_ratio = params->rate;
105105

libCacheSim/bin/MRC/main.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@
44
#include <assert.h>
55
#include <libgen.h>
66
#include <unistd.h>
7+
78
#include "../../include/libCacheSim/sampling.h"
89
#include "../cachesim/internal.h"
910
#include "mrc_internal.h"
1011

1112
int main(int argc, char **argv) {
1213
if (argc < 5) {
13-
fprintf(stderr, "Usage:\n"
14+
fprintf(stderr,
15+
"Usage:\n"
1416
" For SHARDS:\n"
15-
" %s SHARDS <output_file> <trace_file> <trace_type> <rate> [--size SIZE] [other options]\n\n"
17+
" %s SHARDS <output_file> <trace_file> <trace_type> <rate> "
18+
"[--size SIZE] [other options]\n\n"
1619
" For MINI:\n"
17-
" %s MINI <trace_file> <trace_type> <eviction_algo> <cache_sizes> <rate> <output_file> [other options]\n",
20+
" %s MINI <trace_file> <trace_type> <eviction_algo> "
21+
"<cache_sizes> <rate> <output_file> [other options]\n",
1822
argv[0], argv[0]);
1923
return 1;
20-
}
24+
}
2125

2226
// printf("Received Arguments:\n");
2327
// for (int i = 0; i < argc; i++) {
@@ -27,7 +31,7 @@ int main(int argc, char **argv) {
2731
char *algorithm_type = argv[1];
2832
printf("Algorithm type: %s\n", algorithm_type);
2933
if (strcmp(algorithm_type, "MINI") == 0) {
30-
char* path=argv[7];
34+
char *path = argv[7];
3135
struct MINI_arguments arguments;
3236
parse_mini_cmd(argc, argv, &arguments);
3337
cache_stat_t *return_value = generate_mini_mrc(&arguments);
@@ -39,11 +43,16 @@ int main(int argc, char **argv) {
3943
}
4044

4145
fprintf(output_file, "Cache Size,Miss Ratio, Miss Ratio Byte\n");
42-
for (int i = 0; i < arguments.n_cache_size * arguments.n_eviction_algo; i++) {
43-
uint64_t cache_size = (uint64_t)((float)return_value[i].cache_size / return_value[i].sampler_ratio);
44-
double miss_ratio = (double)return_value[i].n_miss / (double)return_value[i].n_req;
45-
double miss_ratio_byte = (double)return_value[i].n_miss_byte / (double)return_value[i].n_req_byte;
46-
fprintf(output_file, "%ld,%f, %f\n", cache_size, miss_ratio, miss_ratio_byte);
46+
for (int i = 0; i < arguments.n_cache_size * arguments.n_eviction_algo;
47+
i++) {
48+
uint64_t cache_size = (uint64_t)((float)return_value[i].cache_size /
49+
return_value[i].sampler_ratio);
50+
double miss_ratio =
51+
(double)return_value[i].n_miss / (double)return_value[i].n_req;
52+
double miss_ratio_byte = (double)return_value[i].n_miss_byte /
53+
(double)return_value[i].n_req_byte;
54+
fprintf(output_file, "%" PRId64 ",%f, %f\n", cache_size, miss_ratio,
55+
miss_ratio_byte);
4756
}
4857

4958
fclose(output_file);
@@ -57,4 +66,4 @@ int main(int argc, char **argv) {
5766
fprintf(stderr, "Error: unknown algorithm type\n");
5867
return 1;
5968
}
60-
}
69+
}

libCacheSim/bin/cachesim/sim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void simulate(reader_t *reader, cache_t *cache, int report_interval, int warmup_
9393
(double)req_cnt / 1000000.0 / runtime);
9494
} else {
9595
snprintf(output_str, 1024,
96-
"%s %s cache size %8ld, %16lu req, miss ratio %.4lf, throughput "
96+
"%s %s cache size %8" PRId64 ", %16lu req, miss ratio %.4lf, throughput "
9797
"%.2lf MQPS\n",
9898
reader->trace_path, detailed_cache_name, cache->cache_size,
9999
(unsigned long)req_cnt, (double)miss_cnt / (double)req_cnt,

libCacheSim/bin/debug/aligned.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void test_unaligned_read_mmap(char* filepath) {
142142
printf("uint16_t unaligned read time: %.4f sec\n", time_read_uint16_unaligned);
143143
printf("uint8_t aligned read time: %.4f sec\n", time_read_uint8_aligned);
144144
printf("uint8_t unaligned read time: %.4f sec\n", time_read_uint8_unaligned);
145-
printf("s: %ld\n", s);
145+
printf("s: %" PRId64 "\n", s);
146146

147147
close(fd);
148148
}
@@ -264,7 +264,7 @@ void test_unaligned_read_mmap_struct(char* filepath) {
264264
printf("struct aligned read time: %.4f sec\n", time_read_struct_aligned);
265265
printf("struct unaligned read time: %.4f sec\n", time_read_struct_unaligned);
266266

267-
printf("s: %ld\n", s);
267+
printf("s: %" PRId64 "\n", s);
268268
close(fd);
269269
}
270270

@@ -314,7 +314,7 @@ void test_unaligned_read_struct(char* filepath) {
314314
printf("struct aligned read time: %.4f sec\n", time_read_struct_aligned);
315315
printf("struct unaligned read time: %.4f sec\n", time_read_struct_unaligned);
316316

317-
printf("s: %ld\n", s);
317+
printf("s: %" PRId64 "\n", s);
318318
}
319319

320320
int main(int argc, char* argv[]) {

libCacheSim/bin/mrcProfiler/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void print_args(struct arguments *args) {
1919
printf("trace_type: %d\n", args->trace_type);
2020
printf("trace_type_params: %s\n", args->trace_type_params);
2121
printf("ofilepath: %s\n", args->ofilepath);
22-
printf("n_req: %ld\n", args->n_req);
22+
printf("n_req: %" PRId64 "\n", args->n_req);
2323
printf("verbose: %d\n", args->verbose);
2424
printf("cache_algorithm_str: %s\n", args->cache_algorithm_str);
2525
printf("mrc_size_str: %s\n", args->mrc_size_str);

0 commit comments

Comments
 (0)