|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen: fix violations of MISRA C:2012 Rule 3.1
commit ea96231023fb264b4499fda0cca4ae048ea6d456
Author: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Thu Jul 13 16:57:16 2023 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Jul 13 16:57:16 2023 +0200
xen: fix violations of MISRA C:2012 Rule 3.1
In the file 'xen/common/xmalloc_tlsf.c' is not clear how
the commented-out code should interact with the previous statement.
To resolve the MISRA violation generated by the nested comment
a #if .. #endif block with an explanatory comment substitutes
the earlier construct.
In the file 'xen/include/xen/atomic.h' the nested comment has been removed,
since the code sample is already explained by the preceding comment.
Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
xen/common/xmalloc_tlsf.c | 13 ++++++++++---
xen/include/xen/atomic.h | 2 +-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/xen/common/xmalloc_tlsf.c b/xen/common/xmalloc_tlsf.c
index c21bf71e88..c603c39bb9 100644
--- a/xen/common/xmalloc_tlsf.c
+++ b/xen/common/xmalloc_tlsf.c
@@ -139,10 +139,17 @@ static inline void MAPPING_SEARCH(unsigned long *r, int
*fl, int *sl)
*r = *r + t;
*fl = flsl(*r) - 1;
*sl = (*r >> (*fl - MAX_LOG2_SLI)) - MAX_SLI;
- *fl -= FLI_OFFSET;
- /*if ((*fl -= FLI_OFFSET) < 0) // FL will be always >0!
- *fl = *sl = 0;
+ /*
+ * It's unclear what was the purpose of the commented-out code that now
+ * is in the #else branch. The current form is motivated by the
correction
+ * of a violation MISRA:C 2012 Rule 3.1
*/
+#if 1
+ *fl -= FLI_OFFSET;
+#else
+ if ((*fl -= FLI_OFFSET) < 0) /* FL will be always >0! */
+ *fl = *sl = 0;
+#endif
*r &= ~t;
}
}
diff --git a/xen/include/xen/atomic.h b/xen/include/xen/atomic.h
index 529213ebbb..fa750a18ae 100644
--- a/xen/include/xen/atomic.h
+++ b/xen/include/xen/atomic.h
@@ -78,7 +78,7 @@ static inline void _atomic_set(atomic_t *v, int i);
* int old = atomic_read(&v);
* int new = old + 1;
* if ( likely(old == atomic_cmpxchg(&v, old, new)) )
- * break; // success!
+ * break;
* }
*/
static inline int atomic_cmpxchg(atomic_t *v, int old, int new);
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |