[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v2 2/2] lib/uknetdev: Fix compliation warning about signed/unsigned comparision



Hi,

Title: s/compliation/compilation/

On 12/10/2019 07:39, Jia He wrote:
This fixes the compilation warning when compiling libuknetdev

/root/hj/UK/unikraft/lib/uknetdev/netbuf.c: In function
'uk_netbuf_alloc_buf':
/root/hj/UK/unikraft/lib/uknetdev/netbuf.c:120:35: warning: comparison
between signed and unsigned integer expressions [-Wsign-compare]
   if (likely(UINT16_MAX - headroom > NETBUF_ADDR_ALIGNMENT)) {
                                    ^
/root/hj/UK/unikraft/include/uk/arch/lcpu.h:48:43: note: in definition
of macro 'likely'
  #define likely(x)   (__builtin_expect((!!(x)), 1))
                                            ^

The UINT16_MAX is 0xffff (signed int) on my X86 host (gcc version 7.4.0).

I am a bit confused, is this cross-compilation or native compilation? I guess the later as you mention x86 host. So I guess you are referring to /usr/include/stdint.h, right?

Integer types smaller than int are promoted when an operation is performed
on them. Thus, the left side of equation is "int", and the right side is
size_t.

I am not sure to understand this. Above you say UINT16_MAX is signed int (aka int), so why do you speak about promotion to int here?

Cheers,

--
Julien Grall




_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.