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

Re: [PATCH v4 1/5] tools: add container_of() macro to xen-tools/common-macros.h


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 22 Mar 2023 13:34:04 +0100
  • 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=7xb2+udRRmcim7KeNpZkI03CkyRqCmZeN5dvuzaIoPE=; b=HDfbkU1y85J/yZ+V9Q8CQa3mxdvcsRPenPnw6rlV+jzRwJlrE8+umzeBF4fOzBO7eghNoneJu2/btaqJHI7p0kWtCSHF+yUelGgaG7zGhKTKEzHqg8jDYKNY3UmHND/m0dZblZsrbOD2kzzjQLVegVpECisy/D7uBbtzF9fsBVygZo4vkmBSWarmDj+v/SfgShu790Kauu1wmXAsphPaA2jTrhYfjBOuxDUjpyQ1OVsjZ1Jj67pOQZsJvfL2D2Balbe3FvCfCwVrGTjrUrH/M96s6NI1p0LYDM7LuMmaRrkmpv/Dq1bbCKr/6ZmNmGA+IrnlYz/8T+kTxy6LetTUug==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwFQIVwCzrhY/ZARy4I/YE8M3Npf5KAVUMnXz5Z9OgWMOI3JJOYa+q3yGpZZhspDlWbrF1KnWmeVa+rTen0umW2AqBu9JzyjHMM7JqGirBHIRwzKndFvkT89I2ZOIiaU9q8llXRW7YzSWsRPLqm3BEunZAbkIzJ6ZL+8mqSLHZJ/9i/+c09mGEWE9TM3J6psjXclf44/siNBnnbiCSEg6ilbz35LYrMbCwR9gl6wx0T7mk5E9r440rBMMUUTcxiLBhSPzkKRCO16GAHrrtSbIHtOaw8J0ZOKlPSFW8M9fRvCn7JjqT3LRYJoF4z+vYcFkfHmCQGfl/lABep6uxX6uQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 22 Mar 2023 12:34:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.03.2023 13:08, Juergen Gross wrote:
> --- a/tools/include/xen-tools/common-macros.h
> +++ b/tools/include/xen-tools/common-macros.h
> @@ -76,4 +76,8 @@
>  #define __must_check __attribute__((__warn_unused_result__))
>  #endif
>  
> +#define container_of(ptr, type, member) ({                \
> +    typeof( ((type *)0)->member ) *__mptr = (ptr);        \
> +    (type *)( (char *)__mptr - offsetof(type,member) );})

Can the variant used here please be closer to ...

> --- a/tools/tests/x86_emulator/x86-emulate.h
> +++ b/tools/tests/x86_emulator/x86-emulate.h
> @@ -56,11 +56,6 @@
>  
>  #define cf_check /* No Control Flow Integriy checking */
>  
> -#define container_of(ptr, type, member) ({             \
> -    typeof(((type *)0)->member) *mptr__ = (ptr);       \
> -    (type *)((char *)mptr__ - offsetof(type, member)); \
> -})

... this rather than ...

> --- a/tools/xenstore/list.h
> +++ b/tools/xenstore/list.h
> @@ -3,6 +3,8 @@
>  /* Taken from Linux kernel code, but de-kernelized for userspace. */
>  #include <stddef.h>
>  
> +#include <xen-tools/common-macros.h>
> +
>  #undef LIST_HEAD_INIT
>  #undef LIST_HEAD
>  #undef INIT_LIST_HEAD
> @@ -15,10 +17,6 @@
>  #define LIST_POISON1  ((void *) 0x00100100)
>  #define LIST_POISON2  ((void *) 0x00200200)
>  
> -#define container_of(ptr, type, member) ({                   \
> -        typeof( ((type *)0)->member ) *__mptr = (ptr);       \
> -        (type *)( (char *)__mptr - offsetof(type,member) );})

... this, both formatting-wise (excess blanks) and local-variable-
naming-wise (trailing underscores instead of leading ones)? (If I was
the one to commit this, I'd be happy to make the adjustment at that
time.) Then
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>

Jan



 


Rackspace

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