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

Re: [XEN PATCH] xen/types: address Rule 10.1 for macro BITS_TO_LONGS


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 5 Sep 2023 09:46:41 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=arVjiqzRKuqF+U74p69xaqT0ApN91zlmkQkNxIWjppo=; b=X1ron+kZoN4zyyaJytoT+GiXPBBLewVO73r7bLGuRJAPJbx9+M/13R0LMqpTSI/ZxHhI0WXqajs+eHmaztTmJLbEqbPmA7puKyIaDNhYvx2drQyvUEE/6kFx//d+QDHIyBX4r5TVP67Z5U1qDxBu/EN9ERGAaDPe9CCt5QazhzMTBoccd8eU0PbJ68GrswR/5eIcFU2K9NiLCOoJ1amcyVg1R8nWRdrFPlK+Y5wnlVVud9w26yXWJ8n1uxI+n6z1TLrLbmnA7U39ESD9o35wVP8NCT/PYciocpxcsYyeTOg07giztxV3yNtAASPqfhZ8f5QbRiIBKxv/8pIVtW1/yA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Za0oOFaL2eWkz7nP+lOjH62gOPUyiDot1o8vtYwsa7TRaPNEGvryjNZAvC3/0AhlMxYqqbbdoXW6NKIz8C0tgvwDVEMjbjKZNYDyUFzNOOoriojuygfrXRKfzUD2Th8u3hdkAVS8EfmzbZZGZRuel2KGizSKAtY+OXrreS4UmoUSoFwsPlFUyM0S1R9p75Wj4BctVGhrgixqKABxuxdEk1RKV+5r52haDxy+fvLe9ZWbP9gZ088fIDpZ5ep2wDNWXLb2mS9QmNpY9pHwLOT4AD+VCcXVdtR8NA1s//+hPGoPNdNWwZ/KUQOzH7VUj2WILd8zd50ldBA+xx9tFAoLAw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 05 Sep 2023 07:46:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05.09.2023 09:31, Nicola Vetrini wrote:
> Given its use in the declaration
> 'DECLARE_BITMAP(features, IOMMU_FEAT_count)' the argument
> 'bits' has essential type 'enum iommu_feature', which is not
> allowed by the Rule as an operand to the addition operator.
> Given that its value can be represented by a signed integer,
> the explicit cast resolves the violation.

Wait - why would this lead to a change to BITS_TO_LONGS()? And if that
was to be changed, why plain int? I don't think negative input makes
sense there, and in principle I'd expect values beyond 4 billion to
also be permissible (even if likely no such use will ever appear in a
DECLARE_BITMAP(), but elsewhere it may make sense). Even going to
"unsigned long" may be too limiting ...

> --- a/xen/include/xen/types.h
> +++ b/xen/include/xen/types.h
> @@ -23,7 +23,7 @@ typedef signed long ssize_t;
>  typedef __PTRDIFF_TYPE__ ptrdiff_t;
>  
>  #define BITS_TO_LONGS(bits) \
> -    (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
> +    (((int)(bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
>  #define DECLARE_BITMAP(name,bits) \
>      unsigned long name[BITS_TO_LONGS(bits)]
>  

Furthermore, as always - if this was to be touched, please take care
of style violations (numerous missing blanks) at this occasion.

Jan



 


Rackspace

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