Changeset 5e801dc in mainline for uspace/srv/vfs/vfs_node.c


Ignore:
Timestamp:
2019-02-25T14:42:38Z (5 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
  • uspace/srv/vfs/vfs_node.c

    ree8d4d6 r5e801dc  
    6060#define KEY_INDEX       2
    6161
    62 static size_t nodes_key_hash(void *);
     62static size_t nodes_key_hash(const void *);
    6363static size_t nodes_hash(const ht_link_t *);
    64 static bool nodes_key_equal(void *, const ht_link_t *);
     64static bool nodes_key_equal(const void *, const ht_link_t *);
    6565static vfs_triplet_t node_triplet(vfs_node_t *node);
    6666
     
    280280}
    281281
    282 static size_t nodes_key_hash(void *key)
    283 {
    284         vfs_triplet_t *tri = key;
     282static size_t nodes_key_hash(const void *key)
     283{
     284        const vfs_triplet_t *tri = key;
    285285        size_t hash = hash_combine(tri->fs_handle, tri->index);
    286286        return hash_combine(hash, tri->service_id);
     
    294294}
    295295
    296 static bool nodes_key_equal(void *key, const ht_link_t *item)
    297 {
    298         vfs_triplet_t *tri = key;
     296static bool nodes_key_equal(const void *key, const ht_link_t *item)
     297{
     298        const vfs_triplet_t *tri = key;
    299299        vfs_node_t *node = hash_table_get_inst(item, vfs_node_t, nh_link);
    300300        return node->fs_handle == tri->fs_handle &&
Note: See TracChangeset for help on using the changeset viewer.