|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/2] Arm32: tidy the memset() macro
- 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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |