[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] Arm32: tidy the memset() macro
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Fri, 19 Aug 2022 09:50:21 +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=bflGzSbGwtVrTpLswCHuwtkvvy0efCiqZEXeFBXqy0E=; b=kVY3FQs8KXWB/lgbjdkR8FMrNbxHUX/GqBaSa2/+i+4aEwcq0evnv6jj7i7gN5Ugd+BkaPGftKl+VtzfPKjx/QACfW5bjc9FVNC6CmfNpA/alyuCEw4r22TZDFy/R+Wcet5GQv/WPj2kqf2ircPxwPeNlvvr6BU4k+yjs/nO/L/Rz46SJkdxGJctKRkGaq4AMCiTVauMio5VSO/rzSOq8Obnp5Z53qm66GYQVqdsjRTgsHaSVwn0ahmPX0SHVNcfD7lqnZL/ZyR2/YNXPu/cx7ePAyAOzaRfTnh86Xbf+RspuFoQrOykIcMI6m7B3PAURjkJyYbpM4H9Friy3ErkIg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B46+e6JIEynXpj2p6Bbt4Dy3Fx34r9h/JKIBe7czepM3fBPBow76H0Y0DAQyNr3snu0c9e1VfqkIHrVcx85OD8Bp7iM9Uwbp4S54ssWUJ+xqzryBJieultmZ1QgZoGgk8CZJMOIb8MSnerCmID/m1ggNWAPcgsEdyKFdCSFSXc4+O8vEIx2A1/cjlZtL0G80a3BuWVKRRILXCg4lY4fIf4fb5+CQPLQXsixSfiaYnO4Dtg1ksD0k44tSpdYXQjZvR922SjNopLcNJBOEzCMMeR4QcJmF1AMhVszeWk0/bgiCrQ/jtgZdN/wjJnjZjOVkWFCOHC/kLNTjf61iW5Xm3A==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
- Delivery-date: Fri, 19 Aug 2022 07:50:28 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- add parentheses where they were missing (MISRA)
- make sure to evaluate also v exactly once (MISRA)
- remove excess parentheses
- rename local variables to not have leading underscores
- apply Xen coding style
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
I wonder whether "if ( n_ )" is really helpful: It's extra code in all
callers passing a non-constant size, just to cover a pretty rare case
which memset() is required to deal with correctly anyway, and which
__memzero() also handles quite fine from all I can tell.
--- a/xen/arch/arm/include/asm/string.h
+++ b/xen/arch/arm/include/asm/string.h
@@ -28,17 +28,19 @@
void __memzero(void *ptr, size_t n);
-#define memset(p, v, n) \
- ({ \
- void *__p = (p); size_t __n = n; \
- if ((__n) != 0) { \
- if (__builtin_constant_p((v)) && (v) == 0) \
- __memzero((__p),(__n)); \
- else \
- memset((__p),(v),(__n)); \
- } \
- (__p); \
- })
+#define memset(p, v, n) \
+ ({ \
+ void *p_ = (p); size_t n_ = (n); \
+ typeof(v) v_ = (v); \
+ if ( n_ ) \
+ { \
+ if ( __builtin_constant_p(v) && !v_ ) \
+ __memzero(p_, n_); \
+ else \
+ memset(p_, v_, n_); \
+ } \
+ p_; \
+ })
#endif
|