@@ -70,12 +70,13 @@ static inline cache_t *create_sim_cache(const char *eviction_algo,
7070 const char *window_size = strstr (eviction_params, " window-size=" );
7171 if (window_size == NULL ) {
7272 char dest[30 ];
73- strncpy (dest, eviction_params, 30 );
74- dest[29 ] = ' \0 ' ;
73+ strncpy (dest, eviction_params, sizeof (dest) - 1 );
74+ dest[sizeof (dest) - 1 ] = ' \0 ' ;
7575 size_t param_len = strlen (dest);
7676 char *new_params = (char *)malloc (param_len + 20 );
7777 if (param_len > 0 ) {
78- snprintf (new_params, param_len + 20 , " %s,window-size=0.01" , eviction_params);
78+ snprintf (new_params, param_len + 20 , " %s,window-size=0.01" ,
79+ eviction_params);
7980 } else { // if eviction_params is "", no comma is needed
8081 snprintf (new_params, 20 , " window-size=0.01" );
8182 }
@@ -87,30 +88,31 @@ static inline cache_t *create_sim_cache(const char *eviction_algo,
8788 }
8889 } else if (strcasecmp (eviction_algo, " wtinyLFU" ) == 0 ) {
8990 cache = WTinyLFU_init (cc_params, eviction_params);
90- /* TODO(haocheng): add belady support, since we remove the trace path, format info needs to be passed in through another parameter */
91- // } else if (strcasecmp(eviction_algo, "belady") == 0 &&
92- // strcasestr(trace_path, "lcs") == NULL) {
93- // if (strcasestr(trace_path, "oracleGeneral") == NULL) {
94- // WARN("belady is only supported for oracleGeneral and lcs trace\n");
95- // WARN("to convert a trace to lcs format\n");
96- // WARN("./bin/traceConv input_trace trace_format output_trace\n");
97- // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
98- // exit(1);
99- // }
100- // cache = Belady_init(cc_params, eviction_params);
91+ /* TODO(haocheng): add belady support, since we remove the trace path,
92+ * format info needs to be passed in through another parameter */
93+ // } else if (strcasecmp(eviction_algo, "belady") == 0 &&
94+ // strcasestr(trace_path, "lcs") == NULL) {
95+ // if (strcasestr(trace_path, "oracleGeneral") == NULL) {
96+ // WARN("belady is only supported for oracleGeneral and lcs trace\n");
97+ // WARN("to convert a trace to lcs format\n");
98+ // WARN("./bin/traceConv input_trace trace_format output_trace\n");
99+ // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
100+ // exit(1);
101+ // }
102+ // cache = Belady_init(cc_params, eviction_params);
101103 } else if (strcasecmp (eviction_algo, " nop" ) == 0 ) {
102104 cache = nop_init (cc_params, eviction_params);
103- // } else if (strcasecmp(eviction_algo, "beladySize") == 0) {
104- // if (strcasestr(trace_path, "oracleGeneral") == NULL &&
105- // strcasestr(trace_path, "lcs") == NULL) {
106- // WARN("beladySize is only supported for oracleGeneral and lcs trace\n");
107- // WARN("to convert a trace to lcs format\n");
108- // WARN("./bin/traceConv input_trace trace_format output_trace\n");
109- // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
110- // exit(1);
111- // }
112- // cc_params.hashpower = MAX(cc_params.hashpower - 8, 16);
113- // cache = BeladySize_init(cc_params, eviction_params);
105+ // } else if (strcasecmp(eviction_algo, "beladySize") == 0) {
106+ // if (strcasestr(trace_path, "oracleGeneral") == NULL &&
107+ // strcasestr(trace_path, "lcs") == NULL) {
108+ // WARN("beladySize is only supported for oracleGeneral and lcs
109+ // trace\n"); WARN("to convert a trace to lcs format\n");
110+ // WARN("./bin/traceConv input_trace trace_format output_trace\n");
111+ // WARN("./bin/traceConv ../data/cloudPhysicsIO.txt txt\n");
112+ // exit(1);
113+ // }
114+ // cc_params.hashpower = MAX(cc_params.hashpower - 8, 16);
115+ // cache = BeladySize_init(cc_params, eviction_params);
114116 } else if (strcasecmp (eviction_algo, " fifo-reinsertion" ) == 0 ||
115117 strcasecmp (eviction_algo, " clock" ) == 0 ||
116118 strcasecmp (eviction_algo, " second-chance" ) == 0 ) {
0 commit comments