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


Ignore:
Location:
kernel
Files:
32 edited

Legend:

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

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

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

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

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

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

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

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

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

    r436a0a5 r88e43bc  
    6262}
    6363
    64 errno_t thread_create_arch(thread_t *t, thread_flags_t flags)
     64void thread_create_arch(thread_t *t)
    6565{
    66         if ((flags & THREAD_FLAG_USPACE) && (!t->arch.uspace_window_buffer)) {
     66        if ((t->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, FRAME_ATOMIC);
    72                 if (!t->arch.uspace_window_buffer)
    73                         return ENOMEM;
     71                t->arch.uspace_window_buffer = slab_alloc(uwb_cache, 0);
    7472        } else {
    7573                uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
     
    8280                    UWB_ALIGNMENT);
    8381        }
    84         return EOK;
    8582}
    8683
  • kernel/genarch/src/mm/asid_fifo.c

    r436a0a5 r88e43bc  
    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.
    7367#endif
    7468
  • kernel/genarch/src/ofw/ofw_tree.c

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

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

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

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

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

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

    r436a0a5 r88e43bc  
    219219        const char *hint;
    220220        const char *help;
     221        char *output = nfmalloc(MAX_CMDLINE);
    221222        size_t hints_to_show = MAX_TAB_HINTS - 1;
    222223        size_t total_hints_shown = 0;
    223224        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         }
    231225
    232226        output[0] = 0;
     
    331325}
    332326
    333 NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev,
    334     char *tmp)
     327NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev)
    335328{
    336329        printf("%s> ", prompt);
     
    339332        wchar_t *current = history[history_pos];
    340333        current[0] = 0;
     334        char *tmp = nfmalloc(STR_BOUNDS(MAX_CMDLINE));
    341335
    342336        while (true) {
     
    540534        }
    541535
     536        free(tmp);
    542537        return current;
    543538}
     
    814809                printf("Type \"exit\" to leave the console.\n");
    815810
    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 
     811        char *cmdline = nfmalloc(STR_BOUNDS(MAX_CMDLINE));
    826812        while (true) {
    827                 wchar_t *tmp = clever_readline((char *) prompt, stdin, buffer);
     813                wchar_t *tmp = clever_readline((char *) prompt, stdin);
    828814                size_t len = wstr_length(tmp);
    829815                if (!len)
     
    841827                (void) cmd_info->func(cmd_info->argv);
    842828        }
    843         free(buffer);
    844829        free(cmdline);
    845830}
  • kernel/generic/src/ipc/event.c

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

    r436a0a5 r88e43bc  
    108108 * TASK->answerbox.
    109109 *
    110  * @return Initialized kernel call structure with one reference, or NULL.
    111  *
    112  */
    113 call_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);
     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 */
     116call_t *ipc_call_alloc(unsigned int flags)
     117{
     118        call_t *call = slab_alloc(call_cache, flags);
    118119        if (!call)
    119120                return NULL;
    120121
    121         kobject_t *kobj = (kobject_t *) malloc(sizeof(kobject_t));
     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
    122128        if (!kobj) {
    123129                slab_free(call_cache, call);
     
    213219errno_t ipc_call_sync(phone_t *phone, call_t *request)
    214220{
    215         answerbox_t *mybox = slab_alloc(answerbox_cache, FRAME_ATOMIC);
    216         if (!mybox)
    217                 return ENOMEM;
    218 
     221        answerbox_t *mybox = slab_alloc(answerbox_cache, 0);
    219222        ipc_answerbox_init(mybox, TASK);
    220223
     
    480483                kobject_put(phone->kobject);
    481484
    482                 call_t *call = phone->hangup_call;
    483                 phone->hangup_call = NULL;
    484                 assert(call);
    485 
     485                call_t *call = ipc_call_alloc(0);
    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 = phone->hangup_call;
    688                         phone->hangup_call = NULL;
    689                         assert(call);
    690 
     687                        call_t *call = ipc_call_alloc(0);
    691688                        IPC_SET_IMETHOD(call->data, IPC_M_PHONE_HUNGUP);
    692689                        call->request_method = IPC_M_PHONE_HUNGUP;
  • kernel/generic/src/ipc/ipcrsc.c

    r436a0a5 r88e43bc  
    4646{
    4747        phone_t *phone = (phone_t *) arg;
    48         if (phone->hangup_call)
    49                 kobject_put(phone->hangup_call->kobject);
    5048        slab_free(phone_cache, phone);
    5149}
     
    8179                        return ENOMEM;
    8280                }
    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                 }
    9081
    9182                ipc_phone_init(phone, task);
    9283                phone->state = IPC_PHONE_CONNECTING;
    93                 phone->hangup_call = hcall;
    9484
    9585                kobject_initialize(kobj, KOBJECT_TYPE_PHONE, phone,
  • kernel/generic/src/ipc/irq.c

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

    r436a0a5 r88e43bc  
    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
    270269 *
    271270 */
     
    277276                return ENOENT;
    278277
    279         call_t *call = ipc_call_alloc();
    280         if (!call) {
    281                 kobject_put(kobj);
    282                 return ENOMEM;
    283         }
    284 
     278        call_t *call = ipc_call_alloc(0);
    285279        call->priv = priv;
    286280        memcpy(call->data.args, data->args, sizeof(data->args));
     
    379373        }
    380374
    381         call_t *call = ipc_call_alloc();
    382         if (!call) {
    383                 kobject_put(kobj);
    384                 return ENOMEM;
    385         }
    386 
     375        call_t *call = ipc_call_alloc(0);
    387376        IPC_SET_IMETHOD(call->data, imethod);
    388377        IPC_SET_ARG1(call->data, arg1);
     
    431420        }
    432421
    433         call_t *call = ipc_call_alloc();
    434         if (!call) {
    435                 kobject_put(kobj);
    436                 return ENOMEM;
    437         }
    438 
     422        call_t *call = ipc_call_alloc(0);
    439423        errno_t rc = copy_from_uspace(&call->data.args, &data->args,
    440424            sizeof(call->data.args));
  • kernel/generic/src/lib/str.c

    r436a0a5 r88e43bc  
    635635{
    636636        size_t size = str_size(src) + 1;
    637         char *dest = malloc(size);
    638         if (!dest)
    639                 return NULL;
     637        char *dest = nfmalloc(size);
     638        assert(dest);
    640639
    641640        str_cpy(dest, size, src);
     
    669668                size = n;
    670669
    671         char *dest = malloc(size + 1);
    672         if (!dest)
    673                 return NULL;
     670        char *dest = nfmalloc(size + 1);
     671        assert(dest);
    674672
    675673        str_ncpy(dest, size + 1, src, size);
  • kernel/generic/src/main/kinit.c

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

    r436a0a5 r88e43bc  
    151151as_t *as_create(unsigned int flags)
    152152{
    153         as_t *as = (as_t *) slab_alloc(as_cache, FRAME_ATOMIC);
    154         if (!as)
    155                 return NULL;
    156 
     153        as_t *as = (as_t *) slab_alloc(as_cache, 0);
    157154        (void) as_create_arch(as, 0);
    158155
     
    22402237 *
    22412238 */
    2242 as_area_info_t *as_get_area_info(as_t *as, size_t *osize)
     2239void as_get_area_info(as_t *as, as_area_info_t **obuf, size_t *osize)
    22432240{
    22442241        mutex_lock(&as->lock);
     
    22482245
    22492246        size_t isize = area_cnt * sizeof(as_area_info_t);
    2250         as_area_info_t *info = malloc(isize);
    2251         if (!info) {
    2252                 mutex_unlock(&as->lock);
    2253                 return NULL;
    2254         }
     2247        as_area_info_t *info = nfmalloc(isize);
    22552248
    22562249        /* Record area data. */
     
    22742267        mutex_unlock(&as->lock);
    22752268
     2269        *obuf = info;
    22762270        *osize = isize;
    2277         return info;
    22782271}
    22792272
  • kernel/generic/src/mm/slab.c

    r436a0a5 r88e43bc  
    667667    size_t (*destructor)(void *obj), unsigned int flags)
    668668{
    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 
     669        slab_cache_t *cache = slab_alloc(&slab_cache_cache, 0);
    673670        _slab_cache_create(cache, name, size, align, constructor, destructor,
    674671            flags);
     
    733730NO_TRACE static void _slab_free(slab_cache_t *cache, void *obj, slab_t *slab)
    734731{
    735         if (!obj)
    736                 return;
    737 
    738732        ipl_t ipl = interrupts_disable();
    739733
     
    960954}
    961955
    962 void *malloc(size_t size)
     956static void *_malloc(size_t size, unsigned int flags)
    963957{
    964958        assert(_slab_initialized);
     
    970964        uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
    971965
    972         return slab_alloc(malloc_caches[idx], FRAME_ATOMIC);
    973 }
    974 
    975 void *realloc(void *ptr, size_t size)
     966        return slab_alloc(malloc_caches[idx], flags);
     967}
     968
     969void *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 */
     977void *nfmalloc(size_t size)
     978{
     979        return _malloc(size, 0);
     980}
     981
     982static void *_realloc(void *ptr, size_t size, unsigned int flags)
    976983{
    977984        assert(_slab_initialized);
     
    985992                uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1;
    986993
    987                 new_ptr = slab_alloc(malloc_caches[idx], FRAME_ATOMIC);
     994                new_ptr = slab_alloc(malloc_caches[idx], flags);
    988995        } else
    989996                new_ptr = NULL;
     
    10001007}
    10011008
     1009void *realloc(void *ptr, size_t size)
     1010{
     1011        return _realloc(ptr, size, FRAME_ATOMIC);
     1012}
     1013
    10021014void free(void *ptr)
    10031015{
  • kernel/generic/src/proc/scheduler.c

    r436a0a5 r88e43bc  
    134134void scheduler_fpu_lazy_request(void)
    135135{
     136restart:
    136137        fpu_enable();
    137138        irq_spinlock_lock(&CPU->lock, false);
     
    152153                fpu_context_restore(THREAD->saved_fpu_context);
    153154        } 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                }
    154166                fpu_init();
    155167                THREAD->fpu_context_exists = true;
  • kernel/generic/src/proc/task.c

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

    r436a0a5 r88e43bc  
    165165
    166166#ifdef CONFIG_FPU
    167         thread->saved_fpu_context = slab_alloc(fpu_context_cache,
    168             FRAME_ATOMIC | kmflags);
     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);
    169171        if (!thread->saved_fpu_context)
    170172                return ENOMEM;
     173#endif /* CONFIG_FPU_LAZY */
    171174#endif /* CONFIG_FPU */
    172175
     
    197200        if (!stack_phys) {
    198201#ifdef CONFIG_FPU
    199                 assert(thread->saved_fpu_context);
    200                 slab_free(fpu_context_cache, thread->saved_fpu_context);
     202                if (thread->saved_fpu_context)
     203                        slab_free(fpu_context_cache, thread->saved_fpu_context);
    201204#endif
    202205                return ENOMEM;
     
    223226
    224227#ifdef CONFIG_FPU
    225         assert(thread->saved_fpu_context);
    226         slab_free(fpu_context_cache, thread->saved_fpu_context);
     228        if (thread->saved_fpu_context)
     229                slab_free(fpu_context_cache, thread->saved_fpu_context);
    227230#endif
    228231
     
    339342    thread_flags_t flags, const char *name)
    340343{
    341         thread_t *thread = (thread_t *) slab_alloc(thread_cache, FRAME_ATOMIC);
     344        thread_t *thread = (thread_t *) slab_alloc(thread_cache, 0);
    342345        if (!thread)
    343346                return NULL;
    344 
    345         if (thread_create_arch(thread, flags) != EOK) {
    346                 slab_free(thread_cache, thread);
    347                 return NULL;
    348         }
    349347
    350348        /* Not needed, but good for debugging */
     
    409407        udebug_thread_initialize(&thread->udebug);
    410408#endif
     409
     410        /* Might depend on previous initialization */
     411        thread_create_arch(thread);
    411412
    412413        if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH)
     
    653654
    654655        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.
    659656}
    660657
  • kernel/generic/src/sysinfo/sysinfo.c

    r436a0a5 r88e43bc  
    204204
    205205                *psubtree =
    206                     (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, FRAME_ATOMIC);
    207                 if (!*psubtree)
    208                         return NULL;
     206                    (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0);
     207                assert(*psubtree);
    209208
    210209                /* Fill in item name up to the delimiter */
    211210                (*psubtree)->name = str_ndup(name, i);
    212                 if (!(*psubtree)->name) {
    213                         slab_free(sysinfo_item_cache, *psubtree);
    214                         return NULL;
    215                 }
     211                assert((*psubtree)->name);
    216212
    217213                /* Create subtree items */
    218214                if (name[i] == '.') {
    219215                        (*psubtree)->subtree_type = SYSINFO_SUBTREE_TABLE;
    220                         sysinfo_item_t *item = sysinfo_create_path(name + i + 1,
     216                        return sysinfo_create_path(name + i + 1,
    221217                            &((*psubtree)->subtree.table));
    222                         if (!item) {
    223                                 free((*psubtree)->name);
    224                                 slab_free(sysinfo_item_cache, *psubtree);
    225                         }
    226                         return item;
    227218                }
    228219
     
    280271
    281272                        sysinfo_item_t *item =
    282                             (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, FRAME_ATOMIC);
    283                         if (!item)
    284                                 return NULL;
     273                            (sysinfo_item_t *) slab_alloc(sysinfo_item_cache, 0);
     274                        assert(item);
    285275
    286276                        cur->next = item;
     
    288278                        /* Fill in item name up to the delimiter */
    289279                        item->name = str_ndup(name, i);
    290                         if (!item->name) {
    291                                 slab_free(sysinfo_item_cache, item);
    292                                 return NULL;
    293                         }
     280                        assert(item->name);
    294281
    295282                        /* Create subtree items */
    296283                        if (name[i] == '.') {
    297284                                item->subtree_type = SYSINFO_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;
     285                                return sysinfo_create_path(name + i + 1,
     286                                    &(item->subtree.table));
    306287                        }
    307288
     
    337318                item->val_type = SYSINFO_VAL_VAL;
    338319                item->val.val = val;
    339         } else {
    340                 printf("Could not set sysinfo item %s.\n", name);
    341320        }
    342321
     
    371350                item->val.data.data = data;
    372351                item->val.data.size = size;
    373         } else {
    374                 printf("Could not set sysinfo item %s.\n", name);
    375352        }
    376353
     
    401378                item->val.gen_val.fn = fn;
    402379                item->val.gen_val.data = data;
    403         } else {
    404                 printf("Could not set sysinfo item %s.\n", name);
    405380        }
    406381
     
    436411                item->val.gen_data.fn = fn;
    437412                item->val.gen_data.data = data;
    438         } else {
    439                 printf("Could not set sysinfo item %s.\n", name);
    440413        }
    441414
     
    461434        if (item != NULL)
    462435                item->val_type = SYSINFO_VAL_UNDEFINED;
    463         else
    464                 printf("Could not set sysinfo item %s.\n", name);
    465436
    466437        mutex_unlock(&sysinfo_lock);
     
    495466                item->subtree.generator.fn = fn;
    496467                item->subtree.generator.data = data;
    497         } else {
    498                 printf("Could not set sysinfo item %s.\n", name);
    499468        }
    500469
     
    685654                return ret;
    686655
    687         // TODO: Change this so that allocation is not needed.
    688         char *path = malloc(size + 1);
    689         if (!path)
    690                 return ret;
     656        char *path = (char *) nfmalloc(size + 1);
     657        assert(path);
    691658
    692659        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
     
    796763                return ret;
    797764
    798         // TODO: Change this so that allocation is not needed.
    799         char *path = malloc(size + 1);
    800         if (!path)
    801                 return ret;
     765        char *path = (char *) nfmalloc(size + 1);
     766        assert(path);
    802767
    803768        if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
  • kernel/generic/src/udebug/udebug_ipc.c

    r436a0a5 r88e43bc  
    266266        size_t data_size;
    267267        size_t buf_size;
    268         as_area_info_t *data;
     268        void *data;
    269269
    270270        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     
    274274         * Read area list.
    275275         */
    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         }
     276        as_get_area_info(AS, (as_area_info_t **) &data, &data_size);
    282277
    283278        /* Copy MAX(buf_size, data_size) bytes */
     
    302297
    303298        IPC_SET_ARG3(call->data, data_size);
    304         call->buffer = (uint8_t *) data;
     299        call->buffer = data;
    305300
    306301        ipc_answer(&TASK->kb.box, call);
  • kernel/test/mm/slab1.c

    r436a0a5 r88e43bc  
    5050
    5151        for (i = 0; i < count; i++) {
    52                 data[i] = slab_alloc(cache, FRAME_ATOMIC);
    53                 if (data[i])
    54                         memsetb(data[i], size, 0);
     52                data[i] = slab_alloc(cache, 0);
     53                memsetb(data[i], size, 0);
    5554        }
    5655
     
    6766
    6867        for (i = 0; i < count; i++) {
    69                 data[i] = slab_alloc(cache, FRAME_ATOMIC);
    70                 if (data[i])
    71                         memsetb(data[i], size, 0);
     68                data[i] = slab_alloc(cache, 0);
     69                memsetb(data[i], size, 0);
    7270        }
    7371
     
    8482
    8583        for (i = count / 2; i < count; i++) {
    86                 data[i] = slab_alloc(cache, FRAME_ATOMIC);
    87                 if (data[i])
    88                         memsetb(data[i], size, 0);
     84                data[i] = slab_alloc(cache, 0);
     85                memsetb(data[i], size, 0);
    8986        }
    9087
     
    134131        for (j = 0; j < 10; j++) {
    135132                for (i = 0; i < THR_MEM_COUNT; i++)
    136                         thr_data[offs][i] = slab_alloc(thr_cache, FRAME_ATOMIC);
     133                        thr_data[offs][i] = slab_alloc(thr_cache, 0);
    137134                for (i = 0; i < THR_MEM_COUNT / 2; i++)
    138135                        slab_free(thr_cache, thr_data[offs][i]);
    139136                for (i = 0; i < THR_MEM_COUNT / 2; i++)
    140                         thr_data[offs][i] = slab_alloc(thr_cache, FRAME_ATOMIC);
     137                        thr_data[offs][i] = slab_alloc(thr_cache, 0);
    141138                for (i = 0; i < THR_MEM_COUNT; i++)
    142139                        slab_free(thr_cache, thr_data[offs][i]);
Note: See TracChangeset for help on using the changeset viewer.