|
[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 Julien
> -----Original Message-----
> From: Minios-devel <minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf
> Of Julien Grall
> Sent: Monday, October 14, 2019 5:01 PM
> To: Justin He (Arm Technology China) <Justin.He@xxxxxxx>; minios-
> devel@xxxxxxxxxxxxxxxxxxxx; Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> Cc: Felipe Huici <felipe.huici@xxxxxxxxx>; Kaly Xin (Arm Technology China)
> <Kaly.Xin@xxxxxxx>; Sharan.Santhanam@xxxxxxxxx;
> Santiago.Pagani@xxxxxxxxx; nd <nd@xxxxxxx>; Costin Lupu
> <costin.lupu@xxxxxxxxx>
> Subject: Re: [Minios-devel] [UNIKRAFT PATCH v2 2/2] lib/uknetdev: Fix
> compliation warning about signed/unsigned comparision
>
> Hi,
>
> Title: s/compliation/compilation/
>
Okay
> 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?
It is a native compilation. This warnings occurred when I reviewed Felipe's WAMR
lib patches. As for your latter question, unikraft won't include any glibc
head files
(-nostdinc option)
>
> > 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?
The original code line:
(UINT16_MAX - headroom) > NETBUF_ADDR_ALIGNMENT
IIUC, UINT16_MAX is int, headroom is unsigned short (u16), and
NETBUF_ADDR_ALIGNMENT
is unsigned int (u32).
So headroom is promoted to int and the left of the equation is int, the right
is unsigned int.
--
Cheers,
Justin (Jia He)
>
> Cheers,
>
> --
> Julien Grall
>
>
>
>
> _______________________________________________
> 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 |