chiark / gitweb /
src/types.c: Clarify gettimeofday error handling (style)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 13 Oct 2014 12:09:03 +0000 (13:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Oct 2014 20:16:24 +0000 (21:16 +0100)
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 <ijackson@chiark.greenend.org.uk>
src/types.c

index 5062c6a8a35964c6bbc712fc4d6831001d61523b..aa34c0ab9945ab43b6256437fa25bded7df8b0b6 100644 (file)
@@ -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;