[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


  • To: Julien Grall <Julien.Grall@xxxxxxx>, "minios-devel@xxxxxxxxxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxxxxxxxxx>, Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
  • From: "Justin He (Arm Technology China)" <Justin.He@xxxxxxx>
  • Date: Tue, 22 Oct 2019 02:09:15 +0000
  • Accept-language: en-US, zh-CN
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WKC4uoi724ZHZ1TclhDPS3vCv5q5t8k6RWTYmGAWDbQ=; b=j7pUGAv9fzZeJMdm9gcItb1vuBEeA1ZM7egiXjkooLQXbntZscE18nQ76Vyvvj046SXoJJCfIC3Pp6V4a/CyXFPVd53tddzW6NOHgY0sj3E1MazMrp28UhffnmIL3krAdNTZjli0vG85Mr3PwTo/Vcn5hW8Qc/xCqx6HTg1aVfRhROXlpulMB5duHgsgcD6DY7yBHAzdO68jNNJQ3RawPx0WDi7rLAVBvU5bF/FNMT4tstvt1AzXHVwVcJBe+CjkeiZbREL98IXjk0L8fxiMvtwrY9oE5lewiesBLHgt+case604lkT4ySd/+ldIq0d7/ri6XyUI6OA9P6o0RGbtVA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g5kMORtZMxmt8bGsqnIqh71Snl02TRQ94xeTlpwboOcXpMH6MGQZjQNBasvJJt1IgDw/9FvQg8fBeUviK9grLu3ZZ+ZC8Dyqq5z+SiFcgOi5N6FC01IUUpQJTl5pwKdS5Wg/eAXRINfGYFxTfD5k0DytM0OqZ4HvTwoK308J23eWUs8CDdzBk3W0RjH3zJp/AXiScFghmHpIB4Yg04dIQ1uVxiHKGqEuxmTBMhlMSW6Cj486JwAH2p/JA3H/tmgdYkPEOarq/XfyUO1gRhYOGAC+QJeoVLRgSSQOgBzTa/nkz/hzCxo6UX0WJK/oFTSfi6mIVzwmu5DrM5bUUvOJFA==
  • Authentication-results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Authentication-results-original: spf=none (sender IP is ) smtp.mailfrom=Justin.He@xxxxxxx;
  • Cc: Felipe Huici <felipe.huici@xxxxxxxxx>, "Kaly Xin \(Arm Technology China\)" <Kaly.Xin@xxxxxxx>, "Sharan.Santhanam@xxxxxxxxx" <Sharan.Santhanam@xxxxxxxxx>, "Santiago.Pagani@xxxxxxxxx" <Santiago.Pagani@xxxxxxxxx>, nd <nd@xxxxxxx>, Costin Lupu <costin.lupu@xxxxxxxxx>
  • Delivery-date: Tue, 22 Oct 2019 02:09:32 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Nodisclaimer: True
  • Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Justin.He@xxxxxxx;
  • Thread-index: AQHVgMfMHVGjWlPiuUy/uZqXFQVa4qdZ2h0AgAwcdSA=
  • Thread-topic: [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

 


Rackspace

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