From 79d4d86add26e3ed27828e1ed4e069b6109607ed Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 13 Oct 2014 13:09:03 +0100 Subject: [PATCH 1/1] src/types.c: Clarify gettimeofday error handling (style) Use `r=...; if (r)...' rather than `if (syscall) ...'. And add a comment explaining why we're not using adns__must_gettimeofday. Signed-off-by: Ian Jackson --- src/types.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/types.c b/src/types.c index 5062c6a..aa34c0a 100644 --- a/src/types.c +++ b/src/types.c @@ -654,7 +654,7 @@ static void icb_addr(adns_query parent, adns_query child) { struct timeval now; adns_status err; adns_queryflags qf; - int id; + int id, r; propagate_ttl(parent, child); @@ -695,7 +695,7 @@ static void icb_addr(adns_query parent, adns_query child) { * settled on. */ adns__cancel_children(parent); - if (gettimeofday(&now, 0)) goto x_gtod; + r= gettimeofday(&now, 0); if (r) goto x_gtod; qf= adns__qf_addr_cname; if (!(parent->flags & adns_qf_cname_loose)) qf |= adns_qf_cname_forbid; addr_subqueries(parent, now, qf, child->vb.buf, child->vb.used); @@ -716,7 +716,7 @@ static void icb_addr(adns_query parent, adns_query child) { adns__cancel_children(parent); adns__free_interim(parent, pans->rrs.bytes); pans->rrs.bytes= 0; pans->nrrs= 0; - if (gettimeofday(&now, 0)) goto x_gtod; + r= gettimeofday(&now, 0); if (r) goto x_gtod; adns__search_next(ads, parent, now); return; } @@ -738,6 +738,9 @@ static void icb_addr(adns_query parent, adns_query child) { return; x_gtod: + /* We have our own error handling, because adns__must_gettimeofday + * handles errors by calling adns_globalsystemfailure, which would + * reenter the query processing logic. */ adns__diag(ads, -1, parent, "gettimeofday failed: %s", strerror(errno)); err= adns_s_systemfail; goto x_err; -- 2.30.2