summaryrefslogtreecommitdiff
path: root/count.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-08-25 01:13:43 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-08-25 01:13:43 +0200
commitcb6f056004a10d5c3ed0341366e3ddeb53cac5e6 (patch)
treeda1ecf272317cc684ee64062bbe25153630e6f24 /count.c
parent1a5b5a7aff28a5c8bdafc6104508f553f50977a4 (diff)
downloadstrace-cb6f056004a10d5c3ed0341366e3ddeb53cac5e6.tar.gz
strace-cb6f056004a10d5c3ed0341366e3ddeb53cac5e6.tar.bz2
strace-cb6f056004a10d5c3ed0341366e3ddeb53cac5e6.tar.xz
Opotimize "scno >= 0 && scno < nsyscalls" check
gcc can't figure out on its own that this check can be done with single compare, and does two compares. We can help it by casting scno to unsigned long: ((unsigned long)(scno) < nsyscalls) * defs.h: New macro SCNO_IN_RANGE(long_var). * count.c (count_syscall): Use SCNO_IN_RANGE() instead of open-coded check. * syscall.c (getrval2): Use SCNO_IN_RANGE() instead of open-coded check. This fixes a bug: missing check for scno < 0 and scno > nsyscalls instead of scno >= nsyscalls. (get_scno): Use SCNO_IN_RANGE() instead of open-coded check. This fixes a bug: scno > nsyscalls instead of scno >= nsyscalls. (known_scno): Use SCNO_IN_RANGE() instead of open-coded check. (internal_syscall): Likewise. (syscall_enter): Likewise. (trace_syscall_entering): Likewise. (get_error): Likewise. (trace_syscall_exiting): Likewise. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'count.c')
-rw-r--r--count.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/count.c b/count.c
index 86b1953..77fc919 100644
--- a/count.c
+++ b/count.c
@@ -50,7 +50,7 @@ static struct timeval shortest = { 1000000, 0 };
void
count_syscall(struct tcb *tcp, struct timeval *tv)
{
- if (tcp->scno < 0 || tcp->scno >= nsyscalls)
+ if (!SCNO_IN_RANGE(tcp->scno))
return;
if (!counts) {