From 2ee98e5030860aa535728ec4de5b07c0ce765b50 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 9 Feb 2017 22:26:14 +0000 Subject: [PATCH] Simplify struct inject_opts.rval semantics Drop use of INJECT_OPTS_RVAL_DISABLE special inject_opts.rval value, INJECT_OPTS_RVAL_DEFAULT is enough. * defs.h (INJECT_OPTS_RVAL_DISABLE): Remove. * qualify.c (qualify_inject_common): Do not replace INJECT_OPTS_RVAL_DEFAULT with INJECT_OPTS_RVAL_DISABLE in inject_opts.rval. * syscall.c (tamper_with_syscall_entering): Check for INJECT_OPTS_RVAL_DEFAULT instead of INJECT_OPTS_RVAL_DISABLE. --- defs.h | 1 - qualify.c | 13 +++++-------- syscall.c | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/defs.h b/defs.h index 59c9e0ec..b333a221 100644 --- a/defs.h +++ b/defs.h @@ -206,7 +206,6 @@ struct inject_opts { #define MAX_ERRNO_VALUE 4095 #define INJECT_OPTS_RVAL_DEFAULT (-(MAX_ERRNO_VALUE + 1)) -#define INJECT_OPTS_RVAL_DISABLE (INJECT_OPTS_RVAL_DEFAULT - 1) /* Trace Control Block */ struct tcb { diff --git a/qualify.c b/qualify.c index 4ce98694..bb4aefe3 100644 --- a/qualify.c +++ b/qualify.c @@ -522,16 +522,13 @@ qualify_inject_common(const char *const str, error_msg_and_die("invalid %s '%s'", description, str); } - if (opts.rval == INJECT_OPTS_RVAL_DEFAULT) { - /* If neither retval nor error is specified, then ... */ - if (opts.signo) { - /* disable syscall fault injection if signal is specified. */ - opts.rval = INJECT_OPTS_RVAL_DISABLE; - } else if (fault_tokens_only) { - /* default error code for fault= syntax is ENOSYS */ + /* If neither of retval, error, or signal is specified, then ... */ + if (opts.rval == INJECT_OPTS_RVAL_DEFAULT && !opts.signo) { + if (fault_tokens_only) { + /* in fault= syntax the default error code is ENOSYS. */ opts.rval = -ENOSYS; } else { - /* an error has to be specified in inject= syntax. */ + /* in inject= syntax this is not allowed. */ error_msg_and_die("invalid %s '%s'", description, str); } } diff --git a/syscall.c b/syscall.c index 714fee71..c0407ed5 100644 --- a/syscall.c +++ b/syscall.c @@ -596,7 +596,7 @@ tamper_with_syscall_entering(struct tcb *tcp, unsigned int *signo) if (opts->signo > 0) *signo = opts->signo; - if (opts->rval != INJECT_OPTS_RVAL_DISABLE && !arch_set_scno(tcp, -1)) + if (opts->rval != INJECT_OPTS_RVAL_DEFAULT && !arch_set_scno(tcp, -1)) tcp->flags |= TCB_TAMPERED; return 0; -- 2.50.1