From 446e7c3582475751136722e633085479fcb7dd31 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Thu, 2 May 2019 10:41:59 -0400 Subject: [PATCH] Force correct order of evaluation of macro arguments in check_*register macros Noted that a number of tests were failing on x86 machines with errors like the following: ERROR: register access fault [man error::fault] near identifier 'module_name' at /usr/share/systemtap/tapset/linux/context.stp:392:10 The problem was traced to the maxregno argument for the macro having a ?: operator which has lower precedence than || or >. This caused the conditional tests in check_fetch_register and check_store_register for error reporting to incorrectly trigger. Used ()'s in the conditionals to force the correct order of evaluation. --- runtime/linux/loc2c-runtime.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/linux/loc2c-runtime.h b/runtime/linux/loc2c-runtime.h index 767b3feb9..048d3307f 100644 --- a/runtime/linux/loc2c-runtime.h +++ b/runtime/linux/loc2c-runtime.h @@ -31,7 +31,7 @@ #define check_fetch_register(regs,regno,maxregno,fn) ({ \ - if (regs == 0 || regno < 0 || regno > maxregno) { \ + if ((regs) == 0 || (regno) < 0 || (regno) > (maxregno)) { \ snprintf(c->error_buffer, sizeof(c->error_buffer), \ STAP_MSG_LOC2C_04); \ c->last_error = c->error_buffer; \ @@ -41,7 +41,7 @@ }) #define check_store_register(regs,regno,maxregno,value,fn) do { \ - if (regs == 0 || regno < 0 || regno > maxregno) { \ + if ((regs) == 0 || (regno) < 0 || (regno) > (maxregno)) { \ snprintf(c->error_buffer, sizeof(c->error_buffer), \ STAP_MSG_LOC2C_04); \ c->last_error = c->error_buffer; \ -- 2.43.5