Changeset 0c48e14 in mainline for uspace/srv/ns/service.c


Ignore:
Timestamp:
2019-02-24T15:45:40Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
91bef446
Parents:
52b44c6
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-02 15:07:29)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-24 15:45:40)
Message:

Indicate and enforce constness of hash table key in certain functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/ns/service.c

    r52b44c6 r0c48e14  
    6565} hashed_iface_t;
    6666
    67 static size_t service_key_hash(void *key)
    68 {
    69         return *(service_t *) key;
     67static size_t service_key_hash(const void *key)
     68{
     69        const service_t *srv = key;
     70        return *srv;
    7071}
    7172
     
    7879}
    7980
    80 static bool service_key_equal(void *key, const ht_link_t *item)
    81 {
     81static bool service_key_equal(const void *key, const ht_link_t *item)
     82{
     83        const service_t *srv = key;
    8284        hashed_service_t *service =
    8385            hash_table_get_inst(item, hashed_service_t, link);
    8486
    85         return service->service == *(service_t *) key;
    86 }
    87 
    88 static size_t iface_key_hash(void *key)
    89 {
    90         return *(iface_t *) key;
     87        return service->service == *srv;
     88}
     89
     90static size_t iface_key_hash(const void *key)
     91{
     92        const iface_t *iface = key;
     93        return *iface;
    9194}
    9295
     
    99102}
    100103
    101 static bool iface_key_equal(void *key, const ht_link_t *item)
    102 {
     104static bool iface_key_equal(const void *key, const ht_link_t *item)
     105{
     106        const iface_t *kiface = key;
    103107        hashed_iface_t *iface =
    104108            hash_table_get_inst(item, hashed_iface_t, link);
    105109
    106         return iface->iface == *(iface_t *) key;
     110        return iface->iface == *kiface;
    107111}
    108112
Note: See TracChangeset for help on using the changeset viewer.