Changeset 5e801dc in mainline for kernel/genarch/src/mm/page_ht.c


Ignore:
Timestamp:
2019-02-25T14:42:38Z (6 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a4e78743
Parents:
ee8d4d6
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-25 14:42:38)
git-committer:
GitHub <noreply@…> (2019-02-25 14:42:38)
Message:

Indicate and enforce constness of hash table key in certain functions (#158)

The assumption here is that modifying key in the hash/equal functions in something completely unexpected, and not something you would ever want to do intentionally, so it makes sense to disallow it entirely to get that extra level of checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/mm/page_ht.c

    ree8d4d6 r5e801dc  
    5454
    5555static size_t ht_hash(const ht_link_t *);
    56 static size_t ht_key_hash(void *);
    57 static bool ht_key_equal(void *, const ht_link_t *);
     56static size_t ht_key_hash(const void *);
     57static bool ht_key_equal(const void *, const ht_link_t *);
    5858static void ht_remove_callback(ht_link_t *);
    5959
     
    109109
    110110/** Return the hash of the key. */
    111 size_t ht_key_hash(void *arg)
    112 {
    113         uintptr_t *key = (uintptr_t *) arg;
     111size_t ht_key_hash(const void *arg)
     112{
     113        const uintptr_t *key = arg;
    114114        size_t hash = 0;
    115115        hash = hash_combine(hash, key[KEY_AS]);
     
    119119
    120120/** Return true if the key is equal to the item's lookup key. */
    121 bool ht_key_equal(void *arg, const ht_link_t *item)
    122 {
    123         uintptr_t *key = (uintptr_t *) arg;
     121bool ht_key_equal(const void *arg, const ht_link_t *item)
     122{
     123        const uintptr_t *key = arg;
    124124        pte_t *pte = hash_table_get_inst(item, pte_t, link);
    125125        return (key[KEY_AS] == (uintptr_t) pte->as) &&
Note: See TracChangeset for help on using the changeset viewer.