mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-04 23:24:56 +00:00
hv: treewide: fix 'Potential side effect problem in expression'
MISRA-C requirement: The value of an expression shall be the same under any order of evaluation. The order in which side effects take place is unspecified and may lead to unexpected results. This patch add a temporary variable for temporary storage to avoid the side effects of evaluation order. Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -14,11 +14,13 @@ static int charout(int cmd, const char *s_arg, uint32_t sz_arg, void *hnd)
|
||||
int *nchars = (int *)hnd;
|
||||
/* working pointer */
|
||||
const char *p = s;
|
||||
int len;
|
||||
|
||||
/* copy mode ? */
|
||||
if (cmd == PRINT_CMD_COPY) {
|
||||
if (sz > 0U) { /* copy 'sz' characters */
|
||||
s += console_write(s, sz);
|
||||
len = console_write(s, sz);
|
||||
s += len;
|
||||
}
|
||||
|
||||
*nchars += (s - p);
|
||||
|
||||
Reference in New Issue
Block a user