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

Re: [Minios-devel] [UNIKRAFT PATCH 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>, Costin Lupu <costin.lupu@xxxxxxxxx>
  • From: "Justin He (Arm Technology China)" <Justin.He@xxxxxxx>
  • Date: Fri, 11 Oct 2019 15:13:54 +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=UdV5BoHDA48cSqLCkuT7MwwBc2BpaZyoDZ/XhVWKd+I=; b=TIWSc+xbPccOtKyFgJPqWdW7waNXWKpUcp2OnHAQ9P/dJr+PWQbTSHXlS2kpsRdFF7vjZu4yr01448MkwK2MDl/UxEGm8ytciQZVteKJ+8rWRkKgqYIOKUhKhiZ6GmQ7N5qxpFuBFd676TYr0UNR5KcmgHCL43XOErq5wW718cQd2DHJqyPlxD1EQO+ozR8wRhf6Fmuyoscn/kZIWsM4T1ND5Kme5Quy7SPOHn4sZjp1qsMnzDkPadZ5TZLPO09/lBboX//Bt8gxwxHx9oIV9zz4lx4CLeDIypqIWLDDK86LArDJ4gN+2rdl5ZehScayZQmcYPMT0cf1MqtcTxlO0A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P39PQ7oxk1iHGTXy+RP2WkpIjzOHT199vY7nQg73XB6GOjY2EgpKLEskLEpWTgzIUwJu3UAT0f2M7cRSCYAkYEiAST+srsRMUG3Ehw41pksirQmhISEGvBAs3zGC+QGg31DXzBwfQXbczPrVyov+iSHlQfjf+46wkb2Q4JOp8nh3LvvmZsxJcxxcRcIGgELAHq/Ee5FoKo9F55TJsXk43cCduiRDQaWeZUZLs6UoVN7O1W0n3FSGsyxe9TtJCsszjuCFhPOWKDF8LobpwOEa/y7OS1xtaF0MhBj9Rv17z/T2wHJhM09gtge3cUBew+S8QkPKuYqmxUAx+IZqQJ6OEw==
  • 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>, nd <nd@xxxxxxx>, "Sharan.Santhanam@xxxxxxxxx" <Sharan.Santhanam@xxxxxxxxx>, "Santiago.Pagani@xxxxxxxxx" <Santiago.Pagani@xxxxxxxxx>
  • Delivery-date: Fri, 11 Oct 2019 15:14:17 +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: AQHVgBFYpW1AePeHFEOmdJIaWmit1qdVJFAAgABnTnA=
  • Thread-topic: [UNIKRAFT PATCH 2/2] lib/uknetdev: Fix compliation warning about signed/unsigned comparision

Hi Julien

> -----Original Message-----
> From: Julien Grall <julien.grall@xxxxxxx>
> Sent: Friday, October 11, 2019 5:00 PM
> To: Justin He (Arm Technology China) <Justin.He@xxxxxxx>; minios-
> devel@xxxxxxxxxxxxxxxxxxxx; Simon Kuenzer <simon.kuenzer@xxxxxxxxx>;
> Costin Lupu <costin.lupu@xxxxxxxxx>
> Cc: Sharan.Santhanam@xxxxxxxxx; Felipe Huici <felipe.huici@xxxxxxxxx>;
> Kaly Xin (Arm Technology China) <Kaly.Xin@xxxxxxx>;
> Santiago.Pagani@xxxxxxxxx; nd <nd@xxxxxxx>
> Subject: Re: [UNIKRAFT PATCH 2/2] lib/uknetdev: Fix compliation warning
> about signed/unsigned comparision
> 
> Hi,
> 
> On 11/10/2019 09:52, Jia He wrote:
> > This fixes the compliation warning when compiling libuknetdev
> 
> Typo s/compliation/compilation/
> 
> >
> > /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))
> >                                             ^
> > Signed-off-by: Jia He <justin.he@xxxxxxx>
> > ---
> >   lib/uknetdev/netbuf.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/uknetdev/netbuf.c b/lib/uknetdev/netbuf.c
> > index 96a5f68..108bd36 100644
> > --- a/lib/uknetdev/netbuf.c
> > +++ b/lib/uknetdev/netbuf.c
> > @@ -36,7 +36,7 @@
> >   #include <uk/print.h>
> >
> >   /* Used to align netbuf's priv and data areas to `long long` data type */
> > -#define NETBUF_ADDR_ALIGNMENT (sizeof(long long))
> > +#define NETBUF_ADDR_ALIGNMENT (int)(sizeof(long long))
> 
> Maybe I am missing something but:
> 
> UINT16_MAX - headrom should be unsigned, right?
> 
> IIRC, sizeof() is also returning an unsigned. So how this is solving the
> problem
> here?
Because UINT16_MAX and headroom are both unsigned short,
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.


--
Cheers,
Justin (Jia He)


_______________________________________________
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®.