From 479813329a1ca27f48877b2e872d813f85c957ab Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 15 Feb 2011 23:25:40 +1030 Subject: [PATCH] failtest: don't insert spurious failures if open would fail anyway. open fails in fairly normal cases; don't double execution time for this! --- ccan/failtest/failtest.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index 9102ba0a..1874d620 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -588,12 +588,17 @@ int failtest_open(const char *pathname, /* Avoid memory leak! */ if (p == &unrecorded_call) free((char *)call.pathname); - if (should_fail(p)) { + p->u.open.ret = open(pathname, call.flags, call.mode); + + if (!failpath && p->u.open.ret == -1) { + p->fail = false; + p->error = errno; + } else if (should_fail(p)) { + close(p->u.open.ret); p->u.open.ret = -1; /* FIXME: Play with error codes? */ p->error = EACCES; } else { - p->u.open.ret = open(pathname, call.flags, call.mode); set_cleanup(p, cleanup_open, struct open_call); } errno = p->error; -- 2.39.2