提交 61c7bbd2 编写于 作者: A Alexander Graf 提交者: Cornelia Huck

kvm: Fix enable_cap helpers on older gcc

Commit 40f1ee27 introduced handy helpers for enable_cap calls on
vcpu and vm level. Unfortunately some older gcc versions (4.7.1, 4.6)
seem to choke on signedness detection in inline created variables:

target-ppc/kvm.c: In function 'kvmppc_booke_watchdog_enable':
target-ppc/kvm.c:1302:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
target-ppc/kvm.c: In function 'kvmppc_set_papr':
target-ppc/kvm.c:1504:21: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]

However - thanks to Thomas Huth for the suggestion - we can just cast the
offending potentially 0 value to a signed type, making the comparison signed.
Reviewed-by: NThomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: NCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: NAlexander Graf <agraf@suse.de>
Signed-off-by: NCornelia Huck <cornelia.huck@de.ibm.com>
上级 c5fa6c86
......@@ -300,7 +300,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
}; \
uint64_t args_tmp[] = { __VA_ARGS__ }; \
int i; \
for (i = 0; i < ARRAY_SIZE(args_tmp) && \
for (i = 0; i < (int)ARRAY_SIZE(args_tmp) && \
i < ARRAY_SIZE(cap.args); i++) { \
cap.args[i] = args_tmp[i]; \
} \
......@@ -315,7 +315,7 @@ int kvm_check_extension(KVMState *s, unsigned int extension);
}; \
uint64_t args_tmp[] = { __VA_ARGS__ }; \
int i; \
for (i = 0; i < ARRAY_SIZE(args_tmp) && \
for (i = 0; i < (int)ARRAY_SIZE(args_tmp) && \
i < ARRAY_SIZE(cap.args); i++) { \
cap.args[i] = args_tmp[i]; \
} \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册