Changeset 205832b in mainline


Ignore:
Timestamp:
2012-11-05T15:37:39Z (12 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f048658
Parents:
6b99156
Message:

Replaced 0 with NULL where appropriate (in rcu, cht, uspace hashtable, smp_call, workqueue).

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/adt/cht.c

    r6b99156 r205832b  
    151151/* Sentinel node used by all buckets. Stores the greatest possible hash value.*/
    152152static const cht_link_t sentinel = {
    153         .link = 0,
     153        /* NULL and N_NORMAL */
     154        .link = 0 | N_NORMAL,
    154155        .hash = -1
    155156};
     
    265266        h->max_load = (max_load == 0) ? CHT_MAX_LOAD : max_load;
    266267        h->min_order = min_order;
    267         h->new_b = 0;
     268        h->new_b = NULL;
    268269        h->op = op;
    269270        atomic_set(&h->item_cnt, 0);
     
    298299       
    299300        if (!b)
    300                 return 0;
     301                return NULL;
    301302       
    302303        b->order = order;
     
    346347       
    347348        free(h->b);
    348         h->b = 0;
     349        h->b = NULL;
    349350       
    350351        /* You must clear the table of items. Otherwise cht_destroy will leak. */
     
    457458         */
    458459
    459         cht_link_t *cur = 0;
     460        cht_link_t *cur = NULL;
    460461        marked_ptr_t prev = head;
    461462
     
    492493        }
    493494       
    494         return 0;
     495        return NULL;
    495496}
    496497
     
    607608                         * points to an allocated join node (if non-null) even if marked
    608609                         * invalid. Before the resizer lets join nodes to be unlinked
    609                          * (and freed) it sets old_head to 0 and waits for a grace period.
     610                         * (and freed) it sets old_head to NULL and waits for a grace period.
    610611                         * So either the invalid old_head points to join node; or old_head
    611612                         * is null and we would have seen a completed bucket join while
     
    616617                }
    617618               
    618                 return 0;
     619                return NULL;
    619620        } else {
    620621                /*
     
    700701                        .ppred = phead,
    701702                        .cur = get_next(*phead),
    702                         .last = 0
     703                        .last = NULL
    703704                };
    704705               
     
    807808         */
    808809        read_barrier();
    809         return 0 != find_duplicate(h, item, hash, wnd->cur);
     810        return NULL != find_duplicate(h, item, hash, wnd->cur);
    810811}
    811812
     
    840841        }
    841842       
    842         return 0;       
     843        return NULL;
    843844}
    844845
     
    908909                        .ppred = phead,
    909910                        .cur = get_next(*phead),
    910                         .last = 0
     911                        .last = NULL
    911912                };
    912913               
     
    11941195        }
    11951196
    1196         /* wnd->cur may be 0 or even marked N_DELETED. */
     1197        /* wnd->cur may be NULL or even marked N_DELETED. */
    11971198        return true;
    11981199}
     
    19661967       
    19671968        /* Not needed; just for increased readability. */
    1968         h->new_b = 0;
     1969        h->new_b = NULL;
    19691970}
    19701971
     
    20652066       
    20662067        /* Not needed; just for increased readability. */
    2067         h->new_b = 0;
     2068        h->new_b = NULL;
    20682069}
    20692070
     
    21442145
    21452146        wnd_t wnd = {
    2146                 .ppred = 0,
    2147                 .cur = 0
     2147                .ppred = NULL,
     2148                .cur = NULL
    21482149        };
    21492150        marked_ptr_t *cur_link = new_head;
  • kernel/generic/src/synch/rcu.c

    r6b99156 r205832b  
    237237#endif
    238238       
    239         rcu.detector_thr = 0;
     239        rcu.detector_thr = NULL;
    240240       
    241241        rcu.stat_expedited_cnt = 0;
     
    260260#endif
    261261       
    262         CPU->rcu.cur_cbs = 0;
     262        CPU->rcu.cur_cbs = NULL;
    263263        CPU->rcu.cur_cbs_cnt = 0;
    264         CPU->rcu.next_cbs = 0;
     264        CPU->rcu.next_cbs = NULL;
    265265        CPU->rcu.next_cbs_cnt = 0;
    266         CPU->rcu.arriving_cbs = 0;
     266        CPU->rcu.arriving_cbs = NULL;
    267267        CPU->rcu.parriving_cbs_tail = &CPU->rcu.arriving_cbs;
    268268        CPU->rcu.arriving_cbs_cnt = 0;
     
    275275        /* BSP creates reclaimer threads before AP's rcu_cpu_init() runs. */
    276276        if (config.cpu_active == 1)
    277                 CPU->rcu.reclaimer_thr = 0;
     277                CPU->rcu.reclaimer_thr = NULL;
    278278       
    279279        CPU->rcu.stat_max_cbs = 0;
     
    317317        /* Stop and wait for reclaimers. */
    318318        for (unsigned int cpu_id = 0; cpu_id < config.cpu_active; ++cpu_id) {
    319                 ASSERT(cpus[cpu_id].rcu.reclaimer_thr != 0);
     319                ASSERT(cpus[cpu_id].rcu.reclaimer_thr != NULL);
    320320       
    321321                if (cpus[cpu_id].rcu.reclaimer_thr) {
     
    323323                        thread_join(cpus[cpu_id].rcu.reclaimer_thr);
    324324                        thread_detach(cpus[cpu_id].rcu.reclaimer_thr);
    325                         cpus[cpu_id].rcu.reclaimer_thr = 0;
     325                        cpus[cpu_id].rcu.reclaimer_thr = NULL;
    326326                }
    327327        }
     
    333333                thread_join(rcu.detector_thr);
    334334                thread_detach(rcu.detector_thr);
    335                 rcu.detector_thr = 0;
     335                rcu.detector_thr = NULL;
    336336        }
    337337#endif
     
    357357               
    358358                cpus[cpu_id].rcu.reclaimer_thr =
    359                         thread_create(reclaimer, 0, TASK, THREAD_FLAG_NONE, name);
     359                        thread_create(reclaimer, NULL, TASK, THREAD_FLAG_NONE, name);
    360360
    361361                if (!cpus[cpu_id].rcu.reclaimer_thr)
     
    373373{
    374374        rcu.detector_thr =
    375                 thread_create(detector, 0, TASK, THREAD_FLAG_NONE, "rcu-det");
     375                thread_create(detector, NULL, TASK, THREAD_FLAG_NONE, "rcu-det");
    376376       
    377377        if (!rcu.detector_thr)
     
    410410                 * to finish.
    411411                 *
    412                  * Note that THREAD may be 0 in scheduler() and not just during boot.
     412                 * Note that THREAD may be NULL in scheduler() and not just during boot.
    413413                 */
    414414                if ((THREAD && THREAD->rcu.was_preempted) || CPU->rcu.is_delaying_gp) {
     
    522522       
    523523        cpu_mask_for_each(*cpu_mask, cpu_id) {
    524                 smp_call(cpu_id, add_barrier_cb, 0);
     524                smp_call(cpu_id, add_barrier_cb, NULL);
    525525        }
    526526       
     
    583583       
    584584        rcu_item->func = func;
    585         rcu_item->next = 0;
     585        rcu_item->next = NULL;
    586586       
    587587        preemption_disable();
     
    611611{
    612612        ASSERT(THREAD && THREAD->wired);
    613         return 0 == CPU->rcu.cur_cbs;
     613        return NULL == CPU->rcu.cur_cbs;
    614614}
    615615
     
    617617{
    618618        ASSERT(THREAD && THREAD->wired);
    619         return 0 == CPU->rcu.next_cbs;
     619        return NULL == CPU->rcu.next_cbs;
    620620}
    621621
     
    628628         * a false negative if we race with a local interrupt handler.
    629629         */
    630         return 0 == CPU->rcu.arriving_cbs;
     630        return NULL == CPU->rcu.arriving_cbs;
    631631}
    632632
     
    741741        }
    742742       
    743         *phead = 0;
     743        *phead = NULL;
    744744}
    745745
     
    779779        CPU->rcu.next_cbs_cnt = CPU->rcu.arriving_cbs_cnt;
    780780       
    781         CPU->rcu.arriving_cbs = 0;
     781        CPU->rcu.arriving_cbs = NULL;
    782782        CPU->rcu.parriving_cbs_tail = &CPU->rcu.arriving_cbs;
    783783        CPU->rcu.arriving_cbs_cnt = 0;
     
    12891289        atomic_set(&rcu.delaying_cpu_cnt, 0);
    12901290       
    1291         sample_cpus(cpu_mask, 0);
     1291        sample_cpus(cpu_mask, NULL);
    12921292}
    12931293
     
    14521452void rcu_thread_exiting(void)
    14531453{
    1454         ASSERT(THREAD != 0);
     1454        ASSERT(THREAD != NULL);
    14551455        ASSERT(THREAD->state == Exiting);
    14561456        ASSERT(PREEMPTION_DISABLED || interrupts_disabled());
  • kernel/test/cht/cht1.c

    r6b99156 r205832b  
    9797static const char * do_sanity_test(cht_t *h)
    9898{
    99         if (cht_find_lazy(h, 0))
     99        if (cht_find_lazy(h, (void*)0))
    100100                return "Found lazy in empty table.";
    101101       
    102         if (cht_find(h, 0))
     102        if (cht_find(h, (void*)0))
    103103                return "Found in empty table.";
    104104       
    105         if (cht_remove_key(h, 0))
     105        if (cht_remove_key(h, (void*)0))
    106106                return "Removed from empty table.";
    107107       
    108108        const int val_cnt = 6;
    109         val_t *v[6] = {0};
     109        val_t *v[6] = { NULL };
    110110       
    111111        for (int i = 0; i < val_cnt; ++i)
     
    145145       
    146146        if (cht_find(h, (void*)0))
    147                 return "Fantom find.";
     147                return "Phantom find.";
    148148       
    149149        cht_link_t *item = cht_find(h, (void*)v[5]->unique_id);
     
    226226        }
    227227
    228         return 0;
     228        return NULL;
    229229}
    230230
     
    559559                return "CHT stress test failed.";
    560560        else
    561                 return 0;
    562 }
     561                return NULL;
     562}
  • kernel/test/smpcall/smpcall1.c

    r6b99156 r205832b  
    8585        /* Number of received calls that were sent by cpu[i]. */
    8686        size_t call_cnt[MAX_CPUS] = {0};
    87         thread_t *thread[MAX_CPUS] = {0};
     87        thread_t *thread[MAX_CPUS] = { NULL };
    8888       
    8989        unsigned int cpu_count = min(config.cpu_active, MAX_CPUS);
  • kernel/test/synch/rcu1.c

    r6b99156 r205832b  
    4343
    4444static int one_idx = 0;
    45 static thread_t *thread[MAX_THREADS] = {0};
     45static thread_t *thread[MAX_THREADS] = { NULL };
    4646
    4747typedef struct {
     
    100100       
    101101        for (size_t i = 0; i < thread_cnt; ++i) {
    102                 run_thread(i, func, 0);
     102                run_thread(i, func, NULL);
    103103        }
    104104}
     
    123123                       
    124124                        thread_detach(thread[i]);
    125                         thread[i] = 0;
     125                        thread[i] = NULL;
    126126                }
    127127        }
     
    145145                thread_join(thread[one_idx]);
    146146                thread_detach(thread[one_idx]);
    147                 thread[one_idx] = 0;
     147                thread[one_idx] = NULL;
    148148        }
    149149}
     
    337337       
    338338        TPRINTF("\nRun a single reader that posts one callback.\n");
    339         run_one(one_cb_reader, 0);
     339        run_one(one_cb_reader, NULL);
    340340        join_one();
    341341       
     
    10151015                { 0, do_expedite, "do_expedite" },
    10161016                { 1, do_stress, "do_stress" },
    1017                 { 0, 0, 0 }
     1017                { 0, NULL, NULL }
    10181018        };
    10191019       
     
    10231023        uint64_t delta_gps = 0;
    10241024       
    1025         for (int i = 0; test_func[i].func != 0; ++i) {
     1025        for (int i = 0; test_func[i].func; ++i) {
    10261026                if (!test_func[i].include) {
    10271027                        TPRINTF("\nSubtest %s() skipped.\n", test_func[i].desc);
     
    10471047
    10481048        if (success)
    1049                 return 0;
     1049                return NULL;
    10501050        else
    10511051                return "One of the tests failed.";
  • kernel/test/synch/workqueue2.c

    r6b99156 r205832b  
    116116        test_custom_workq_impl(true, "test-workq-stop");
    117117        /* Errors are expected. */
    118         return 0;
     118        return NULL;
    119119}
    120120
     
    122122const char *test_workqueue_all(void)
    123123{
    124         const char *err = 0;
     124        const char *err = NULL;
    125125        const char *res;
    126126       
  • kernel/test/synch/workqueue3.c

    r6b99156 r205832b  
    5656static const char *do_test(bool exit_early)
    5757{
    58         const char *err = 0;
     58        const char *err = NULL;
    5959        TPRINTF("Stress testing system queue.\n");
    6060        TPRINTF("First run:\n");
  • uspace/lib/c/generic/adt/hash_table.c

    r6b99156 r205832b  
    112112        h->apply_ongoing = false;
    113113
    114         if (h->op->remove_callback == 0) {
     114        if (h->op->remove_callback == NULL) {
    115115                h->op->remove_callback = nop_remove_callback;
    116116        }
     
    133133        free(h->bucket);
    134134
    135         h->bucket = 0;
     135        h->bucket = NULL;
    136136        h->bucket_cnt = 0;
    137137}
Note: See TracChangeset for help on using the changeset viewer.