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

[PATCH 2/2] livepatch: address violations of MISRA C Rule 20.7


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Fri, 13 Mar 2026 11:44:18 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • 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=vshbixKweyTpuWP1WiS0HOtqU2yyfMLBFnxs6AU9Xi0=; b=k+RuaBpKs7Zks5F0VCQgM0zibZ6wUZh5tWhLMk5tC9YYfyP2c4Lqm0eh6/WtE2Hinlg8dcE7QuqfuAFLU56FvHTbwDKaMUa8u/wW/GCHZ2cUp91yjSTGEWE0P6p1Q0myMUOVE+mJFGKsC+XlhEcSBM13wOv97xh3qZXQnfxpS+sgzCQOKQUcLNviuAV/c1kV9KYh54FKYUtBo8hbj3/tZairyRVUoOBKfoA4JTSpnHAd4VLggui4q8PvtpXd+L5jOnpEWJqbAGDbTrFqW527kvN3JyT2GJt4EBPbuJ8V2ohdhpylbmQ1A3+jmVXKWHz0GzpkqPGaHW2H32hIBKcc4g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VAxu/PAhwEzb+JP05VQXQ4Fia53vo+yOhdNsbUZqGcfmUXzFoRcODGKgiNczNQFv9Y7AeL2ubyjwiw8u2+QQqjmIUhW4PsBUFcXuEff3oJDnE6Eq+QAm3MECEB5cpafGMDYDFN08BcRkUK9ZcerS0wKTU5kocEuFFFp39Q+cfYeOkvPyRKYG5SJ9m+yth2fhA4YC5kMXzSC5jDzpzPTQ4x7Hw4ad/EwPI59xWvUKWLD60zfdwacXs7OpNSRptaxY6WdkbpIoJRPUY4Vw3RRr2sspc98qvse0mg9vCtI18uDpnM98Cr/QSRF4ZkIk8kgdW9DW8cXOMdM+xjyPVKz4wg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Delivery-date: Fri, 13 Mar 2026 11:44:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcst66E5OKF88ZqUOMQkXYvVhPMw==
  • Thread-topic: [PATCH 2/2] livepatch: address violations of MISRA C Rule 20.7

MISRA C Rule 20.7 states: "Expressions resulting from the expansion
of macro parameters shall be enclosed in parentheses".

In macros LIVEPATCH_ASSIGN_SINGLE_HOOK() and LIVEPATCH_ASSIGN_MULTI_HOOK()
add parentheses around the macro's parameter 'hook' to prevent against
unintended expansions.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
 xen/common/livepatch.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 7446533c8c..a9986c2aa8 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -660,13 +660,13 @@ static inline int livepatch_check_expectations(const 
struct payload *payload)
  * Perform section pointer and size validation: single hook sections must 
contain a
  * single pointer only.
  */
-#define LIVEPATCH_ASSIGN_SINGLE_HOOK(elf, hook, section_name) do {             
           \
-    const struct livepatch_elf_sec *__sec = livepatch_elf_sec_by_name(elf, 
section_name); \
-    if ( !__sec )                                                              
           \
-        break;                                                                 
           \
-    if ( !section_ok(elf, __sec, sizeof(*hook)) || __sec->sec->sh_size != 
sizeof(*hook) ) \
-        return -EINVAL;                                                        
           \
-    hook = __sec->addr;                                                        
           \
+#define LIVEPATCH_ASSIGN_SINGLE_HOOK(elf, hook, section_name) do {             
               \
+    const struct livepatch_elf_sec *__sec = livepatch_elf_sec_by_name(elf, 
section_name);     \
+    if ( !__sec )                                                              
               \
+        break;                                                                 
               \
+    if ( !section_ok(elf, __sec, sizeof(*(hook))) || __sec->sec->sh_size != 
sizeof(*(hook)) ) \
+        return -EINVAL;                                                        
               \
+    hook = __sec->addr;                                                        
               \
 } while (0)
 
 /*
@@ -678,10 +678,10 @@ static inline int livepatch_check_expectations(const 
struct payload *payload)
     const struct livepatch_elf_sec *__sec = livepatch_elf_sec_by_name(elf, 
section_name); \
     if ( !__sec )                                                              
           \
         break;                                                                 
           \
-    if ( !section_ok(elf, __sec, sizeof(*hook)) )                              
           \
+    if ( !section_ok(elf, __sec, sizeof(*(hook))) )                            
           \
         return -EINVAL;                                                        
           \
     hook = __sec->addr;                                                        
           \
-    nhooks = __sec->sec->sh_size / sizeof(*hook);                              
           \
+    nhooks = __sec->sec->sh_size / sizeof(*(hook));                            
           \
 } while (0)
 
 static int prepare_payload(struct payload *payload,
-- 
2.43.0



 


Rackspace

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