Changeset 3bacee1 in mainline for kernel/test/cht/cht1.c


Ignore:
Timestamp:
2018-04-12T16:27:17Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3cf22f9
Parents:
76d0981d
git-author:
Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
git-committer:
Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
Message:

Make ccheck-fix again and commit more good files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/cht/cht1.c

    r76d0981d r3bacee1  
    9595
    9696
    97 static const char * do_sanity_test(cht_t *h)
    98 {
    99         if (cht_find_lazy(h, (void*)0))
     97static const char *do_sanity_test(cht_t *h)
     98{
     99        if (cht_find_lazy(h, (void *)0))
    100100                return "Found lazy in empty table.";
    101101
    102         if (cht_find(h, (void*)0))
     102        if (cht_find(h, (void *)0))
    103103                return "Found in empty table.";
    104104
    105         if (cht_remove_key(h, (void*)0))
     105        if (cht_remove_key(h, (void *)0))
    106106                return "Removed from empty table.";
    107107
     
    149149                return "Refused unique ins 4, 5.";
    150150
    151         if (cht_find(h, (void*)0))
     151        if (cht_find(h, (void *)0))
    152152                return "Phantom find.";
    153153
    154         cht_link_t *item = cht_find(h, (void*)v[5]->unique_id);
     154        cht_link_t *item = cht_find(h, (void *)v[5]->unique_id);
    155155        if (!item || item != &v[5]->link)
    156156                return "Missing 5.";
     
    160160                return "Found nonexisting duplicate 5";
    161161
    162         item = cht_find(h, (void*)v[3]->unique_id);
     162        item = cht_find(h, (void *)v[3]->unique_id);
    163163        if (!item || item != &v[3]->link)
    164164                return "Missing 3.";
     
    168168                return "Found nonexisting duplicate 3, same hash as others.";
    169169
    170         item = cht_find(h, (void*)v[0]->unique_id);
    171         ((val_t*)item)->mark = true;
     170        item = cht_find(h, (void *)v[0]->unique_id);
     171        ((val_t *)item)->mark = true;
    172172
    173173        for (int k = 1; k < 3; ++k) {
     
    176176                        return "Did not find an inserted duplicate";
    177177
    178                 val_t *val = ((val_t*)item);
     178                val_t *val = ((val_t *)item);
    179179
    180180                if (val->unique_id != v[0]->unique_id)
     
    195195                return "Found non-existing duplicate.";
    196196
    197         item = cht_find_next(h, cht_find(h, (void*)key[0]));
    198 
    199         ((val_t*)item)->mark = true;
     197        item = cht_find_next(h, cht_find(h, (void *)key[0]));
     198
     199        ((val_t *)item)->mark = true;
    200200        if (!cht_remove_item(h, item))
    201201                return "Failed to remove inserted item";
    202202
    203         item = cht_find(h, (void*)key[0]);
    204         if (!item || ((val_t*)item)->mark)
     203        item = cht_find(h, (void *)key[0]);
     204        if (!item || ((val_t *)item)->mark)
    205205                return "Did not find proper item.";
    206206
    207207        item = cht_find_next(h, item);
    208         if (!item || ((val_t*)item)->mark)
     208        if (!item || ((val_t *)item)->mark)
    209209                return "Did not find proper duplicate.";
    210210
     
    213213                return "Found removed duplicate";
    214214
    215         if (2 != cht_remove_key(h, (void*)key[0]))
     215        if (2 != cht_remove_key(h, (void *)key[0]))
    216216                return "Failed to remove all duplicates";
    217217
    218         if (cht_find(h, (void*)key[0]))
     218        if (cht_find(h, (void *)key[0]))
    219219                return "Found removed key";
    220220
    221         if (!cht_find(h, (void*)key[3]))
     221        if (!cht_find(h, (void *)key[3]))
    222222                return "Removed incorrect key";
    223223
    224224        for (size_t k = 0; k < sizeof(v) / sizeof(v[0]); ++k) {
    225                 cht_remove_key(h, (void*)key[k]);
     225                cht_remove_key(h, (void *)key[k]);
    226226        }
    227227
    228228        for (size_t k = 0; k < sizeof(v) / sizeof(v[0]); ++k) {
    229                 if (cht_find(h, (void*)key[k]))
     229                if (cht_find(h, (void *)key[k]))
    230230                        return "Found a key in a cleared table";
    231231        }
     
    234234}
    235235
    236 static const char * sanity_test(void)
     236static const char *sanity_test(void)
    237237{
    238238        cht_t h;
     
    279279static size_t stress_hash(const cht_link_t *item)
    280280{
    281         return ((stress_t*)item)->key >> 8;
     281        return ((stress_t *)item)->key >> 8;
    282282}
    283283static size_t stress_key_hash(void *key)
     
    287287static bool stress_equal(const cht_link_t *item1, const cht_link_t *item2)
    288288{
    289         return ((stress_t*)item1)->key == ((stress_t*)item2)->key;
     289        return ((stress_t *)item1)->key == ((stress_t *)item2)->key;
    290290}
    291291static bool stress_key_equal(void *key, const cht_link_t *item)
    292292{
    293         return ((size_t)key) == ((stress_t*)item)->key;
     293        return ((size_t)key) == ((stress_t *)item)->key;
    294294}
    295295static void stress_rm_callback(cht_link_t *item)
    296296{
    297         if (((stress_t*)item)->free)
     297        if (((stress_t *)item)->free)
    298298                free(item);
    299299        else
    300                 ((stress_t*)item)->deleted = true;
     300                ((stress_t *)item)->deleted = true;
    301301}
    302302
     
    335335                        size_t key = (i << 8) + work->id;
    336336
    337                         if (1 != cht_remove_key(work->h, (void*)key)) {
     337                        if (1 != cht_remove_key(work->h, (void *)key)) {
    338338                                TPRINTF("Err: Failed to remove inserted item\n");
    339339                                goto failed;
     
    357357        for (size_t i = 0; i < work->wave_elems; ++i) {
    358358                size_t key = (i << 8) + work->id;
    359                 cht_remove_key(work->h, (void*)key);
     359                cht_remove_key(work->h, (void *)key);
    360360        }
    361361}
     
    392392                                        rcu_read_unlock();
    393393                                } else {
    394                                         void *key = (void*)work->elem[elem_idx].key;
     394                                        void *key = (void *)work->elem[elem_idx].key;
    395395                                        if (1 != cht_remove_key(work->h, key)) {
    396396                                                TPRINTF("Err: did not rm the key\n");
     
    406406                                        cht_link_t *dup;
    407407                                        if (!cht_insert_unique(work->h, &work->elem[elem_idx].link,
    408                                                 &dup)) {
     408                                            &dup)) {
    409409                                                TPRINTF("Err: already inserted\n");
    410410                                                work->failed = true;
     
    420420                        rcu_read_lock();
    421421                        cht_link_t *item =
    422                                 cht_find(work->h, (void*)work->elem[elem_idx].key);
     422                            cht_find(work->h, (void *)work->elem[elem_idx].key);
    423423                        rcu_read_unlock();
    424424
     
    444444        /* Remove anything we may have inserted. */
    445445        for (size_t i = 0; i < work->elem_cnt; ++i) {
    446                 void *key = (void*) work->elem[i].key;
     446                void *key = (void *) work->elem[i].key;
    447447                cht_remove_key(work->h, key);
    448448        }
     
    469469
    470470        /* Alloc hash table items. */
    471         size_t size = item_cnt * sizeof(stress_t) + work_cnt * sizeof(stress_work_t)
    472                 + sizeof(int);
     471        size_t size = item_cnt * sizeof(stress_t) + work_cnt * sizeof(stress_work_t) +
     472            sizeof(int);
    473473
    474474        TPRINTF("Alloc and init table items. \n");
     
    482482        stress_t *pitem = p + work_cnt * sizeof(stress_work_t);
    483483        stress_work_t *pwork = p;
    484         int *pstop = (int*)(pitem + item_cnt);
     484        int *pstop = (int *)(pitem + item_cnt);
    485485
    486486        *pstop = 0;
     
    517517
    518518        TPRINTF("Running %zu ins/del/find stress threads + %zu resizers.\n",
    519                 op_thread_cnt, resize_thread_cnt);
     519            op_thread_cnt, resize_thread_cnt);
    520520
    521521        /* Create and run threads. */
Note: See TracChangeset for help on using the changeset viewer.