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

Re: [PATCH 2/2] xen/arm: gnttab: modify macros to evaluate all arguments and only once


  • To: Michal Orzel <michal.orzel@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 5 May 2022 13:20:13 +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=0mVTX3TkakSlTqqRukpP5/yEJBJhUFNk6zXYPPW9fKE=; b=Y+36MiB4u1aHNK9DezaJLJStXRqOn0WUWtPkDCDms5Ya5oJK3j1eBa+lQcYucq5mx4uZ+prQ71spfXP0o6dtzbNoPkke9j4lxgx4JiuFKWMe33AVg/SIKvWc5Xe0lavNWk91mreF2cP5w2wPz5+aCvVP8WJlbGDSPuENc0wWBoZNVMENjkqd3C8jh/E9K5pBHEzztmZ7Ee11D8W4Kjwq6WRYPOq+VbHiBYs1e7QJoOeaE4HZX0xzHpFtROgDIMgwYbojL2hYCmTUcOacT1OxRCAMBkTZtqBzTLZtSfLSd1arLD9BIDAHBMa8Oo2dEb35osGrzobxsRUXyWJ4ZLaKPw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PnC+eK0SLCMjMPWLs7PW8hRsag69oI12Yf0HzonGH1MA+bGqovQgopPZ1qXEx9i8mO2CDXxL8DeeSz939rfTOsSXRaeeLVKg1gE+NF/Y+CvGFQ7VvRNnVzYnNoXE5Py4+MY6FsW4J3LbNq0qqZHAcHsC+ZyOh1V8IdAj0exNBa6PF5jSxhQCslc/XNiOb+tF/FIEOgV5/okleRP6Tl4SmAI79FYXMOEhcJeVpTTsQfhWTk2uFvqVv2Ur2MlK1tIlrnbulEle9GoqZKkYJ2XJjcRWECfZfkpU4ZsBbNc7Zw9pPkDItiEtDaMljZ7d6Bjv/8JYOwPQ2xiOsBNLawJKYg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 05 May 2022 11:20:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 05.05.2022 12:36, Michal Orzel wrote:
> Modify macros to evaluate all the arguments and make sure the arguments
> are evaluated only once. While doing so, use typeof for basic types
> and use const qualifier when applicable.

Why only for basic types? To take an example, passing void * into
gnttab_need_iommu_mapping() would imo also better not work.

> @@ -98,13 +104,36 @@ int replace_grant_host_mapping(unsigned long gpaddr, 
> mfn_t mfn,
>  })
>  
>  #define gnttab_shared_gfn(d, t, i)                                       \
> -    (((i) >= nr_grant_frames(t)) ? INVALID_GFN : (t)->arch.shared_gfn[i])
> +    ({                                                                   \
> +        const struct domain *d_ = (d);                                   \
> +        const struct grant_table *t_ = (t);                              \
> +        const typeof(i) i_ = (i);                                        \
> +                                                                         \
> +        if ( d_ != NULL )                                                \
> +            ASSERT(d_->grant_table == t_);                               \

I'm puzzled by this NULL check (and the similar instance further down):
Are you suggesting NULL can legitimately come into here? If not, maybe
better ASSERT(d_ && d_->grant_table == t_)?

Jan




 


Rackspace

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