Skip to content

Commit d4f1f2d

Browse files
authored
[Fix] Remove unnecessary const qualifier from pass-by-value parameters (#298)
* [Fix] Remove unnecessary const qualifier from pass-by-value parameters * [Fix] Removing the const qualifier from interface * [Fix] clang-format warning
1 parent f1a56cd commit d4f1f2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+222
-223
lines changed

doc/advanced_lib.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ cache_t *LRU_init(const common_cache_params_t ccache_params,
2929
void LRU_free(cache_t *cache);
3030
bool LRU_get(cache_t *cache, const request_t *req);
3131
cache_obj_t *LRU_find(cache_t *cache, const request_t *req,
32-
const bool update_cache);
32+
bool update_cache);
3333
cache_obj_t *LRU_insert(cache_t *cache, const request_t *req);
3434
cache_obj_t *LRU_to_evict(cache_t *cache, const request_t *req);
3535
void LRU_evict(cache_t *cache, const request_t *req);
36-
bool LRU_remove(cache_t *cache, const obj_id_t obj_id);
36+
bool LRU_remove(cache_t *cache, obj_id_t obj_id);
3737
```
3838
3939
#### Create Cache

doc/advanced_lib_extend.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void LRU_free(cache_t *cache);
1515
bool LRU_get(cache_t *cache, const request_t *req);
1616

1717
/* find an object in the cache, return the cache object if found, NULL otherwise, update_cache means whether update the cache state, e.g., moving object to the head of the queue */
18-
cache_obj_t *LRU_find(cache_t *cache, const request_t *req, const bool update_cache);
18+
cache_obj_t *LRU_find(cache_t *cache, const request_t *req, bool update_cache);
1919

2020
/* insert an object to the cache, return the cache object, this assumes the object is not in the cache */
2121
cache_obj_t *LRU_insert(cache_t *cache, const request_t *req);
@@ -27,7 +27,7 @@ cache_obj_t *LRU_to_evict(cache_t *cache, const request_t *req);
2727
void LRU_evict(cache_t *cache, const request_t *req);
2828

2929
/* remove an object from the cache, return true if the object is found and removed, note that this is used for user-triggered remove, eviction should use evict */
30-
bool LRU_remove(cache_t *cache, const obj_id_t obj_id);
30+
bool LRU_remove(cache_t *cache, obj_id_t obj_id);
3131
```
3232
3333
Specifically, you can following the steps:

doc/quickstart_plugin.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Your library **must** export the following C-symbols:
6161
| `cache_hit_hook` | `void cache_hit_hook(void *data, const request_t *req);` | A requested object is found in the cache. |
6262
| `cache_miss_hook` | `void cache_miss_hook(void *data, const request_t *req);` | A requested object is **not** in the cache *after* insertion. |
6363
| `cache_eviction_hook` | `obj_id_t cache_eviction_hook(void *data, const request_t *req);` | Cache is full – must return the object-ID to evict. |
64-
| `cache_remove_hook` | `void cache_remove_hook(void *data, const obj_id_t obj_id);` | An object is explicitly removed (not necessarily due to eviction). |
64+
| `cache_remove_hook` | `void cache_remove_hook(void *data, obj_id_t obj_id);` | An object is explicitly removed (not necessarily due to eviction). |
6565

6666
The opaque pointer returned by `cache_init_hook` is passed back to every other hook via the `data` parameter, letting your plugin maintain arbitrary state (linked lists, hash maps, statistics, …). For memory safety, your library can export `cache_free_hook` (`void cache_free_hook(void *data);`) to free the resources used by your cache struct according to your demands.
6767

@@ -100,7 +100,7 @@ obj_id_t cache_eviction_hook(void *data, const request_t * /*req*/) {
100100
return static_cast<MyPolicy *>(data)->evict();
101101
}
102102

103-
void cache_remove_hook(void *data, const obj_id_t obj_id) {
103+
void cache_remove_hook(void *data, obj_id_t obj_id) {
104104
static_cast<MyPolicy *>(data)->on_remove(obj_id);
105105
}
106106
} // extern "C"

example/plugin_v1/plugin_lru.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static bool plugin_lru_get(cache_t *cache, const request_t *req) {
135135
* @return the cache object if found, NULL otherwise
136136
*/
137137
static cache_obj_t *plugin_lru_find(cache_t *cache, const request_t *req,
138-
const bool update_cache) {
138+
bool update_cache) {
139139
plugin_lru_params_t *params = (plugin_lru_params_t *)cache->eviction_params;
140140
cache_obj_t *cache_obj = cache_find_base(cache, req, update_cache);
141141

@@ -228,7 +228,7 @@ static void plugin_lru_remove_obj(cache_t *cache, cache_obj_t *obj) {
228228
* @return true if the object is removed, false if the object is not in the
229229
* cache
230230
*/
231-
static bool plugin_lru_remove(cache_t *cache, const obj_id_t obj_id) {
231+
static bool plugin_lru_remove(cache_t *cache, obj_id_t obj_id) {
232232
request_t req = {.obj_id = obj_id, .obj_size = 0};
233233
cache_obj_t *obj = cache_find_base(cache, &req, false);
234234

example/plugin_v2/plugin_lru.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ obj_id_t cache_eviction_hook(void *data, const request_t *req) {
133133
}
134134

135135
// implement the cache remove hook
136-
void cache_remove_hook(void *data, const obj_id_t obj_id) {
136+
void cache_remove_hook(void *data, obj_id_t obj_id) {
137137
// remove object from the cache
138138
StandaloneLRU *lru_cache = (StandaloneLRU *)data;
139139
lru_cache->cache_remove(obj_id);

libCacheSim/cache/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ bool cache_can_insert_default(cache_t *cache, const request_t *req) {
179179
* @return the found cache_obj_t* or NULL if not found
180180
*/
181181
cache_obj_t *cache_find_base(cache_t *cache, const request_t *req,
182-
const bool update_cache) {
182+
bool update_cache) {
183183
cache_obj_t *cache_obj = hashtable_find(cache->hashtable, req);
184184

185185
// "update_cache = true" means that it is a real user request, use handle_find

libCacheSim/cache/eviction/3LCache/ThreeLCache_Interface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ static void ThreeLCache_free(cache_t *cache);
3131
static bool ThreeLCache_get(cache_t *cache, const request_t *req);
3232

3333
static cache_obj_t *ThreeLCache_find(cache_t *cache, const request_t *req,
34-
const bool update_cache);
34+
bool update_cache);
3535
static cache_obj_t *ThreeLCache_insert(cache_t *cache, const request_t *req);
3636
static cache_obj_t *ThreeLCache_to_evict(cache_t *cache, const request_t *req);
3737
static void ThreeLCache_evict(cache_t *cache, const request_t *req);
38-
static bool ThreeLCache_remove(cache_t *cache, const obj_id_t obj_id);
38+
static bool ThreeLCache_remove(cache_t *cache, obj_id_t obj_id);
3939
static int64_t ThreeLCache_get_occupied_byte(const cache_t *cache);
4040
static int64_t ThreeLCache_get_n_obj(const cache_t *cache);
4141

@@ -181,7 +181,7 @@ static bool ThreeLCache_get(cache_t *cache, const request_t *req) {
181181
* @return the object or NULL if not found
182182
*/
183183
static cache_obj_t *ThreeLCache_find(cache_t *cache, const request_t *req,
184-
const bool update_cache) {
184+
bool update_cache) {
185185
auto *params = static_cast<ThreeLCache_params_t *>(cache->eviction_params);
186186
auto *ThreeLCache =
187187
static_cast<ThreeLCache::ThreeLCacheCache *>(params->ThreeLCache_cache);
@@ -288,7 +288,7 @@ static void ThreeLCache_evict(cache_t *cache, const request_t *req) {
288288
* @return true if the object is removed, false if the object is not in the
289289
* cache
290290
*/
291-
static bool ThreeLCache_remove(cache_t *cache, const obj_id_t obj_id) {
291+
static bool ThreeLCache_remove(cache_t *cache, obj_id_t obj_id) {
292292
auto *params = static_cast<ThreeLCache_params_t *>(cache->eviction_params);
293293
auto *ThreeLCache =
294294
static_cast<ThreeLCache::ThreeLCacheCache *>(params->ThreeLCache_cache);

libCacheSim/cache/eviction/ARC.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ static void ARC_parse_params(cache_t *cache, const char *cache_specific_params);
6262
static void ARC_free(cache_t *cache);
6363
static bool ARC_get(cache_t *cache, const request_t *req);
6464
static cache_obj_t *ARC_find(cache_t *cache, const request_t *req,
65-
const bool update_cache);
65+
bool update_cache);
6666
static cache_obj_t *ARC_insert(cache_t *cache, const request_t *req);
6767
static cache_obj_t *ARC_to_evict(cache_t *cache, const request_t *req);
6868
static void ARC_evict(cache_t *cache, const request_t *req);
69-
static bool ARC_remove(cache_t *cache, const obj_id_t obj_id);
69+
static bool ARC_remove(cache_t *cache, obj_id_t obj_id);
7070

7171
/* internal functions */
7272
/* this is the case IV in the paper */
@@ -217,7 +217,7 @@ static bool ARC_get(cache_t *cache, const request_t *req) {
217217
* @return the object or NULL if not found
218218
*/
219219
static cache_obj_t *ARC_find(cache_t *cache, const request_t *req,
220-
const bool update_cache) {
220+
bool update_cache) {
221221
ARC_params_t *params = (ARC_params_t *)(cache->eviction_params);
222222

223223
cache_obj_t *obj = cache_find_base(cache, req, update_cache);
@@ -384,7 +384,7 @@ static void ARC_evict(cache_t *cache, const request_t *req) {
384384
* @return true if the object is removed, false if the object is not in the
385385
* cache
386386
*/
387-
static bool ARC_remove(cache_t *cache, const obj_id_t obj_id) {
387+
static bool ARC_remove(cache_t *cache, obj_id_t obj_id) {
388388
ARC_params_t *params = (ARC_params_t *)(cache->eviction_params);
389389
cache_obj_t *obj = hashtable_find_obj_id(cache->hashtable, obj_id);
390390

libCacheSim/cache/eviction/ARCv0.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ static void ARCv0_parse_params(cache_t *cache,
5555
static void ARCv0_free(cache_t *cache);
5656
static bool ARCv0_get(cache_t *cache, const request_t *req);
5757
static cache_obj_t *ARCv0_find(cache_t *cache, const request_t *req,
58-
const bool update_cache);
58+
bool update_cache);
5959
static cache_obj_t *ARCv0_insert(cache_t *cache, const request_t *req);
6060
static cache_obj_t *ARCv0_to_evict(cache_t *cache, const request_t *req);
6161
static void ARCv0_evict(cache_t *cache, const request_t *req);
62-
static bool ARCv0_remove(cache_t *cache, const obj_id_t obj_id);
62+
static bool ARCv0_remove(cache_t *cache, obj_id_t obj_id);
6363
static int64_t ARCv0_get_occupied_byte(const cache_t *cache);
6464
static int64_t ARCv0_get_n_obj(const cache_t *cache);
6565

@@ -204,7 +204,7 @@ static bool ARCv0_get(cache_t *cache, const request_t *req) {
204204
* @return the object or NULL if not found
205205
*/
206206
static cache_obj_t *ARCv0_find(cache_t *cache, const request_t *req,
207-
const bool update_cache) {
207+
bool update_cache) {
208208
ARCv0_params_t *params = (ARCv0_params_t *)(cache->eviction_params);
209209

210210
cache_obj_t *obj_t1 = params->T1->find(params->T1, req, false);
@@ -358,7 +358,7 @@ static void ARCv0_evict(cache_t *cache, const request_t *req) {
358358
* @return true if the object is removed, false if the object is not in the
359359
* cache
360360
*/
361-
static bool ARCv0_remove(cache_t *cache, const obj_id_t obj_id) {
361+
static bool ARCv0_remove(cache_t *cache, obj_id_t obj_id) {
362362
ARCv0_params_t *params = (ARCv0_params_t *)(cache->eviction_params);
363363
bool removed = false;
364364
removed |= params->T1->remove(params->T1, obj_id);

libCacheSim/cache/eviction/Belady.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ typedef struct Belady_params {
3333
static void Belady_free(cache_t *cache);
3434
static bool Belady_get(cache_t *cache, const request_t *req);
3535
static cache_obj_t *Belady_find(cache_t *cache, const request_t *req,
36-
const bool update_cache);
36+
bool update_cache);
3737
static cache_obj_t *Belady_insert(cache_t *cache, const request_t *req);
3838
static cache_obj_t *Belady_to_evict(cache_t *cache, const request_t *req);
3939
static void Belady_evict(cache_t *cache, const request_t *req);
40-
static bool Belady_remove(cache_t *cache, const obj_id_t obj_id);
40+
static bool Belady_remove(cache_t *cache, obj_id_t obj_id);
4141
static void Belady_remove_obj(cache_t *cache, cache_obj_t *obj);
4242

4343
// ***********************************************************************
@@ -139,7 +139,7 @@ static bool Belady_get(cache_t *cache, const request_t *req) {
139139
* @return the object or NULL if not found
140140
*/
141141
static cache_obj_t *Belady_find(cache_t *cache, const request_t *req,
142-
const bool update_cache) {
142+
bool update_cache) {
143143
Belady_params_t *params = cache->eviction_params;
144144
cache_obj_t *cached_obj = cache_find_base(cache, req, update_cache);
145145

@@ -270,7 +270,7 @@ static void Belady_remove_obj(cache_t *cache, cache_obj_t *obj) {
270270
* @return true if the object is removed, false if the object is not in the
271271
* cache
272272
*/
273-
static bool Belady_remove(cache_t *cache, const obj_id_t obj_id) {
273+
static bool Belady_remove(cache_t *cache, obj_id_t obj_id) {
274274
cache_obj_t *obj = hashtable_find_obj_id(cache->hashtable, obj_id);
275275
if (obj == NULL) {
276276
return false;

0 commit comments

Comments
 (0)