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

Re: [PATCH] lib: make memchr_inv() compliant with Misra rule 11.8


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Tue, 3 Nov 2026 15:38:46 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=dQq92vVJ28VanfC/T4dasbuK9cCJxgm/p2+rz9H2dxY=; b=Io6ZZDqsWEIsQwuRwKFWhl0o3W15XNnEB4SOuBOiU4gK2KKVCEtR9P9Q6MhDSzuQcSNLP4e8Q7Pi91TQ0PIqew+wZunone1PvInUsa23jc8NnlVp/HBsKeE9u0TIehMVYxElm8oB06BbHYfbvlE3CtvcCFGmXsWs23QVwkySD5/fztvIglkE/B+y8V39VXIdJng5QsX3kvW35hXMf9IA51RDz36ipR+3fncx65DIYIcXpZbdLdgJ4m4OqBQ6L+Csi9JGf3lXMSis32d13b91L1y+gylSlA7iWQkTaMyw7nS/3DzzbVw3AQ2atfMjiwjdcLVuXM2a+BlB8muUhXHwCg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gK/Fn5tWohoFOGRhsrGd1IXfE2T3K86i5RhBcjhyHH2awlsdXPgx890Kf9gVDhiuVizG11+M4dswrEwOd0EDSMAoxCbR8lD1Q5QqZzkxwUH5Zf4w/fzh54C1YrwEQxrx0g3Inr7Scj2QQomfr6aa5C8Q0f7OsH91ckab7d5n7gHXMFs+PpnSkquHt2lGuqTDR86kxyuDKJSrgKKZpIyztCDc/1lQ+UDxN+IH/sz0nieMx+nLoqpzSVG1AgC8E7RaBWkQf6WFAusakIn1cBiNn+Q9PFWKZOET8AdG9iT7z+DO/neieK3YTuXCEw1px8+e+o9/cd8KGj7/Tfg8mQXhmg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Delivery-date: Tue, 03 Nov 2026 13:39:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 11/3/26 13:24, Jan Beulich wrote:
Neither the sole present caller nor the two ones pending (in the AMX/ACE
series on x86) require the casting away of constness.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/include/xen/string.h
+++ b/xen/include/xen/string.h
@@ -33,7 +33,7 @@ void *memcpy(void *dest, const void *src
  void *memmove(void *dest, const void *src, size_t n);
  int memcmp(const void *cs, const void *ct, size_t count);
  void *memchr(const void *s, int c, size_t n);
-void *memchr_inv(const void *s, int c, size_t n);
+const void *memchr_inv(const void *s, int c, size_t n);
#include <asm/string.h> --- a/xen/lib/memchr_inv.c
+++ b/xen/lib/memchr_inv.c
@@ -13,13 +13,13 @@
   * returns the address of the first occurrence of a character other than @c,
   * or %NULL if the whole buffer contains just @c.
   */
-void *memchr_inv(const void *s, int c, size_t n)
+const void *memchr_inv(const void *s, int c, size_t n)
  {
        const unsigned char *p = s;
while (n--)
                if ((unsigned char)c != *p++)
-                       return (void *)(p - 1);
+                       return p - 1;
return NULL;
  }

Reviewed-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>

BR, Dmytro.



 


Rackspace

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