Changeset 8565a42 in mainline for kernel/generic/src/sysinfo


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
kernel/generic/src/sysinfo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/sysinfo/stats.c

    r3061bc1 r8565a42  
    9999        if (dry_run)
    100100                return NULL;
    101        
     101
    102102        /* Assumption: config.cpu_count is constant */
    103103        stats_cpu_t *stats_cpus = (stats_cpu_t *) malloc(*size, FRAME_ATOMIC);
     
    106106                return NULL;
    107107        }
    108        
     108
    109109        size_t i;
    110110        for (i = 0; i < config.cpu_count; i++) {
    111111                irq_spinlock_lock(&cpus[i].lock, true);
    112                
     112
    113113                stats_cpus[i].id = cpus[i].id;
    114114                stats_cpus[i].active = cpus[i].active;
     
    116116                stats_cpus[i].busy_cycles = cpus[i].busy_cycles;
    117117                stats_cpus[i].idle_cycles = cpus[i].idle_cycles;
    118                
     118
    119119                irq_spinlock_unlock(&cpus[i].lock, true);
    120120        }
    121        
     121
    122122        return ((void *) stats_cpus);
    123123}
     
    137137        size_t *count = (size_t *) arg;
    138138        (*count)++;
    139        
     139
    140140        return true;
    141141}
     
    156156         * object, return inexact statistics by skipping the respective object.
    157157         */
    158        
     158
    159159        if (mutex_trylock(&as->lock) != EOK)
    160160                return 0;
    161        
     161
    162162        size_t pages = 0;
    163        
     163
    164164        /* Walk the B+ tree and count pages */
    165165        list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
     
    168168                for (i = 0; i < node->keys; i++) {
    169169                        as_area_t *area = node->value[i];
    170                        
     170
    171171                        if (mutex_trylock(&area->lock) != EOK)
    172172                                continue;
    173                        
     173
    174174                        pages += area->pages;
    175175                        mutex_unlock(&area->lock);
    176176                }
    177177        }
    178        
     178
    179179        mutex_unlock(&as->lock);
    180        
     180
    181181        return (pages << PAGE_WIDTH);
    182182}
     
    197197         * object, return inexact statistics by skipping the respective object.
    198198         */
    199        
     199
    200200        if (mutex_trylock(&as->lock) != EOK)
    201201                return 0;
    202        
     202
    203203        size_t pages = 0;
    204        
     204
    205205        /* Walk the B+ tree and count pages */
    206206        list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t, node) {
     
    208208                for (i = 0; i < node->keys; i++) {
    209209                        as_area_t *area = node->value[i];
    210                        
     210
    211211                        if (mutex_trylock(&area->lock) != EOK)
    212212                                continue;
    213                        
     213
    214214                        pages += area->resident;
    215215                        mutex_unlock(&area->lock);
    216216                }
    217217        }
    218        
     218
    219219        mutex_unlock(&as->lock);
    220        
     220
    221221        return (pages << PAGE_WIDTH);
    222222}
     
    234234        assert(interrupts_disabled());
    235235        assert(irq_spinlock_locked(&task->lock));
    236        
     236
    237237        stats_task->task_id = task->taskid;
    238238        str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name);
     
    260260        stats_task_t **iterator = (stats_task_t **) arg;
    261261        task_t *task = avltree_get_instance(node, task_t, tasks_tree_node);
    262        
     262
    263263        /* Interrupts are already disabled */
    264264        irq_spinlock_lock(&(task->lock), false);
    265        
     265
    266266        /* Record the statistics and increment the iterator */
    267267        produce_stats_task(task, *iterator);
    268268        (*iterator)++;
    269        
     269
    270270        irq_spinlock_unlock(&(task->lock), false);
    271        
     271
    272272        return true;
    273273}
     
    289289        /* Messing with task structures, avoid deadlock */
    290290        irq_spinlock_lock(&tasks_lock, true);
    291        
     291
    292292        /* First walk the task tree to count the tasks */
    293293        size_t count = 0;
    294294        avltree_walk(&tasks_tree, avl_count_walker, (void *) &count);
    295        
     295
    296296        if (count == 0) {
    297297                /* No tasks found (strange) */
     
    300300                return NULL;
    301301        }
    302        
     302
    303303        *size = sizeof(stats_task_t) * count;
    304304        if (dry_run) {
     
    306306                return NULL;
    307307        }
    308        
     308
    309309        stats_task_t *stats_tasks = (stats_task_t *) malloc(*size, FRAME_ATOMIC);
    310310        if (stats_tasks == NULL) {
     
    314314                return NULL;
    315315        }
    316        
     316
    317317        /* Walk tha task tree again to gather the statistics */
    318318        stats_task_t *iterator = stats_tasks;
    319319        avltree_walk(&tasks_tree, task_serialize_walker, (void *) &iterator);
    320        
     320
    321321        irq_spinlock_unlock(&tasks_lock, true);
    322        
     322
    323323        return ((void *) stats_tasks);
    324324}
     
    336336        assert(interrupts_disabled());
    337337        assert(irq_spinlock_locked(&thread->lock));
    338        
     338
    339339        stats_thread->thread_id = thread->tid;
    340340        stats_thread->task_id = thread->task->taskid;
     
    343343        stats_thread->ucycles = thread->ucycles;
    344344        stats_thread->kcycles = thread->kcycles;
    345        
     345
    346346        if (thread->cpu != NULL) {
    347347                stats_thread->on_cpu = true;
     
    366366        stats_thread_t **iterator = (stats_thread_t **) arg;
    367367        thread_t *thread = avltree_get_instance(node, thread_t, threads_tree_node);
    368        
     368
    369369        /* Interrupts are already disabled */
    370370        irq_spinlock_lock(&thread->lock, false);
    371        
     371
    372372        /* Record the statistics and increment the iterator */
    373373        produce_stats_thread(thread, *iterator);
    374374        (*iterator)++;
    375        
     375
    376376        irq_spinlock_unlock(&thread->lock, false);
    377        
     377
    378378        return true;
    379379}
     
    395395        /* Messing with threads structures, avoid deadlock */
    396396        irq_spinlock_lock(&threads_lock, true);
    397        
     397
    398398        /* First walk the thread tree to count the threads */
    399399        size_t count = 0;
    400400        avltree_walk(&threads_tree, avl_count_walker, (void *) &count);
    401        
     401
    402402        if (count == 0) {
    403403                /* No threads found (strange) */
     
    406406                return NULL;
    407407        }
    408        
     408
    409409        *size = sizeof(stats_thread_t) * count;
    410410        if (dry_run) {
     
    412412                return NULL;
    413413        }
    414        
     414
    415415        stats_thread_t *stats_threads = (stats_thread_t *) malloc(*size, FRAME_ATOMIC);
    416416        if (stats_threads == NULL) {
     
    420420                return NULL;
    421421        }
    422        
     422
    423423        /* Walk tha thread tree again to gather the statistics */
    424424        stats_thread_t *iterator = stats_threads;
    425425        avltree_walk(&threads_tree, thread_serialize_walker, (void *) &iterator);
    426        
     426
    427427        irq_spinlock_unlock(&threads_lock, true);
    428        
     428
    429429        return ((void *) stats_threads);
    430430}
     
    454454        sysinfo_return_t ret;
    455455        ret.tag = SYSINFO_VAL_UNDEFINED;
    456        
     456
    457457        /* Parse the task ID */
    458458        task_id_t task_id;
    459459        if (str_uint64_t(name, NULL, 0, true, &task_id) != EOK)
    460460                return ret;
    461        
     461
    462462        /* Messing with task structures, avoid deadlock */
    463463        irq_spinlock_lock(&tasks_lock, true);
    464        
     464
    465465        task_t *task = task_find_by_id(task_id);
    466466        if (task == NULL) {
     
    469469                return ret;
    470470        }
    471        
     471
    472472        if (dry_run) {
    473473                ret.tag = SYSINFO_VAL_FUNCTION_DATA;
    474474                ret.data.data = NULL;
    475475                ret.data.size = sizeof(stats_task_t);
    476                
     476
    477477                irq_spinlock_unlock(&tasks_lock, true);
    478478        } else {
     
    484484                        return ret;
    485485                }
    486                
     486
    487487                /* Correct return value */
    488488                ret.tag = SYSINFO_VAL_FUNCTION_DATA;
    489489                ret.data.data = (void *) stats_task;
    490490                ret.data.size = sizeof(stats_task_t);
    491                
     491
    492492                /* Hand-over-hand locking */
    493493                irq_spinlock_exchange(&tasks_lock, &task->lock);
    494                
     494
    495495                produce_stats_task(task, stats_task);
    496                
     496
    497497                irq_spinlock_unlock(&task->lock, true);
    498498        }
    499        
     499
    500500        return ret;
    501501}
     
    525525        sysinfo_return_t ret;
    526526        ret.tag = SYSINFO_VAL_UNDEFINED;
    527        
     527
    528528        /* Parse the thread ID */
    529529        thread_id_t thread_id;
    530530        if (str_uint64_t(name, NULL, 0, true, &thread_id) != EOK)
    531531                return ret;
    532        
     532
    533533        /* Messing with threads structures, avoid deadlock */
    534534        irq_spinlock_lock(&threads_lock, true);
    535        
     535
    536536        thread_t *thread = thread_find_by_id(thread_id);
    537537        if (thread == NULL) {
     
    540540                return ret;
    541541        }
    542        
     542
    543543        if (dry_run) {
    544544                ret.tag = SYSINFO_VAL_FUNCTION_DATA;
    545545                ret.data.data = NULL;
    546546                ret.data.size = sizeof(stats_thread_t);
    547                
     547
    548548                irq_spinlock_unlock(&threads_lock, true);
    549549        } else {
     
    555555                        return ret;
    556556                }
    557                
     557
    558558                /* Correct return value */
    559559                ret.tag = SYSINFO_VAL_FUNCTION_DATA;
    560560                ret.data.data = (void *) stats_thread;
    561561                ret.data.size = sizeof(stats_thread_t);
    562                
     562
    563563                /* Hand-over-hand locking */
    564564                irq_spinlock_exchange(&threads_lock, &thread->lock);
    565                
     565
    566566                produce_stats_thread(thread, stats_thread);
    567                
     567
    568568                irq_spinlock_unlock(&thread->lock, true);
    569569        }
    570        
     570
    571571        return ret;
    572572}
     
    587587{
    588588        *size = sizeof(stats_exc_t) * IVT_ITEMS;
    589        
     589
    590590        if ((dry_run) || (IVT_ITEMS == 0))
    591591                return NULL;
    592        
     592
    593593        stats_exc_t *stats_exceptions =
    594594            (stats_exc_t *) malloc(*size, FRAME_ATOMIC);
     
    598598                return NULL;
    599599        }
    600        
     600
    601601#if (IVT_ITEMS > 0)
    602602        /* Messing with exception table, avoid deadlock */
    603603        irq_spinlock_lock(&exctbl_lock, true);
    604        
     604
    605605        unsigned int i;
    606606        for (i = 0; i < IVT_ITEMS; i++) {
     
    611611                stats_exceptions[i].count = exc_table[i].count;
    612612        }
    613        
     613
    614614        irq_spinlock_unlock(&exctbl_lock, true);
    615615#endif
    616        
     616
    617617        return ((void *) stats_exceptions);
    618618}
     
    642642        sysinfo_return_t ret;
    643643        ret.tag = SYSINFO_VAL_UNDEFINED;
    644        
     644
    645645        /* Parse the exception number */
    646646        uint64_t excn;
    647647        if (str_uint64_t(name, NULL, 0, true, &excn) != EOK)
    648648                return ret;
    649        
     649
    650650#if (IVT_FIRST > 0)
    651651        if (excn < IVT_FIRST)
    652652                return ret;
    653653#endif
    654        
     654
    655655#if (IVT_ITEMS + IVT_FIRST == 0)
    656656        return ret;
     
    659659                return ret;
    660660#endif
    661        
     661
    662662        if (dry_run) {
    663663                ret.tag = SYSINFO_VAL_FUNCTION_DATA;
     
    667667                /* Update excn index for accessing exc_table */
    668668                excn -= IVT_FIRST;
    669                
     669
    670670                /* Allocate stats_exc_t structure */
    671671                stats_exc_t *stats_exception =
     
    673673                if (stats_exception == NULL)
    674674                        return ret;
    675                
     675
    676676                /* Messing with exception table, avoid deadlock */
    677677                irq_spinlock_lock(&exctbl_lock, true);
    678                
     678
    679679                /* Correct return value */
    680680                ret.tag = SYSINFO_VAL_FUNCTION_DATA;
    681681                ret.data.data = (void *) stats_exception;
    682682                ret.data.size = sizeof(stats_exc_t);
    683                
     683
    684684                stats_exception->id = excn;
    685685                str_cpy(stats_exception->desc, EXC_NAME_BUFLEN, exc_table[excn].name);
     
    687687                stats_exception->cycles = exc_table[excn].cycles;
    688688                stats_exception->count = exc_table[excn].count;
    689                
     689
    690690                irq_spinlock_unlock(&exctbl_lock, true);
    691691        }
    692        
     692
    693693        return ret;
    694694}
     
    711711        if (dry_run)
    712712                return NULL;
    713        
     713
    714714        stats_physmem_t *stats_physmem =
    715715            (stats_physmem_t *) malloc(*size, FRAME_ATOMIC);
     
    718718                return NULL;
    719719        }
    720        
     720
    721721        zones_stats(&(stats_physmem->total), &(stats_physmem->unavail),
    722722            &(stats_physmem->used), &(stats_physmem->free));
    723        
     723
    724724        return ((void *) stats_physmem);
    725725}
     
    742742        if (dry_run)
    743743                return NULL;
    744        
     744
    745745        load_t *stats_load = (load_t *) malloc(*size, FRAME_ATOMIC);
    746746        if (stats_load == NULL) {
     
    748748                return NULL;
    749749        }
    750        
     750
    751751        /* To always get consistent values acquire the mutex */
    752752        mutex_lock(&load_lock);
    753        
     753
    754754        unsigned int i;
    755755        for (i = 0; i < LOAD_STEPS; i++)
    756756                stats_load[i] = avenrdy[i] << LOAD_KERNEL_SHIFT;
    757        
     757
    758758        mutex_unlock(&load_lock);
    759        
     759
    760760        return ((void *) stats_load);
    761761}
     
    768768        load *= exp;
    769769        load += (ready << LOAD_FIXED_SHIFT) * (LOAD_FIXED_1 - exp);
    770        
     770
    771771        return (load >> LOAD_FIXED_SHIFT);
    772772}
     
    782782{
    783783        thread_detach(THREAD);
    784        
     784
    785785        while (true) {
    786786                atomic_count_t ready = atomic_get(&nrdy);
    787                
     787
    788788                /* Mutually exclude with get_stats_load() */
    789789                mutex_lock(&load_lock);
    790                
     790
    791791                unsigned int i;
    792792                for (i = 0; i < LOAD_STEPS; i++)
    793793                        avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready);
    794                
     794
    795795                mutex_unlock(&load_lock);
    796                
     796
    797797                thread_sleep(LOAD_INTERVAL);
    798798        }
     
    805805{
    806806        mutex_initialize(&load_lock, MUTEX_PASSIVE);
    807        
     807
    808808        sysinfo_set_item_gen_data("system.cpus", NULL, get_stats_cpus, NULL);
    809809        sysinfo_set_item_gen_data("system.physmem", NULL, get_stats_physmem, NULL);
  • kernel/generic/src/sysinfo/sysinfo.c

    r3061bc1 r8565a42  
    6464{
    6565        sysinfo_item_t *item = (sysinfo_item_t *) obj;
    66        
     66
    6767        item->name = NULL;
    6868        item->val_type = SYSINFO_VAL_UNDEFINED;
     
    7070        item->subtree.table = NULL;
    7171        item->next = NULL;
    72        
     72
    7373        return EOK;
    7474}
     
    8484{
    8585        sysinfo_item_t *item = (sysinfo_item_t *) obj;
    86        
     86
    8787        if (item->name != NULL)
    8888                free(item->name);
    89        
     89
    9090        return 0;
    9191}
     
    101101            sizeof(sysinfo_item_t), 0, sysinfo_item_constructor,
    102102            sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED);
    103        
     103
    104104        mutex_initialize(&sysinfo_lock, MUTEX_ACTIVE);
    105105}
     
    127127{
    128128        assert(subtree != NULL);
    129        
     129
    130130        sysinfo_item_t *cur = subtree;
    131        
     131
    132132        /* Walk all siblings */
    133133        while (cur != NULL) {
    134134                size_t i = 0;
    135                
     135
    136136                /* Compare name with path */
    137137                while ((cur->name[i] != 0) && (name[i] == cur->name[i]))
    138138                        i++;
    139                
     139
    140140                /* Check for perfect name and path match */
    141141                if ((name[i] == 0) && (cur->name[i] == 0))
    142142                        return cur;
    143                
     143
    144144                /* Partial match up to the delimiter */
    145145                if ((name[i] == '.') && (cur->name[i] == 0)) {
     
    155155                                        **ret = cur->subtree.generator.fn(name + i + 1,
    156156                                            dry_run, cur->subtree.generator.data);
    157                                
     157
    158158                                return NULL;
    159159                        default:
     
    161161                                if (ret != NULL)
    162162                                        *ret = NULL;
    163                                
     163
    164164                                return NULL;
    165165                        }
    166166                }
    167                
     167
    168168                cur = cur->next;
    169169        }
    170        
     170
    171171        /* Not found, no data generated */
    172172        if (ret != NULL)
    173173                *ret = NULL;
    174        
     174
    175175        return NULL;
    176176}
     
    193193{
    194194        assert(psubtree != NULL);
    195        
     195
    196196        if (*psubtree == NULL) {
    197197                /* No parent */
    198                
     198
    199199                size_t i = 0;
    200                
     200
    201201                /* Find the first delimiter in name */
    202202                while ((name[i] != 0) && (name[i] != '.'))
    203203                        i++;
    204                
     204
    205205                *psubtree =
    206206                    (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0);
    207207                assert(*psubtree);
    208                
     208
    209209                /* Fill in item name up to the delimiter */
    210210                (*psubtree)->name = str_ndup(name, i);
    211211                assert((*psubtree)->name);
    212                
     212
    213213                /* Create subtree items */
    214214                if (name[i] == '.') {
     
    217217                            &((*psubtree)->subtree.table));
    218218                }
    219                
     219
    220220                /* No subtree needs to be created */
    221221                return *psubtree;
    222222        }
    223        
     223
    224224        sysinfo_item_t *cur = *psubtree;
    225        
     225
    226226        /* Walk all siblings */
    227227        while (cur != NULL) {
    228228                size_t i = 0;
    229                
     229
    230230                /* Compare name with path */
    231231                while ((cur->name[i] != 0) && (name[i] == cur->name[i]))
    232232                        i++;
    233                
     233
    234234                /* Check for perfect name and path match
    235235                 * -> item is already present.
     
    237237                if ((name[i] == 0) && (cur->name[i] == 0))
    238238                        return cur;
    239                
     239
    240240                /* Partial match up to the delimiter */
    241241                if ((name[i] == '.') && (cur->name[i] == 0)) {
     
    257257                        }
    258258                }
    259                
     259
    260260                /* No match and no more siblings to check
    261261                 * -> create a new sibling item.
     
    266266                        while ((name[i] != 0) && (name[i] != '.'))
    267267                                i++;
    268                        
     268
    269269                        sysinfo_item_t *item =
    270270                            (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0);
    271271                        assert(item);
    272                        
     272
    273273                        cur->next = item;
    274                        
     274
    275275                        /* Fill in item name up to the delimiter */
    276276                        item->name = str_ndup(name, i);
    277277                        assert(item->name);
    278                        
     278
    279279                        /* Create subtree items */
    280280                        if (name[i] == '.') {
     
    283283                                    &(item->subtree.table));
    284284                        }
    285                        
     285
    286286                        /* No subtree needs to be created */
    287287                        return item;
    288288                }
    289                
     289
    290290                cur = cur->next;
    291291        }
    292        
     292
    293293        /* Unreachable */
    294294        assert(false);
     
    309309        /* Protect sysinfo tree consistency */
    310310        mutex_lock(&sysinfo_lock);
    311        
     311
    312312        if (root == NULL)
    313313                root = &global_root;
    314        
     314
    315315        sysinfo_item_t *item = sysinfo_create_path(name, root);
    316316        if (item != NULL) {
     
    318318                item->val.val = val;
    319319        }
    320        
     320
    321321        mutex_unlock(&sysinfo_lock);
    322322}
     
    340340        /* Protect sysinfo tree consistency */
    341341        mutex_lock(&sysinfo_lock);
    342        
     342
    343343        if (root == NULL)
    344344                root = &global_root;
    345        
     345
    346346        sysinfo_item_t *item = sysinfo_create_path(name, root);
    347347        if (item != NULL) {
     
    350350                item->val.data.size = size;
    351351        }
    352        
     352
    353353        mutex_unlock(&sysinfo_lock);
    354354}
     
    368368        /* Protect sysinfo tree consistency */
    369369        mutex_lock(&sysinfo_lock);
    370        
     370
    371371        if (root == NULL)
    372372                root = &global_root;
    373        
     373
    374374        sysinfo_item_t *item = sysinfo_create_path(name, root);
    375375        if (item != NULL) {
     
    378378                item->val.gen_val.data = data;
    379379        }
    380        
     380
    381381        mutex_unlock(&sysinfo_lock);
    382382}
     
    401401        /* Protect sysinfo tree consistency */
    402402        mutex_lock(&sysinfo_lock);
    403        
     403
    404404        if (root == NULL)
    405405                root = &global_root;
    406        
     406
    407407        sysinfo_item_t *item = sysinfo_create_path(name, root);
    408408        if (item != NULL) {
     
    411411                item->val.gen_data.data = data;
    412412        }
    413        
     413
    414414        mutex_unlock(&sysinfo_lock);
    415415}
     
    426426        /* Protect sysinfo tree consistency */
    427427        mutex_lock(&sysinfo_lock);
    428        
     428
    429429        if (root == NULL)
    430430                root = &global_root;
    431        
     431
    432432        sysinfo_item_t *item = sysinfo_create_path(name, root);
    433433        if (item != NULL)
    434434                item->val_type = SYSINFO_VAL_UNDEFINED;
    435        
     435
    436436        mutex_unlock(&sysinfo_lock);
    437437}
     
    451451        /* Protect sysinfo tree consistency */
    452452        mutex_lock(&sysinfo_lock);
    453        
     453
    454454        if (root == NULL)
    455455                root = &global_root;
    456        
     456
    457457        sysinfo_item_t *item = sysinfo_create_path(name, root);
    458        
     458
    459459        /* Change the type of the subtree only if it is not already
    460460           a fixed subtree */
     
    464464                item->subtree.generator.data = data;
    465465        }
    466        
     466
    467467        mutex_unlock(&sysinfo_lock);
    468468}
     
    492492        for (sysinfo_item_t *cur = root; cur; cur = cur->next) {
    493493                size_t length;
    494                
     494
    495495                if (spaces == 0) {
    496496                        printf("%s", cur->name);
     
    501501                        length = str_length(cur->name) + 1;
    502502                }
    503                
     503
    504504                sysarg_t val;
    505505                size_t size;
    506                
     506
    507507                /* Display node value and type */
    508508                switch (cur->val_type) {
     
    531531                        printf("+ %s [unknown]\n", cur->name);
    532532                }
    533                
     533
    534534                /* Recursivelly nest into the subtree */
    535535                switch (cur->subtree_type) {
     
    562562           while we are dumping it */
    563563        mutex_lock(&sysinfo_lock);
    564        
     564
    565565        if (root == NULL)
    566566                sysinfo_dump_internal(global_root, 0);
    567567        else
    568568                sysinfo_dump_internal(root, 0);
    569        
     569
    570570        mutex_unlock(&sysinfo_lock);
    571571}
     
    590590        if (root == NULL)
    591591                root = &global_root;
    592        
     592
    593593        /* Try to find the item or generate data */
    594594        sysinfo_return_t ret;
     
    596596        sysinfo_item_t *item = sysinfo_find_item(name, *root, &ret_ptr,
    597597            dry_run);
    598        
     598
    599599        if (item != NULL) {
    600600                /* Item found in the fixed sysinfo tree */
    601                
     601
    602602                ret.tag = item->val_type;
    603603                switch (item->val_type) {
     
    625625                }
    626626        }
    627        
     627
    628628        return ret;
    629629}
     
    645645        sysinfo_return_t ret;
    646646        ret.tag = SYSINFO_VAL_UNDEFINED;
    647        
     647
    648648        if (size > SYSINFO_MAX_PATH)
    649649                return ret;
    650        
     650
    651651        char *path = (char *) malloc(size + 1, 0);
    652652        assert(path);
    653        
     653
    654654        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
    655655            (path[size] == 0)) {
     
    662662                mutex_unlock(&sysinfo_lock);
    663663        }
    664        
     664
    665665        free(path);
    666666        return ret;
     
    686686        if (root == NULL)
    687687                root = &global_root;
    688        
     688
    689689        sysinfo_item_t *subtree = NULL;
    690        
     690
    691691        if (name[0] != 0) {
    692692                /* Try to find the item */
     
    698698        } else
    699699                subtree = *root;
    700        
     700
    701701        sysinfo_return_t ret;
    702702        ret.tag = SYSINFO_VAL_UNDEFINED;
    703        
     703
    704704        if (subtree != NULL) {
    705705                /*
     
    709709                for (sysinfo_item_t *cur = subtree; cur; cur = cur->next)
    710710                        size += str_size(cur->name) + 1;
    711                
     711
    712712                if (dry_run) {
    713713                        ret.tag = SYSINFO_VAL_DATA;
     
    719719                        if (names == NULL)
    720720                                return ret;
    721                        
     721
    722722                        size_t pos = 0;
    723723                        for (sysinfo_item_t *cur = subtree; cur; cur = cur->next) {
     
    725725                                pos += str_size(cur->name) + 1;
    726726                        }
    727                        
     727
    728728                        /* Correct return value */
    729729                        ret.tag = SYSINFO_VAL_DATA;
     
    732732                }
    733733        }
    734        
     734
    735735        return ret;
    736736}
     
    754754        ret.data.data = NULL;
    755755        ret.data.size = 0;
    756        
     756
    757757        if (size > SYSINFO_MAX_PATH)
    758758                return ret;
    759        
     759
    760760        char *path = (char *) malloc(size + 1, 0);
    761761        assert(path);
    762        
     762
    763763        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
    764764            (path[size] == 0)) {
     
    771771                mutex_unlock(&sysinfo_lock);
    772772        }
    773        
     773
    774774        free(path);
    775775        return ret;
     
    794794{
    795795        errno_t rc;
    796        
     796
    797797        /*
    798798         * Get the keys.
     
    803803        sysinfo_return_t ret =
    804804            sysinfo_get_keys_uspace(path_ptr, path_size, true);
    805        
     805
    806806        /* Check return data tag */
    807807        if (ret.tag == SYSINFO_VAL_DATA)
     
    810810        else
    811811                rc = EINVAL;
    812        
     812
    813813        return (sys_errno_t) rc;
    814814}
     
    842842{
    843843        errno_t rc;
    844        
     844
    845845        /* Get the keys */
    846846        sysinfo_return_t ret = sysinfo_get_keys_uspace(path_ptr, path_size,
    847847            false);
    848        
     848
    849849        /* Check return data tag */
    850850        if (ret.tag == SYSINFO_VAL_DATA) {
     
    853853                if (rc == EOK)
    854854                        rc = copy_to_uspace(size_ptr, &size, sizeof(size));
    855                
     855
    856856                free(ret.data.data);
    857857        } else
    858858                rc = EINVAL;
    859        
     859
    860860        return (sys_errno_t) rc;
    861861}
     
    882882         */
    883883        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
    884        
     884
    885885        /*
    886886         * Map generated value types to constant types (user space does
     
    891891        else if (ret.tag == SYSINFO_VAL_FUNCTION_DATA)
    892892                ret.tag = SYSINFO_VAL_DATA;
    893        
     893
    894894        return (sysarg_t) ret.tag;
    895895}
     
    913913{
    914914        errno_t rc;
    915        
     915
    916916        /*
    917917         * Get the item.
     
    921921         */
    922922        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
    923        
     923
    924924        /* Only constant or generated numerical value is returned */
    925925        if ((ret.tag == SYSINFO_VAL_VAL) || (ret.tag == SYSINFO_VAL_FUNCTION_VAL))
     
    927927        else
    928928                rc = EINVAL;
    929        
     929
    930930        return (sys_errno_t) rc;
    931931}
     
    949949{
    950950        errno_t rc;
    951        
     951
    952952        /*
    953953         * Get the item.
     
    957957         */
    958958        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true);
    959        
     959
    960960        /* Only the size of constant or generated binary data is considered */
    961961        if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA))
     
    964964        else
    965965                rc = EINVAL;
    966        
     966
    967967        return (sys_errno_t) rc;
    968968}
     
    999999{
    10001000        errno_t rc;
    1001        
     1001
    10021002        /* Get the item */
    10031003        sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size,
    10041004            false);
    1005        
     1005
    10061006        /* Only constant or generated binary data is considered */
    10071007        if ((ret.tag == SYSINFO_VAL_DATA) ||
     
    10131013        } else
    10141014                rc = EINVAL;
    1015        
     1015
    10161016        /* N.B.: The generated binary data should be freed */
    10171017        if ((ret.tag == SYSINFO_VAL_FUNCTION_DATA) && (ret.data.data != NULL))
    10181018                free(ret.data.data);
    1019        
     1019
    10201020        return (sys_errno_t) rc;
    10211021}
Note: See TracChangeset for help on using the changeset viewer.