mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-26 15:31:35 +00:00
HV: Moving operators out from conditions
To follow the Misra-c standard, any operators should be done outside the conditions. Removed the prefix, postfix and bitwise shift from conditions. Signed-off-by: Yang, Yu-chu <yu-chu.yang@intel.com>
This commit is contained in:
parent
078178b23b
commit
dd695f3cfa
@ -1107,7 +1107,8 @@ vlapic_icrlo_write_handler(struct vlapic *vlapic)
|
|||||||
"Sending SIPI from VCPU %d to %hu with vector %d",
|
"Sending SIPI from VCPU %d to %hu with vector %d",
|
||||||
vlapic->vcpu->vcpu_id, vcpu_id, vec);
|
vlapic->vcpu->vcpu_id, vcpu_id, vec);
|
||||||
|
|
||||||
if (--target_vcpu->arch_vcpu.nr_sipi > 0)
|
target_vcpu->arch_vcpu.nr_sipi--;
|
||||||
|
if (target_vcpu->arch_vcpu.nr_sipi > 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
target_vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL;
|
target_vcpu->arch_vcpu.cpu_mode = CPU_MODE_REAL;
|
||||||
|
@ -191,7 +191,8 @@ void timer_softirq(uint16_t pcpu_id)
|
|||||||
list_for_each_safe(pos, n, &cpu_timer->timer_list) {
|
list_for_each_safe(pos, n, &cpu_timer->timer_list) {
|
||||||
timer = list_entry(pos, struct timer, node);
|
timer = list_entry(pos, struct timer, node);
|
||||||
/* timer expried */
|
/* timer expried */
|
||||||
if (timer->fire_tsc <= current_tsc && --tries > 0) {
|
tries--;
|
||||||
|
if (timer->fire_tsc <= current_tsc && tries > 0) {
|
||||||
del_timer(timer);
|
del_timer(timer);
|
||||||
|
|
||||||
run_timer(timer);
|
run_timer(timer);
|
||||||
|
@ -1167,10 +1167,11 @@ void suspend_iommu(void)
|
|||||||
/* If the number of real iommu devices is larger than we
|
/* If the number of real iommu devices is larger than we
|
||||||
* defined in kconfig.
|
* defined in kconfig.
|
||||||
*/
|
*/
|
||||||
if (iommu_idx++ > CONFIG_MAX_IOMMU_NUM) {
|
if (iommu_idx > CONFIG_MAX_IOMMU_NUM) {
|
||||||
pr_err("iommu dev number is larger than pre-defined");
|
pr_err("iommu dev number is larger than pre-defined");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
iommu_idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1206,10 +1207,11 @@ void resume_iommu(void)
|
|||||||
/* If the number of real iommu devices is larger than we
|
/* If the number of real iommu devices is larger than we
|
||||||
* defined in kconfig.
|
* defined in kconfig.
|
||||||
*/
|
*/
|
||||||
if (iommu_idx++ > CONFIG_MAX_IOMMU_NUM) {
|
if (iommu_idx > CONFIG_MAX_IOMMU_NUM) {
|
||||||
pr_err("iommu dev number is larger than pre-defined");
|
pr_err("iommu dev number is larger than pre-defined");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
iommu_idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,10 @@ static int charout(int cmd, const char *s, int sz, void *hnd)
|
|||||||
/* fill mode */
|
/* fill mode */
|
||||||
else {
|
else {
|
||||||
*nchars += sz;
|
*nchars += sz;
|
||||||
while ((sz--) != 0)
|
while (sz != 0) {
|
||||||
console_putc(*s);
|
console_putc(*s);
|
||||||
|
sz--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return *nchars;
|
return *nchars;
|
||||||
|
@ -22,7 +22,8 @@ static struct uart *get_uart_by_id(const char *uart_id, uint32_t *index)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* No device is found if index reaches end of array. */
|
/* No device is found if index reaches end of array. */
|
||||||
if (++(*index) == SERIAL_MAX_DEVS)
|
(*index)++;
|
||||||
|
if (*index == SERIAL_MAX_DEVS)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,9 @@ static int string_to_argv(char *argv_str, void *p_argv_mem,
|
|||||||
*/
|
*/
|
||||||
*p_ch = 0;
|
*p_ch = 0;
|
||||||
/* Remove all space in middile of cmdline */
|
/* Remove all space in middile of cmdline */
|
||||||
while (*++p_ch == ' ')
|
p_ch++;
|
||||||
;
|
while (*p_ch == ' ')
|
||||||
|
p_ch++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ static int do_udiv32(uint32_t dividend, uint32_t divisor,
|
|||||||
res->q.dwords.low |= mask;
|
res->q.dwords.low |= mask;
|
||||||
}
|
}
|
||||||
divisor >>= 1U;
|
divisor >>= 1U;
|
||||||
} while (((mask >>= 1U) != 0U) && (dividend != 0U));
|
mask >>= 1U;
|
||||||
|
} while ((mask != 0U) && (dividend != 0U));
|
||||||
/* dividend now contains the reminder */
|
/* dividend now contains the reminder */
|
||||||
res->r.dwords.low = dividend;
|
res->r.dwords.low = dividend;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -9,8 +9,9 @@
|
|||||||
void mdelay(uint32_t loop_count)
|
void mdelay(uint32_t loop_count)
|
||||||
{
|
{
|
||||||
/* Loop until done */
|
/* Loop until done */
|
||||||
while (loop_count-- != 0) {
|
while (loop_count != 0) {
|
||||||
/* Delay for 1 ms */
|
/* Delay for 1 ms */
|
||||||
udelay(1000);
|
udelay(1000);
|
||||||
|
loop_count--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,11 +95,13 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
|
|||||||
*/
|
*/
|
||||||
for (i = 1; i < requested_buffs; i++) {
|
for (i = 1; i < requested_buffs; i++) {
|
||||||
/* Check if tmp_bit_idx is out-of-range */
|
/* Check if tmp_bit_idx is out-of-range */
|
||||||
if (++tmp_bit_idx == BITMAP_WORD_SIZE) {
|
tmp_bit_idx++;
|
||||||
|
if (tmp_bit_idx == BITMAP_WORD_SIZE) {
|
||||||
/* Break the loop if tmp_idx is
|
/* Break the loop if tmp_idx is
|
||||||
* out-of-range
|
* out-of-range
|
||||||
*/
|
*/
|
||||||
if (++tmp_idx == pool->bmp_size)
|
tmp_idx++;
|
||||||
|
if (tmp_idx == pool->bmp_size)
|
||||||
break;
|
break;
|
||||||
/* Reset tmp_bit_idx */
|
/* Reset tmp_bit_idx */
|
||||||
tmp_bit_idx = 0U;
|
tmp_bit_idx = 0U;
|
||||||
@ -153,7 +155,8 @@ static void *allocate_mem(struct mem_pool *pool, unsigned int num_bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check if bit_idx is out-of-range */
|
/* Check if bit_idx is out-of-range */
|
||||||
if (++bit_idx == BITMAP_WORD_SIZE) {
|
bit_idx++;
|
||||||
|
if (bit_idx == BITMAP_WORD_SIZE) {
|
||||||
/* Increment idx */
|
/* Increment idx */
|
||||||
idx++;
|
idx++;
|
||||||
/* Reset bit_idx */
|
/* Reset bit_idx */
|
||||||
@ -306,8 +309,9 @@ void *memchr(const void *void_s, int c, size_t n)
|
|||||||
|
|
||||||
while (ptr < end) {
|
while (ptr < end) {
|
||||||
|
|
||||||
if (*ptr++ == val)
|
if (*ptr == val)
|
||||||
return ((void *)(ptr - 1));
|
return ((void *)ptr);
|
||||||
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -147,7 +147,8 @@ static const char *get_length_modifier(const char *s,
|
|||||||
{
|
{
|
||||||
/* check for h[h] (char/short) */
|
/* check for h[h] (char/short) */
|
||||||
if (*s == 'h') {
|
if (*s == 'h') {
|
||||||
if (*++s == 'h') {
|
s++;
|
||||||
|
if (*s == 'h') {
|
||||||
*flags |= PRINT_FLAG_CHAR;
|
*flags |= PRINT_FLAG_CHAR;
|
||||||
*mask = 0x000000FF;
|
*mask = 0x000000FF;
|
||||||
++s;
|
++s;
|
||||||
@ -158,7 +159,8 @@ static const char *get_length_modifier(const char *s,
|
|||||||
}
|
}
|
||||||
/* check for l[l] (long/long long) */
|
/* check for l[l] (long/long long) */
|
||||||
else if (*s == 'l') {
|
else if (*s == 'l') {
|
||||||
if (*++s == 'l') {
|
s++;
|
||||||
|
if (*s == 'l') {
|
||||||
*flags |= PRINT_FLAG_LONG_LONG;
|
*flags |= PRINT_FLAG_LONG_LONG;
|
||||||
++s;
|
++s;
|
||||||
} else
|
} else
|
||||||
@ -297,8 +299,10 @@ static int print_pow2(struct print_param *param,
|
|||||||
|
|
||||||
/* determine digits from right to left */
|
/* determine digits from right to left */
|
||||||
do {
|
do {
|
||||||
*--pos = digits[(v & mask)];
|
pos--;
|
||||||
} while ((v >>= shift) != 0UL);
|
*pos = digits[(v & mask)];
|
||||||
|
v >>= shift;
|
||||||
|
} while (v != 0UL);
|
||||||
|
|
||||||
/* assign parameter and apply width and precision */
|
/* assign parameter and apply width and precision */
|
||||||
param->vars.value = pos;
|
param->vars.value = pos;
|
||||||
@ -365,8 +369,10 @@ static int print_decimal(struct print_param *param, int64_t value)
|
|||||||
* 10.
|
* 10.
|
||||||
*/
|
*/
|
||||||
nv.dwords.low = v.dwords.low / 10;
|
nv.dwords.low = v.dwords.low / 10;
|
||||||
*--pos = (v.dwords.low - (10 * nv.dwords.low)) + '0';
|
pos--;
|
||||||
} while ((v.dwords.low = nv.dwords.low) != 0);
|
*pos = (v.dwords.low - (10 * nv.dwords.low)) + '0';
|
||||||
|
v.dwords.low = nv.dwords.low;
|
||||||
|
} while (v.dwords.low != 0);
|
||||||
|
|
||||||
/* assign parameter and apply width and precision */
|
/* assign parameter and apply width and precision */
|
||||||
param->vars.value = pos;
|
param->vars.value = pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user