[haiku-development] Using B_USE_POSITIVE_POSIX_ERRORS in kernel space

  • From: Vivek Roy <vivekroyandroid@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 26 Jul 2017 19:52:18 +0530

Greetings,

I am trying to implement linux/scatterlist.h (scatter list gathers the
memory scattered physically across the memory ,but virtually contiguous
though. When communicating with DMA it provides an abstracted view of
memory to DMA as of this is memory contiguous physically).

I am using FreeBSD's implementation of scatterlist.h
<http://xref.plausible.coop/source/xref/freebsd-current/sys/compat/linuxkpi/common/include/linux/scatterlist.h>
With some changes they compile successfully except for one warning:

In function 'int __sg_alloc_table(sg_table*, unsigned int, unsigned int,
scatterlist*, gfp_t, scatterlist* (*)(unsigned int, gfp_t))':
warning: integer overflow in expression [-Woverflow]
#define B_NO_MEMORY     (B_GENERAL_ERROR_BASE + 0)

in expansion of macro 'B_NO_MEMORY'
 # define ENOMEM  B_NO_MEMORY
                  ^
in expansion of macro 'ENOMEM'
    return (-ENOMEM);

Thanks to korli, he told me about defining the B_USE_POSITIVE_POSIX_ERRORS
macro before compiling the code. But he also mentioned that it was meant to
be used in userland and to ask if it is okay to use it in kernel space as
well.

Thank You.

Vivek

Other related posts: