diff mbox series

[v2] include/ctype.h: fix MISRA R10.2 violation

Message ID alpine.DEB.2.22.394.2405151549020.2544314@ubuntu-linux-20-04-desktop (mailing list archive)
State New, archived
Headers show
Series [v2] include/ctype.h: fix MISRA R10.2 violation | expand

Commit Message

Stefano Stabellini May 15, 2024, 10:52 p.m. UTC
The value returned by __toupper is used in arithmetic operations causing
MISRA C 10.2 violations. Cast to plain char in the toupper macro. Also
do the same in tolower for consistency.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
Changes in v2:
- fix the toupper macro instead

Comments

Jan Beulich May 16, 2024, 8:12 a.m. UTC | #1
On 16.05.2024 00:52, Stefano Stabellini wrote:
> The value returned by __toupper is used in arithmetic operations causing
> MISRA C 10.2 violations. Cast to plain char in the toupper macro. Also
> do the same in tolower for consistency.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

diff --git a/xen/include/xen/ctype.h b/xen/include/xen/ctype.h
index 6dec944a37..773ac27aa4 100644
--- a/xen/include/xen/ctype.h
+++ b/xen/include/xen/ctype.h
@@ -48,7 +48,7 @@  static inline unsigned char __toupper(unsigned char c)
 	return c;
 }
 
-#define tolower(c) __tolower(c)
-#define toupper(c) __toupper(c)
+#define tolower(c) ((char)__tolower(c))
+#define toupper(c) ((char)__toupper(c))
 
 #endif