chiark / gitweb /
src/types.c: Clarify gettimeofday error handling (style)
[adns.git] / src / types.c
index 5fdbf5e68dcb8c7a44be44354b31338ea29ac0c6..aa34c0ab9945ab43b6256437fa25bded7df8b0b6 100644 (file)
@@ -365,7 +365,7 @@ enum {
   addr_nrrtypes,
 #define RRTY_FLAG(ty) addr_rf_##ty = 1 << addr__ri_##ty,
   ADDR_RRTYPES(RRTY_FLAG)
-  addr__rrty_hunoz
+  addr__rrty_eat_final_comma
 #undef RRTY_FLAG
 };
 
@@ -373,8 +373,10 @@ static unsigned addr_rrtypeflag(adns_rrtype type) {
   int i;
 
   type &= adns_rrt_typemask;
-  for (i=0; i<addr_nrrtypes && type!=addr_all_rrtypes[i]; i++);
-  return i < addr_nrrtypes ? 1 << i : 0;
+  for (i=0; i<addr_nrrtypes; i++)
+     if (type==addr_all_rrtypes[i])
+       return 1 << i;
+  return 0;
 }
 
 /* About CNAME handling in addr queries.
@@ -652,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);
 
@@ -693,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);
@@ -714,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;
   }
@@ -736,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;