[PATCH] stop using -1 in syscallent tables
Denys Vlasenko
dvlasenk at redhat.com
Tue Aug 23 10:34:14 UTC 2011
Usage -1 as argument count in syscallent tables
necessitates the check for it, a-la:
if (tcp->scno >= 0 && tcp->scno < nsyscalls && sysent[tcp->scno].nargs != -1)
tcp->u_nargs = sysent[tcp->scno].nargs;
else
tcp->u_nargs = MAX_ARGS;
which is stupid: we waste cycles checking something which
is constant and known at compile time.
I propose to fix it with these changes:
* Replace all -1 by MA in all tables.
* Redefine struct sysent::nargs as unsigned
(sadly, this is mostly cosmetic, as gcc won't warn
about -1 static initializer for unsigned field, but still...)
* Add #define MA MAX_ARGS / #undef MA around #include "syscallent[N].h"
* Remove sysent[tcp->scno].nargs != -1 checks.
This seems a good plan to me, so I'm going to commit these changes,
but nevertheless feel free to point out any deficiencies in this plan
I might have missed...
--
vda
More information about the Strace-devel
mailing list