[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH] lib/uksched, plat/*: Fix error handling with uk_posix_memalign()
Hi Simon, looks good, thanks. -- Felipe Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx> On Sat, Feb 8, 2020 at 11:43 AM Simon Kuenzer <simon.kuenzer@xxxxxxxxx> wrote: > > In the cases of failed allocation, `uk_posix_memalign()` is returning > an errno number but does not change `memptr`. Instead of checking > `memptr` being NULL, we test failures with `uk_posix_memalign()`'s > return codes. > > Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx> > --- > lib/uksched/sched.c | 6 +++--- > plat/drivers/virtio/virtio_ring.c | 4 ++-- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lib/uksched/sched.c b/lib/uksched/sched.c > index 5903fe5a..ef195c3a 100644 > --- a/lib/uksched/sched.c > +++ b/lib/uksched/sched.c > @@ -141,8 +141,8 @@ static void *create_stack(struct uk_alloc *allocator) > { > void *stack; > > - uk_posix_memalign(allocator, &stack, STACK_SIZE, STACK_SIZE); > - if (stack == NULL) { > + if (uk_posix_memalign(allocator, &stack, > + STACK_SIZE, STACK_SIZE) != 0) { > uk_pr_err("Failed to allocate thread stack\n"); > return NULL; > } > @@ -155,7 +155,7 @@ static void *uk_thread_tls_create(struct uk_alloc > *allocator) > void *tls; > > if (uk_posix_memalign(allocator, &tls, ukarch_tls_area_align(), > - ukarch_tls_area_size())) { > + ukarch_tls_area_size()) != 0) { > uk_pr_err("Failed to allocate thread TLS area\n"); > return NULL; > } > diff --git a/plat/drivers/virtio/virtio_ring.c > b/plat/drivers/virtio/virtio_ring.c > index a310a431..235679d2 100644 > --- a/plat/drivers/virtio/virtio_ring.c > +++ b/plat/drivers/virtio/virtio_ring.c > @@ -379,8 +379,8 @@ struct virtqueue *virtqueue_create(__u16 queue_id, __u16 > nr_descs, __u16 align, > vrq->vring_mem = NULL; > > ring_size = vring_size(nr_descs, align); > - uk_posix_memalign(a, (void **)&vrq->vring_mem, __PAGE_SIZE, > ring_size); > - if (!vrq->vring_mem) { > + if (uk_posix_memalign(a, &vrq->vring_mem, > + __PAGE_SIZE, ring_size) != 0) { > uk_pr_err("Allocation of vring failed\n"); > rc = -ENOMEM; > goto err_freevq; > -- > 2.20.1 > > > _______________________________________________ > Minios-devel mailing list > Minios-devel@xxxxxxxxxxxxxxxxxxxx > https://lists.xenproject.org/mailman/listinfo/minios-devel _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |