Changes in / [88e43bc:436a0a5] in mainline


Ignore:
Location:
kernel
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/src/proc/thread.c

    r88e43bc r436a0a5  
    3535#include <proc/thread.h>
    3636
    37 void thread_create_arch(thread_t *t)
     37errno_t thread_create_arch(thread_t *t, thread_flags_t flags)
    3838{
     39        return EOK;
    3940}
    4041
  • kernel/arch/amd64/src/proc/thread.c

    r88e43bc r436a0a5  
    4242 *
    4343 */
    44 void thread_create_arch(thread_t *thread)
     44errno_t thread_create_arch(thread_t *thread, thread_flags_t flags)
    4545{
    4646        /*
     
    4949        thread->arch.kstack_rsp =
    5050            (uintptr_t) &thread->kstack[PAGE_SIZE - sizeof(istate_t)];
     51        return EOK;
    5152}
    5253
  • kernel/arch/arm32/include/arch/proc/thread.h

    r88e43bc r436a0a5  
    4242#define thr_constructor_arch(t)
    4343#define thr_destructor_arch(t)
    44 #define thread_create_arch(t)
     44#define thread_create_arch(t, flags) (EOK)
    4545
    4646#endif
  • kernel/arch/ia32/src/proc/thread.c

    r88e43bc r436a0a5  
    3939 * @param t Thread to be initialized.
    4040 */
    41 void thread_create_arch(thread_t *t)
     41errno_t thread_create_arch(thread_t *t, thread_flags_t flags)
    4242{
     43        return EOK;
    4344}
    4445
  • kernel/arch/ia64/include/arch/proc/thread.h

    r88e43bc r436a0a5  
    4141#define thr_constructor_arch(t)
    4242#define thr_destructor_arch(t)
    43 #define thread_create_arch(t)
     43#define thread_create_arch(t, flags) (EOK)
    4444
    4545#endif
  • kernel/arch/mips32/include/arch/proc/thread.h

    r88e43bc r436a0a5  
    4141#define thr_constructor_arch(t)
    4242#define thr_destructor_arch(t)
    43 #define thread_create_arch(t)
     43#define thread_create_arch(t, flags) (EOK)
    4444
    4545#endif
  • kernel/arch/ppc32/include/arch/proc/thread.h

    r88e43bc r436a0a5  
    4141#define thr_constructor_arch(t)
    4242#define thr_destructor_arch(t)
    43 #define thread_create_arch(t)
     43#define thread_create_arch(t, flags) (EOK)
    4444
    4545#endif
  • kernel/arch/riscv64/src/proc/thread.c

    r88e43bc r436a0a5  
    3535#include <proc/thread.h>
    3636
    37 void thread_create_arch(thread_t *t)
     37errno_t thread_create_arch(thread_t *t, thread_flags_t flags)
    3838{
     39        return EOK;
    3940}
    4041
  • kernel/arch/sparc64/src/proc/thread.c

    r88e43bc r436a0a5  
    6262}
    6363
    64 void thread_create_arch(thread_t *t)
     64errno_t thread_create_arch(thread_t *t, thread_flags_t flags)
    6565{
    66         if ((t->uspace) && (!t->arch.uspace_window_buffer)) {
     66        if ((flags & THREAD_FLAG_USPACE) && (!t->arch.uspace_window_buffer)) {
    6767                /*
    6868                 * The thread needs userspace window buffer and the object
    6969                 * returned from the slab allocator doesn't have any.
    7070                 */
    71                 t->arch.uspace_window_buffer = slab_alloc(uwb_cache, 0);
     71                t->arch.uspace_window_buffer = slab_alloc(uwb_cache, FRAME_ATOMIC);
     72                if (!t->arch.uspace_window_buffer)
     73                        return ENOMEM;
    7274        } else {
    7375                uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
     
    8082                    UWB_ALIGNMENT);
    8183        }
     84        return EOK;
    8285}
    8386
  • kernel/genarch/src/mm/asid_fifo.c

    r88e43bc r436a0a5  
    6565#if (!FIFO_STATIC)
    6666        fifo_create(free_asids);
     67        if (!free_asids.fifo)
     68                panic("Not enough memory to allocate ASID FIFO");
     69        // TODO: There really is no reason not to statically allocate it
     70        //       except to keep binary size low. Once kernel is a regular ELF
     71        //       binary supporting .bss section (wip as of the late 2018),
     72        //       the dynamic option should be removed.
    6773#endif
    6874
  • kernel/genarch/src/ofw/ofw_tree.c

    r88e43bc r436a0a5  
    386386static void ofw_tree_node_sysinfo(ofw_tree_node_t *node, const char *path)
    387387{
    388         char *cur_path = (char *) nfmalloc(PATH_MAX_LEN);
     388        char *cur_path = malloc(PATH_MAX_LEN);
     389        if (!cur_path)
     390                panic("Not enough memory to process OFW tree.");
    389391
    390392        for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) {
  • kernel/generic/include/adt/fifo.h

    r88e43bc r436a0a5  
    115115 */
    116116#define fifo_create(name) \
    117         name.fifo = nfmalloc(sizeof(*name.fifo) * name.items)
     117        name.fifo = malloc(sizeof(*name.fifo) * name.items)
    118118
    119119#endif
  • kernel/generic/include/ipc/ipc.h

    r88e43bc r436a0a5  
    4747struct answerbox;
    4848struct task;
     49struct call;
    4950
    5051typedef enum {
     
    6768        struct task *caller;
    6869        struct answerbox *callee;
     70        /* A call prepared for hangup ahead of time, so that it cannot fail. */
     71        struct call *hangup_call;
    6972        ipc_phone_state_t state;
    7073        atomic_t active_calls;
     
    171174extern void ipc_init(void);
    172175
    173 extern call_t *ipc_call_alloc(unsigned int);
    174 extern void ipc_call_free(call_t *);
    175 extern void ipc_call_hold(call_t *);
    176 extern void ipc_call_release(call_t *);
     176extern call_t *ipc_call_alloc(void);
    177177
    178178extern errno_t ipc_call_sync(phone_t *, call_t *);
  • kernel/generic/include/mm/as.h

    r88e43bc r436a0a5  
    325325
    326326/* Introspection functions. */
    327 extern void as_get_area_info(as_t *, as_area_info_t **, size_t *);
     327extern as_area_info_t *as_get_area_info(as_t *, size_t *);
    328328extern void as_print(as_t *);
    329329
  • kernel/generic/include/mm/slab.h

    r88e43bc r436a0a5  
    146146extern void free(void *);
    147147
    148 extern void *nfmalloc(size_t)
    149     __attribute__((malloc, returns_nonnull));
    150 
    151148#endif
    152149
  • kernel/generic/include/proc/thread.h

    r88e43bc r436a0a5  
    225225
    226226#ifndef thread_create_arch
    227 extern void thread_create_arch(thread_t *);
     227extern errno_t thread_create_arch(thread_t *, thread_flags_t);
    228228#endif
    229229
  • kernel/generic/src/console/kconsole.c

    r88e43bc r436a0a5  
    219219        const char *hint;
    220220        const char *help;
    221         char *output = nfmalloc(MAX_CMDLINE);
    222221        size_t hints_to_show = MAX_TAB_HINTS - 1;
    223222        size_t total_hints_shown = 0;
    224223        bool continue_showing_hints = true;
     224
     225        char *output = malloc(MAX_CMDLINE);
     226        if (!output) {
     227                // TODO: fix the function so that it does not need allocation
     228                printf("Can't complete command, out of memory.\n");
     229                return 0;
     230        }
    225231
    226232        output[0] = 0;
     
    325331}
    326332
    327 NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev)
     333NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev,
     334    char *tmp)
    328335{
    329336        printf("%s> ", prompt);
     
    332339        wchar_t *current = history[history_pos];
    333340        current[0] = 0;
    334         char *tmp = nfmalloc(STR_BOUNDS(MAX_CMDLINE));
    335341
    336342        while (true) {
     
    534540        }
    535541
    536         free(tmp);
    537542        return current;
    538543}
     
    809814                printf("Type \"exit\" to leave the console.\n");
    810815
    811         char *cmdline = nfmalloc(STR_BOUNDS(MAX_CMDLINE));
     816        char *buffer = malloc(STR_BOUNDS(MAX_CMDLINE));
     817        char *cmdline = malloc(STR_BOUNDS(MAX_CMDLINE));
     818        if (!buffer || !cmdline) {
     819                // TODO: fix the function so that it does not need allocations
     820                printf("Can't start console, out of memory.\n");
     821                free(buffer);
     822                free(cmdline);
     823                return;
     824        }
     825
    812826        while (true) {
    813                 wchar_t *tmp = clever_readline((char *) prompt, stdin);
     827                wchar_t *tmp = clever_readline((char *) prompt, stdin, buffer);
    814828                size_t len = wstr_length(tmp);
    815829                if (!len)
     
    827841                (void) cmd_info->func(cmd_info->argv);
    828842        }
     843        free(buffer);
    829844        free(cmdline);
    830845}
  • kernel/generic/src/ipc/event.c

    r88e43bc r436a0a5  
    147147        if (event->answerbox != NULL) {
    148148                if (!event->masked) {
    149                         call_t *call = ipc_call_alloc(FRAME_ATOMIC);
     149                        call_t *call = ipc_call_alloc();
    150150
    151151                        if (call) {
  • kernel/generic/src/ipc/ipc.c

    r88e43bc r436a0a5  
    108108 * TASK->answerbox.
    109109 *
    110  * @param flags Parameters for slab_alloc (e.g FRAME_ATOMIC).
    111  *
    112  * @return If flags permit it, return NULL, or initialized kernel
    113  *         call structure with one reference.
    114  *
    115  */
    116 call_t *ipc_call_alloc(unsigned int flags)
    117 {
    118         call_t *call = slab_alloc(call_cache, flags);
     110 * @return Initialized kernel call structure with one reference, or NULL.
     111 *
     112 */
     113call_t *ipc_call_alloc(void)
     114{
     115        // TODO: Allocate call and kobject in single allocation
     116
     117        call_t *call = slab_alloc(call_cache, FRAME_ATOMIC);
    119118        if (!call)
    120119                return NULL;
    121120
    122         kobject_t *kobj;
    123         if (flags & FRAME_ATOMIC)
    124                 kobj = (kobject_t *) malloc(sizeof(kobject_t));
    125         else
    126                 kobj = (kobject_t *) nfmalloc(sizeof(kobject_t));
    127 
     121        kobject_t *kobj = (kobject_t *) malloc(sizeof(kobject_t));
    128122        if (!kobj) {
    129123                slab_free(call_cache, call);
     
    219213errno_t ipc_call_sync(phone_t *phone, call_t *request)
    220214{
    221         answerbox_t *mybox = slab_alloc(answerbox_cache, 0);
     215        answerbox_t *mybox = slab_alloc(answerbox_cache, FRAME_ATOMIC);
     216        if (!mybox)
     217                return ENOMEM;
     218
    222219        ipc_answerbox_init(mybox, TASK);
    223220
     
    483480                kobject_put(phone->kobject);
    484481
    485                 call_t *call = ipc_call_alloc(0);
     482                call_t *call = phone->hangup_call;
     483                phone->hangup_call = NULL;
     484                assert(call);
     485
    486486                IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
    487487                call->request_method = IPC_M_PHONE_HUNGUP;
     
    685685                         * to exist as soon as we release it.
    686686                         */
    687                         call_t *call = ipc_call_alloc(0);
     687                        call_t *call = phone->hangup_call;
     688                        phone->hangup_call = NULL;
     689                        assert(call);
     690
    688691                        IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
    689692                        call->request_method = IPC_M_PHONE_HUNGUP;
  • kernel/generic/src/ipc/ipcrsc.c

    r88e43bc r436a0a5  
    4646{
    4747        phone_t *phone = (phone_t *) arg;
     48        if (phone->hangup_call)
     49                kobject_put(phone->hangup_call->kobject);
    4850        slab_free(phone_cache, phone);
    4951}
     
    7981                        return ENOMEM;
    8082                }
     83                call_t *hcall = ipc_call_alloc();
     84                if (!hcall) {
     85                        cap_free(TASK, handle);
     86                        slab_free(phone_cache, phone);
     87                        free(kobj);
     88                        return ENOMEM;
     89                }
    8190
    8291                ipc_phone_init(phone, task);
    8392                phone->state = IPC_PHONE_CONNECTING;
     93                phone->hangup_call = hcall;
    8494
    8595                kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone,
  • kernel/generic/src/ipc/irq.c

    r88e43bc r436a0a5  
    529529
    530530        if (irq->notif_cfg.answerbox) {
    531                 call_t *call = ipc_call_alloc(FRAME_ATOMIC);
     531                call_t *call = ipc_call_alloc();
    532532                if (!call)
    533533                        return;
     
    565565
    566566        if (irq->notif_cfg.answerbox) {
    567                 call_t *call = ipc_call_alloc(FRAME_ATOMIC);
     567                call_t *call = ipc_call_alloc();
    568568                if (!call) {
    569569                        irq_spinlock_unlock(&irq->lock, true);
  • kernel/generic/src/ipc/sysipc.c

    r88e43bc r436a0a5  
    267267 * @return EOK on success.
    268268 * @return ENOENT if there is no such phone handle.
     269 * @return ENOMEM if not enough memory to make the call
    269270 *
    270271 */
     
    276277                return ENOENT;
    277278
    278         call_t *call = ipc_call_alloc(0);
     279        call_t *call = ipc_call_alloc();
     280        if (!call) {
     281                kobject_put(kobj);
     282                return ENOMEM;
     283        }
     284
    279285        call->priv = priv;
    280286        memcpy(call->data.args, data->args, sizeof(data->args));
     
    373379        }
    374380
    375         call_t *call = ipc_call_alloc(0);
     381        call_t *call = ipc_call_alloc();
     382        if (!call) {
     383                kobject_put(kobj);
     384                return ENOMEM;
     385        }
     386
    376387        IPC_SET_IMETHOD(call->data, imethod);
    377388        IPC_SET_ARG1(call->data, arg1);
     
    420431        }
    421432
    422         call_t *call = ipc_call_alloc(0);
     433        call_t *call = ipc_call_alloc();
     434        if (!call) {
     435                kobject_put(kobj);
     436                return ENOMEM;
     437        }
     438
    423439        errno_t rc = copy_from_uspace(&call->data.args, &data->args,
    424440            sizeof(call->data.args));
  • kernel/generic/src/lib/str.c

    r88e43bc r436a0a5  
    635635{
    636636        size_t size = str_size(src) + 1;
    637         char *dest = nfmalloc(size);
    638         assert(dest);
     637        char *dest = malloc(size);
     638        if (!dest)
     639                return NULL;
    639640
    640641        str_cpy(dest, size, src);
     
    668669                size = n;
    669670
    670         char *dest = nfmalloc(size + 1);
    671         assert(dest);
     671        char *dest = malloc(size + 1);
     672        if (!dest)
     673                return NULL;
    672674
    673675        str_ncpy(dest, size + 1, src, size);
  • kernel/generic/src/main/kinit.c

    r88e43bc r436a0a5  
    120120                thread = thread_create(kmp, NULL, TASK,
    121121                    THREAD_FLAG_UNCOUNTED, "kmp");
    122                 if (thread != NULL) {
    123                         thread_wire(thread, &cpus[0]);
    124                         thread_ready(thread);
    125                 } else
     122                if (!thread)
    126123                        panic("Unable to create kmp thread.");
    127124
     125                thread_wire(thread, &cpus[0]);
     126                thread_ready(thread);
    128127                thread_join(thread);
    129128                thread_detach(thread);
  • kernel/generic/src/mm/as.c

    r88e43bc r436a0a5  
    151151as_t *as_create(unsigned int flags)
    152152{
    153         as_t *as = (as_t *) slab_alloc(as_cache, 0);
     153        as_t *as = (as_t *) slab_alloc(as_cache, FRAME_ATOMIC);
     154        if (!as)
     155                return NULL;
     156
    154157        (void) as_create_arch(as, 0);
    155158
     
    22372240 *
    22382241 */
    2239 void as_get_area_info(as_t *as, as_area_info_t **obuf, size_t *osize)
     2242as_area_info_t *as_get_area_info(as_t *as, size_t *osize)
    22402243{
    22412244        mutex_lock(&as->lock);
     
    22452248
    22462249        size_t isize = area_cnt * sizeof(as_area_info_t);
    2247         as_area_info_t *info = nfmalloc(isize);
     2250        as_area_info_t *info = malloc(isize);
     2251        if (!info) {
     2252                mutex_unlock(&as->lock);
     2253                return NULL;
     2254        }
    22482255
    22492256        /* Record area data. */
     
    22672274        mutex_unlock(&as->lock);
    22682275
    2269         *obuf = info;
    22702276        *osize = isize;
     2277        return info;
    22712278}
    22722279
  • kernel/generic/src/mm/slab.c

    r88e43bc r436a0a5  
    667667    size_t (*destructor)(void *obj), unsigned int flags)
    668668{
    669         slab_cache_t *cache = slab_alloc(&slab_cache_cache, 0);
     669        slab_cache_t *cache = slab_alloc(&slab_cache_cache, FRAME_ATOMIC);
     670        if (!cache)
     671                panic("Not enough memory to allocate slab cache %s.", name);
     672
    670673        _slab_cache_create(cache, name, size, align, constructor, destructor,
    671674            flags);
     
    730733NO_TRACE static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab)
    731734{
     735        if (!obj)
     736                return;
     737
    732738        ipl_t ipl = interrupts_disable();
    733739
     
    954960}
    955961
    956 static void *_malloc(size_t size, unsigned int flags)
     962void *malloc(size_t size)
    957963{
    958964        assert(_slab_initialized);
     
    964970        uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
    965971
    966         return slab_alloc(malloc_caches[idx], flags);
    967 }
    968 
    969 void *malloc(size_t size)
    970 {
    971         return _malloc(size, FRAME_ATOMIC);
    972 }
    973 
    974 /** Non-failing malloc.
    975  *  Never returns NULL, but may block forever if no memory is available.
    976  */
    977 void *nfmalloc(size_t size)
    978 {
    979         return _malloc(size, 0);
    980 }
    981 
    982 static void *_realloc(void *ptr, size_t size, unsigned int flags)
     972        return slab_alloc(malloc_caches[idx], FRAME_ATOMIC);
     973}
     974
     975void *realloc(void *ptr, size_t size)
    983976{
    984977        assert(_slab_initialized);
     
    992985                uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
    993986
    994                 new_ptr = slab_alloc(malloc_caches[idx], flags);
     987                new_ptr = slab_alloc(malloc_caches[idx], FRAME_ATOMIC);
    995988        } else
    996989                new_ptr = NULL;
     
    10071000}
    10081001
    1009 void *realloc(void *ptr, size_t size)
    1010 {
    1011         return _realloc(ptr, size, FRAME_ATOMIC);
    1012 }
    1013 
    10141002void free(void *ptr)
    10151003{
  • kernel/generic/src/proc/scheduler.c

    r88e43bc r436a0a5  
    134134void scheduler_fpu_lazy_request(void)
    135135{
    136 restart:
    137136        fpu_enable();
    138137        irq_spinlock_lock(&CPU->lock, false);
     
    153152                fpu_context_restore(THREAD->saved_fpu_context);
    154153        } else {
    155                 /* Allocate FPU context */
    156                 if (!THREAD->saved_fpu_context) {
    157                         /* Might sleep */
    158                         irq_spinlock_unlock(&THREAD->lock, false);
    159                         irq_spinlock_unlock(&CPU->lock, false);
    160                         THREAD->saved_fpu_context =
    161                             (fpu_context_t *) slab_alloc(fpu_context_cache, 0);
    162 
    163                         /* We may have switched CPUs during slab_alloc */
    164                         goto restart;
    165                 }
    166154                fpu_init();
    167155                THREAD->fpu_context_exists = true;
  • kernel/generic/src/proc/task.c

    r88e43bc r436a0a5  
    199199task_t *task_create(as_t *as, const char *name)
    200200{
    201         task_t *task = (task_t *) slab_alloc(task_cache, 0);
    202         if (task == NULL) {
     201        task_t *task = (task_t *) slab_alloc(task_cache, FRAME_ATOMIC);
     202        if (!task)
    203203                return NULL;
    204         }
    205204
    206205        task_create_arch(task);
  • kernel/generic/src/proc/thread.c

    r88e43bc r436a0a5  
    165165
    166166#ifdef CONFIG_FPU
    167 #ifdef CONFIG_FPU_LAZY
    168         thread->saved_fpu_context = NULL;
    169 #else /* CONFIG_FPU_LAZY */
    170         thread->saved_fpu_context = slab_alloc(fpu_context_cache, kmflags);
     167        thread->saved_fpu_context = slab_alloc(fpu_context_cache,
     168            FRAME_ATOMIC | kmflags);
    171169        if (!thread->saved_fpu_context)
    172170                return ENOMEM;
    173 #endif /* CONFIG_FPU_LAZY */
    174171#endif /* CONFIG_FPU */
    175172
     
    200197        if (!stack_phys) {
    201198#ifdef CONFIG_FPU
    202                 if (thread->saved_fpu_context)
    203                         slab_free(fpu_context_cache, thread->saved_fpu_context);
     199                assert(thread->saved_fpu_context);
     200                slab_free(fpu_context_cache, thread->saved_fpu_context);
    204201#endif
    205202                return ENOMEM;
     
    226223
    227224#ifdef CONFIG_FPU
    228         if (thread->saved_fpu_context)
    229                 slab_free(fpu_context_cache, thread->saved_fpu_context);
     225        assert(thread->saved_fpu_context);
     226        slab_free(fpu_context_cache, thread->saved_fpu_context);
    230227#endif
    231228
     
    342339    thread_flags_t flags, const char *name)
    343340{
    344         thread_t *thread = (thread_t *) slab_alloc(thread_cache, 0);
     341        thread_t *thread = (thread_t *) slab_alloc(thread_cache, FRAME_ATOMIC);
    345342        if (!thread)
    346343                return NULL;
     344
     345        if (thread_create_arch(thread, flags) != EOK) {
     346                slab_free(thread_cache, thread);
     347                return NULL;
     348        }
    347349
    348350        /* Not needed, but good for debugging */
     
    407409        udebug_thread_initialize(&thread->udebug);
    408410#endif
    409 
    410         /* Might depend on previous initialization */
    411         thread_create_arch(thread);
    412411
    413412        if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH)
     
    654653
    655654        return waitq_sleep_timeout(&thread->join_wq, usec, flags, NULL);
     655
     656        // FIXME: join should deallocate the thread.
     657        //        Current code calls detach after join, that's contrary to how
     658        //        join is used in other threading APIs.
    656659}
    657660
  • kernel/generic/src/sysinfo/sysinfo.c

    r88e43bc r436a0a5  
    204204
    205205                *psubtree =
    206                     (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0);
    207                 assert(*psubtree);
     206                    (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, FRAME_ATOMIC);
     207                if (!*psubtree)
     208                        return NULL;
    208209
    209210                /* Fill in item name up to the delimiter */
    210211                (*psubtree)->name = str_ndup(name, i);
    211                 assert((*psubtree)->name);
     212                if (!(*psubtree)->name) {
     213                        slab_free(sysinfo_item_cache, *psubtree);
     214                        return NULL;
     215                }
    212216
    213217                /* Create subtree items */
    214218                if (name[i] == '.') {
    215219                        (*psubtree)->subtree_type = SYSINFO_SUBTREE_TABLE;
    216                         return sysinfo_create_path(name + i + 1,
     220                        sysinfo_item_t *item = sysinfo_create_path(name + i + 1,
    217221                            &((*psubtree)->subtree.table));
     222                        if (!item) {
     223                                free((*psubtree)->name);
     224                                slab_free(sysinfo_item_cache, *psubtree);
     225                        }
     226                        return item;
    218227                }
    219228
     
    271280
    272281                        sysinfo_item_t *item =
    273                             (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0);
    274                         assert(item);
     282                            (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, FRAME_ATOMIC);
     283                        if (!item)
     284                                return NULL;
    275285
    276286                        cur->next = item;
     
    278288                        /* Fill in item name up to the delimiter */
    279289                        item->name = str_ndup(name, i);
    280                         assert(item->name);
     290                        if (!item->name) {
     291                                slab_free(sysinfo_item_cache, item);
     292                                return NULL;
     293                        }
    281294
    282295                        /* Create subtree items */
    283296                        if (name[i] == '.') {
    284297                                item->subtree_type = SYSINFO_SUBTREE_TABLE;
    285                                 return sysinfo_create_path(name + i + 1,
    286                                     &(item->subtree.table));
     298                                sysinfo_item_t *sub = sysinfo_create_path(
     299                                    name + i + 1, &(item->subtree.table));
     300                                if (!sub) {
     301                                        free(item->name);
     302                                        slab_free(sysinfo_item_cache, item);
     303                                        return NULL;
     304                                }
     305                                return sub;
    287306                        }
    288307
     
    318337                item->val_type = SYSINFO_VAL_VAL;
    319338                item->val.val = val;
     339        } else {
     340                printf("Could not set sysinfo item %s.\n", name);
    320341        }
    321342
     
    350371                item->val.data.data = data;
    351372                item->val.data.size = size;
     373        } else {
     374                printf("Could not set sysinfo item %s.\n", name);
    352375        }
    353376
     
    378401                item->val.gen_val.fn = fn;
    379402                item->val.gen_val.data = data;
     403        } else {
     404                printf("Could not set sysinfo item %s.\n", name);
    380405        }
    381406
     
    411436                item->val.gen_data.fn = fn;
    412437                item->val.gen_data.data = data;
     438        } else {
     439                printf("Could not set sysinfo item %s.\n", name);
    413440        }
    414441
     
    434461        if (item != NULL)
    435462                item->val_type = SYSINFO_VAL_UNDEFINED;
     463        else
     464                printf("Could not set sysinfo item %s.\n", name);
    436465
    437466        mutex_unlock(&sysinfo_lock);
     
    466495                item->subtree.generator.fn = fn;
    467496                item->subtree.generator.data = data;
     497        } else {
     498                printf("Could not set sysinfo item %s.\n", name);
    468499        }
    469500
     
    654685                return ret;
    655686
    656         char *path = (char *) nfmalloc(size + 1);
    657         assert(path);
     687        // TODO: Change this so that allocation is not needed.
     688        char *path = malloc(size + 1);
     689        if (!path)
     690                return ret;
    658691
    659692        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
     
    763796                return ret;
    764797
    765         char *path = (char *) nfmalloc(size + 1);
    766         assert(path);
     798        // TODO: Change this so that allocation is not needed.
     799        char *path = malloc(size + 1);
     800        if (!path)
     801                return ret;
    767802
    768803        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
  • kernel/generic/src/udebug/udebug_ipc.c

    r88e43bc r436a0a5  
    266266        size_t data_size;
    267267        size_t buf_size;
    268         void *data;
     268        as_area_info_t *data;
    269269
    270270        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     
    274274         * Read area list.
    275275         */
    276         as_get_area_info(AS, (as_area_info_t **) &data, &data_size);
     276        data = as_get_area_info(AS, &data_size);
     277        if (!data) {
     278                IPC_SET_RETVAL(call->data, ENOMEM);
     279                ipc_answer(&TASK->kb.box, call);
     280                return;
     281        }
    277282
    278283        /* Copy MAX(buf_size, data_size) bytes */
     
    297302
    298303        IPC_SET_ARG3(call->data, data_size);
    299         call->buffer = data;
     304        call->buffer = (uint8_t *) data;
    300305
    301306        ipc_answer(&TASK->kb.box, call);
  • kernel/test/mm/slab1.c

    r88e43bc r436a0a5  
    5050
    5151        for (i = 0; i < count; i++) {
    52                 data[i] = slab_alloc(cache, 0);
    53                 memsetb(data[i], size, 0);
     52                data[i] = slab_alloc(cache, FRAME_ATOMIC);
     53                if (data[i])
     54                        memsetb(data[i], size, 0);
    5455        }
    5556
     
    6667
    6768        for (i = 0; i < count; i++) {
    68                 data[i] = slab_alloc(cache, 0);
    69                 memsetb(data[i], size, 0);
     69                data[i] = slab_alloc(cache, FRAME_ATOMIC);
     70                if (data[i])
     71                        memsetb(data[i], size, 0);
    7072        }
    7173
     
    8284
    8385        for (i = count / 2; i < count; i++) {
    84                 data[i] = slab_alloc(cache, 0);
    85                 memsetb(data[i], size, 0);
     86                data[i] = slab_alloc(cache, FRAME_ATOMIC);
     87                if (data[i])
     88                        memsetb(data[i], size, 0);
    8689        }
    8790
     
    131134        for (j = 0; j < 10; j++) {
    132135                for (i = 0; i < THR_MEM_COUNT; i++)
    133                         thr_data[offs][i] = slab_alloc(thr_cache, 0);
     136                        thr_data[offs][i] = slab_alloc(thr_cache, FRAME_ATOMIC);
    134137                for (i = 0; i < THR_MEM_COUNT / 2; i++)
    135138                        slab_free(thr_cache, thr_data[offs][i]);
    136139                for (i = 0; i < THR_MEM_COUNT / 2; i++)
    137                         thr_data[offs][i] = slab_alloc(thr_cache, 0);
     140                        thr_data[offs][i] = slab_alloc(thr_cache, FRAME_ATOMIC);
    138141                for (i = 0; i < THR_MEM_COUNT; i++)
    139142                        slab_free(thr_cache, thr_data[offs][i]);
Note: See TracChangeset for help on using the changeset viewer.