diff mbox series

[kvm-unit-tests,v2,2/2] x86: don't compare two global objects' addrs for inequality

Message ID 20191015204603.47845-3-morbo@google.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests,v2,1/2] lib: use a status enum for reporting pass/fail | expand

Commit Message

Bill Wendling Oct. 15, 2019, 8:46 p.m. UTC
Two global objects can't have the same address in C. Clang uses this
fact to omit the check on the first iteration of the loop in
check_exception_table. Avoid compariting inequality by using less-than.

Signed-off-by: Bill Wendling <morbo@google.com>
---
 lib/x86/desc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Huth Oct. 16, 2019, 5:53 a.m. UTC | #1
On 15/10/2019 22.46, Bill Wendling wrote:
> Two global objects can't have the same address in C. Clang uses this
> fact to omit the check on the first iteration of the loop in
> check_exception_table. Avoid compariting inequality by using less-than.
> 
> Signed-off-by: Bill Wendling <morbo@google.com>
> ---
>  lib/x86/desc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/x86/desc.c b/lib/x86/desc.c
> index 451f504..4002203 100644
> --- a/lib/x86/desc.c
> +++ b/lib/x86/desc.c
> @@ -113,7 +113,7 @@ static void check_exception_table(struct ex_regs *regs)
>  		(((regs->rflags >> 16) & 1) << 8);
>      asm("mov %0, %%gs:4" : : "r"(ex_val));
>  
> -    for (ex = &exception_table_start; ex != &exception_table_end; ++ex) {
> +    for (ex = &exception_table_start; ex < &exception_table_end; ++ex) {
>          if (ex->rip == regs->rip) {
>              regs->rip = ex->handler;
>              return;
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
Paolo Bonzini Oct. 21, 2019, 3:33 p.m. UTC | #2
On 15/10/19 22:46, Bill Wendling wrote:
> Two global objects can't have the same address in C. Clang uses this
> fact to omit the check on the first iteration of the loop in
> check_exception_table. Avoid compariting inequality by using less-than.
> 
> Signed-off-by: Bill Wendling <morbo@google.com>
> ---
>  lib/x86/desc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/x86/desc.c b/lib/x86/desc.c
> index 451f504..4002203 100644
> --- a/lib/x86/desc.c
> +++ b/lib/x86/desc.c
> @@ -113,7 +113,7 @@ static void check_exception_table(struct ex_regs *regs)
>  		(((regs->rflags >> 16) & 1) << 8);
>      asm("mov %0, %%gs:4" : : "r"(ex_val));
>  
> -    for (ex = &exception_table_start; ex != &exception_table_end; ++ex) {
> +    for (ex = &exception_table_start; ex < &exception_table_end; ++ex) {
>          if (ex->rip == regs->rip) {
>              regs->rip = ex->handler;
>              return;
> 

Queued, thanks.

Paolo
diff mbox series

Patch

diff --git a/lib/x86/desc.c b/lib/x86/desc.c
index 451f504..4002203 100644
--- a/lib/x86/desc.c
+++ b/lib/x86/desc.c
@@ -113,7 +113,7 @@  static void check_exception_table(struct ex_regs *regs)
 		(((regs->rflags >> 16) & 1) << 8);
     asm("mov %0, %%gs:4" : : "r"(ex_val));
 
-    for (ex = &exception_table_start; ex != &exception_table_end; ++ex) {
+    for (ex = &exception_table_start; ex < &exception_table_end; ++ex) {
         if (ex->rip == regs->rip) {
             regs->rip = ex->handler;
             return;