LLVMFuzzerTestOneInput:
   30|  4.66k|int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t nr) {
   31|  4.66k|  log_init("/tmp/foo", 0, NULL);
   32|  4.66k|  struct regional* reg;
   33|       |
   34|  4.66k|  struct sldns_buffer *pkt = sldns_buffer_new(1);
   35|  4.66k|  sldns_buffer_new_frm_data(pkt, buf, nr);
   36|       |
   37|  4.66k|  reg = regional_create();
   38|       |
   39|  4.66k|  struct msg_parse msg;
   40|  4.66k|  struct edns_data edns;
   41|  4.66k|  memset(&msg, 0, sizeof(struct msg_parse));
   42|  4.66k|  memset(&edns, 0, sizeof(edns));
   43|       |
   44|  4.66k|  struct query_info qinfo_out;
   45|  4.66k|  memset(&qinfo_out, 0, sizeof(struct query_info));
   46|  4.66k|  qinfo_out.qname = (unsigned char *) "\03nic\02de";
   47|  4.66k|  uint8_t *peter = (unsigned char *) "\02de";   // zonename  
   48|  4.66k|  struct module_env env;
   49|  4.66k|  memset(&env, 0, sizeof(struct module_env));
   50|  4.66k|  struct config_file cfg;
   51|  4.66k|  memset(&cfg, 0, sizeof(struct config_file));
   52|       |
   53|  4.66k|  cfg.harden_glue = 0;    // crashes now, want to remove that later
   54|  4.66k|  env.cfg = &cfg;
   55|  4.66k|  cfg.rrset_cache_slabs = HASH_DEFAULT_SLABS;
  ------------------
  |  |   49|  4.66k|#define HASH_DEFAULT_SLABS 4
  ------------------
   56|  4.66k|  cfg.rrset_cache_size = HASH_DEFAULT_MAXMEM;
  ------------------
  |  |  116|  4.66k|#define HASH_DEFAULT_MAXMEM		4*1024*1024 /* bytes */
  ------------------
   57|       |
   58|  4.66k|  struct comm_base* base = comm_base_create(0);
   59|  4.66k|  comm_base_timept(base, &env.now, &env.now_tv);
   60|       |
   61|  4.66k|  env.alloc = malloc(sizeof(struct alloc_cache));
   62|  4.66k|  alloc_init(env.alloc, NULL, 0);
   63|       |
   64|  4.66k|  env.rrset_cache = rrset_cache_create(env.cfg, env.alloc);
   65|       |  
   66|       |
   67|  4.66k|  struct iter_env ie;
   68|  4.66k|  memset(&ie, 0, sizeof(struct iter_env));
   69|       |
   70|  4.66k|  struct iter_priv priv;
   71|  4.66k|  memset(&priv, 0, sizeof(struct iter_priv));
   72|  4.66k|  ie.priv = &priv;
   73|       |
   74|  4.66k|  struct module_qstate qstate;
   75|  4.66k|  memset(&qstate, 0, sizeof(struct module_qstate));
   76|  4.66k|  qstate.env = &env;
   77|  4.66k|  qstate.region = reg;
   78|       |
   79|  4.66k|  if (parse_packet(pkt, &msg, reg) != LDNS_RCODE_NOERROR) {    
  ------------------
  |  Branch (79:7): [True: 2.42k, False: 2.24k]
  ------------------
   80|  2.42k|    goto out;
   81|  2.42k|  }
   82|  2.24k|  if (parse_extract_edns_from_response_msg(&msg, &edns, reg) != LDNS_RCODE_NOERROR) {
  ------------------
  |  Branch (82:7): [True: 3, False: 2.23k]
  ------------------
   83|      3|    goto out;
   84|      3|  }
   85|       |
   86|       |
   87|  2.23k|  int msg_lame_empty = 0;
   88|  2.23k|  int msg_lame_referral = 0;
   89|  2.23k|  scrub_message(pkt, &msg, &qinfo_out, peter, reg, &env, &qstate, &ie,
   90|  2.23k|      &msg_lame_empty, &msg_lame_referral, 0);
   91|       |
   92|  4.66k|out:
   93|  4.66k|  rrset_cache_delete(env.rrset_cache);
   94|  4.66k|  alloc_clear(env.alloc);
   95|  4.66k|  free(env.alloc);
   96|  4.66k|  comm_base_delete(base);
   97|  4.66k|  regional_destroy(reg);
   98|  4.66k|  sldns_buffer_free(pkt);
   99|  4.66k|  return 0;
  100|  2.23k|}

priv_rrset_bad:
  374|  15.6k|{
  375|  15.6k|	if(priv->a.count == 0) 
  ------------------
  |  Branch (375:5): [True: 15.6k, False: 0]
  ------------------
  376|  15.6k|		return 0; /* there are no blocked addresses */
  377|       |
  378|       |	/* see if it is a private name, that is allowed to have any */
  379|      0|	if(priv_lookup_name(priv, pkt, rrset->dname, rrset->dname_len,
  ------------------
  |  Branch (379:5): [True: 0, False: 0]
  ------------------
  380|      0|		ntohs(rrset->rrset_class))) {
  381|      0|		return 0;
  382|      0|	} else {
  383|       |		/* so its a public name, check the address */
  384|      0|		socklen_t len;
  385|      0|		struct rr_parse* rr, *prev = NULL;
  386|      0|		if(rrset->type == LDNS_RR_TYPE_A) {
  ------------------
  |  Branch (386:6): [True: 0, False: 0]
  ------------------
  387|      0|			struct sockaddr_storage addr;
  388|      0|			struct sockaddr_in sa;
  389|       |
  390|      0|			len = (socklen_t)sizeof(sa);
  391|      0|			memset(&sa, 0, len);
  392|      0|			sa.sin_family = AF_INET;
  393|      0|			sa.sin_port = (in_port_t)htons(UNBOUND_DNS_PORT);
  394|      0|			for(rr = rrset->rr_first; rr; rr = rr->next) {
  ------------------
  |  Branch (394:30): [True: 0, False: 0]
  ------------------
  395|      0|				if(sldns_read_uint16(rr->ttl_data+4) 
  ------------------
  |  Branch (395:8): [True: 0, False: 0]
  ------------------
  396|      0|					!= INET_SIZE) {
  ------------------
  |  |   87|      0|#define INET_SIZE 4
  ------------------
  397|      0|					prev = rr;
  398|      0|					continue;
  399|      0|				}
  400|      0|				memmove(&sa.sin_addr, rr->ttl_data+4+2, 
  401|      0|					INET_SIZE);
  ------------------
  |  |   87|      0|#define INET_SIZE 4
  ------------------
  402|      0|				memmove(&addr, &sa, len);
  403|      0|				if(priv_lookup_addr(priv, &addr, len)) {
  ------------------
  |  Branch (403:8): [True: 0, False: 0]
  ------------------
  404|      0|					if(msgparse_rrset_remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, rr, &addr, len))
  ------------------
  |  Branch (404:9): [True: 0, False: 0]
  ------------------
  405|      0|						return 1;
  406|      0|					continue;
  407|      0|				}
  408|      0|				prev = rr;
  409|      0|			}
  410|      0|		} else if(rrset->type == LDNS_RR_TYPE_AAAA) {
  ------------------
  |  Branch (410:13): [True: 0, False: 0]
  ------------------
  411|      0|			struct sockaddr_storage addr;
  412|      0|			struct sockaddr_in6 sa;
  413|      0|			len = (socklen_t)sizeof(sa);
  414|      0|			memset(&sa, 0, len);
  415|      0|			sa.sin6_family = AF_INET6;
  416|      0|			sa.sin6_port = (in_port_t)htons(UNBOUND_DNS_PORT);
  417|      0|			for(rr = rrset->rr_first; rr; rr = rr->next) {
  ------------------
  |  Branch (417:30): [True: 0, False: 0]
  ------------------
  418|      0|				if(sldns_read_uint16(rr->ttl_data+4) 
  ------------------
  |  Branch (418:8): [True: 0, False: 0]
  ------------------
  419|      0|					!= INET6_SIZE) {
  ------------------
  |  |   89|      0|#define INET6_SIZE 16
  ------------------
  420|      0|					prev = rr;
  421|      0|					continue;
  422|      0|				}
  423|      0|				memmove(&sa.sin6_addr, rr->ttl_data+4+2, 
  424|      0|					INET6_SIZE);
  ------------------
  |  |   89|      0|#define INET6_SIZE 16
  ------------------
  425|      0|				memmove(&addr, &sa, len);
  426|      0|				if(priv_lookup_addr(priv, &addr, len)) {
  ------------------
  |  Branch (426:8): [True: 0, False: 0]
  ------------------
  427|      0|					if(msgparse_rrset_remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, rr, &addr, len))
  ------------------
  |  Branch (427:9): [True: 0, False: 0]
  ------------------
  428|      0|						return 1;
  429|      0|					continue;
  430|      0|				}
  431|      0|				prev = rr;
  432|      0|			}
  433|      0|		} else if(rrset->type == LDNS_RR_TYPE_SVCB ||
  ------------------
  |  Branch (433:13): [True: 0, False: 0]
  ------------------
  434|      0|			rrset->type == LDNS_RR_TYPE_HTTPS) {
  ------------------
  |  Branch (434:4): [True: 0, False: 0]
  ------------------
  435|      0|			if(priv_svcb_rrset_bad(priv, pkt, rrset))
  ------------------
  |  Branch (435:7): [True: 0, False: 0]
  ------------------
  436|      0|				return 1;
  437|      0|		}
  438|      0|	}
  439|      0|	return 0;
  440|      0|}

scrub_message:
 1247|  2.23k|{
 1248|  2.23k|	int pkt_before_NS;
 1249|       |	/* basic sanity checks */
 1250|  2.23k|	log_nametypeclass(VERB_ALGO, "scrub for", zonename, LDNS_RR_TYPE_NS, 
 1251|  2.23k|		qinfo->qclass);
 1252|  2.23k|	*msg_lame_empty = 0;
 1253|  2.23k|	*msg_lame_referral = 0;
 1254|  2.23k|	if(msg->qdcount > 1)
  ------------------
  |  Branch (1254:5): [True: 0, False: 2.23k]
  ------------------
 1255|      0|		return 0;
 1256|  2.23k|	if( !(msg->flags&BIT_QR) )
  ------------------
  |  |   72|  2.23k|#define BIT_QR 0x8000
  ------------------
  |  Branch (1256:6): [True: 48, False: 2.19k]
  ------------------
 1257|     48|		return 0;
 1258|  2.19k|	msg->flags &= ~(BIT_AD|BIT_Z); /* force off bit AD and Z */
  ------------------
  |  |   60|  2.19k|#define BIT_AD 0x0020
  ------------------
              	msg->flags &= ~(BIT_AD|BIT_Z); /* force off bit AD and Z */
  ------------------
  |  |   62|  2.19k|#define BIT_Z  0x0040
  ------------------
 1259|       |	
 1260|       |	/* make sure that a query is echoed back when NOERROR or NXDOMAIN */
 1261|       |	/* this is not required for basic operation but is a forgery 
 1262|       |	 * resistance (security) feature */
 1263|  2.19k|	if((FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NOERROR ||
  ------------------
  |  |   74|  2.19k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (1263:6): [True: 536, False: 1.65k]
  ------------------
 1264|  1.65k|		FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NXDOMAIN ||
  ------------------
  |  |   74|  1.65k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (1264:3): [True: 129, False: 1.52k]
  ------------------
 1265|  1.52k|		FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_YXDOMAIN) &&
  ------------------
  |  |   74|  1.52k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (1265:3): [True: 127, False: 1.39k]
  ------------------
 1266|    792|		msg->qdcount == 0)
  ------------------
  |  Branch (1266:3): [True: 11, False: 781]
  ------------------
 1267|     11|		return 0;
 1268|       |
 1269|       |	/* if a query is echoed back, make sure it is correct. Otherwise,
 1270|       |	 * this may be not a reply to our query. */
 1271|  2.18k|	if(msg->qdcount == 1) {
  ------------------
  |  Branch (1271:5): [True: 1.06k, False: 1.12k]
  ------------------
 1272|  1.06k|		if(dname_pkt_compare(pkt, msg->qname, qinfo->qname) != 0)
  ------------------
  |  Branch (1272:6): [True: 42, False: 1.01k]
  ------------------
 1273|     42|			return 0;
 1274|  1.01k|		if(msg->qtype != qinfo->qtype || msg->qclass != qinfo->qclass)
  ------------------
  |  Branch (1274:6): [True: 26, False: 992]
  |  Branch (1274:36): [True: 24, False: 968]
  ------------------
 1275|     50|			return 0;
 1276|  1.01k|	}
 1277|       |
 1278|       |	/* If the packet contains type NS in authority before scrub,
 1279|       |	 * like a self referral. With the answer section empty, it
 1280|       |	 * was not AA, the query was not sent with RD, with NS in auth,
 1281|       |	 * and no SOA in auth. For a negative answer, type SOA is present.
 1282|       |	 * This detects certain lameness if after has removed that. */
 1283|  2.08k|	pkt_before_NS = msg->an_rrsets == 0 &&
  ------------------
  |  Branch (1283:18): [True: 1.42k, False: 664]
  ------------------
 1284|  1.42k|		!(msg->flags&BIT_AA) && !rdset &&
  ------------------
  |  |   70|  1.42k|#define BIT_AA 0x0400
  ------------------
  |  Branch (1284:3): [True: 865, False: 559]
  |  Branch (1284:27): [True: 865, False: 0]
  ------------------
 1285|    865|		pkt_contains_ns(msg) && !soa_in_auth(msg);
  ------------------
  |  Branch (1285:3): [True: 246, False: 619]
  |  Branch (1285:27): [True: 226, False: 20]
  ------------------
 1286|       |
 1287|       |	/* normalize the response, this cleans up the additional.  */
 1288|  2.08k|	if(!scrub_normalize(pkt, msg, qinfo, region, env, zonename))
  ------------------
  |  Branch (1288:5): [True: 40, False: 2.04k]
  ------------------
 1289|     40|		return 0;
 1290|       |	/* delete all out-of-zone information */
 1291|  2.04k|	if(!scrub_sanitize(pkt, msg, qinfo, zonename, env, ie, qstate,
  ------------------
  |  Branch (1291:5): [True: 20, False: 2.02k]
  ------------------
 1292|  2.04k|		pkt_before_NS, msg_lame_empty, msg_lame_referral, rdset))
 1293|     20|		return 0;
 1294|  2.02k|	return 1;
 1295|  2.04k|}
iter_scrub.c:pkt_contains_ns:
  329|    865|{
  330|    865|	struct rrset_parse* rrset;
  331|  11.1k|	for(rrset = msg->rrset_first; rrset; rrset = rrset->rrset_all_next) {
  ------------------
  |  Branch (331:32): [True: 10.5k, False: 619]
  ------------------
  332|  10.5k|		if(rrset->type == LDNS_RR_TYPE_NS &&
  ------------------
  |  Branch (332:6): [True: 883, False: 9.65k]
  ------------------
  333|    883|			(rrset->section == LDNS_SECTION_ANSWER ||
  ------------------
  |  Branch (333:5): [True: 0, False: 883]
  ------------------
  334|    883|			rrset->section == LDNS_SECTION_AUTHORITY))
  ------------------
  |  Branch (334:4): [True: 246, False: 637]
  ------------------
  335|    246|			return 1;
  336|  10.5k|	}
  337|    619|	return 0;
  338|    865|}
iter_scrub.c:soa_in_auth:
  373|  2.46k|{
  374|  2.46k|	struct rrset_parse* rrset;
  375|   236k|	for(rrset = msg->rrset_first; rrset; rrset = rrset->rrset_all_next)
  ------------------
  |  Branch (375:32): [True: 234k, False: 1.89k]
  ------------------
  376|   234k|		if(rrset->type == LDNS_RR_TYPE_SOA &&
  ------------------
  |  Branch (376:6): [True: 1.62k, False: 232k]
  ------------------
  377|  1.62k|			rrset->section == LDNS_SECTION_AUTHORITY) 
  ------------------
  |  Branch (377:4): [True: 565, False: 1.05k]
  ------------------
  378|    565|			return 1;
  379|  1.89k|	return 0;
  380|  2.46k|}
iter_scrub.c:scrub_normalize:
  499|  2.08k|{
  500|  2.08k|	uint8_t* sname = qinfo->qname;
  501|  2.08k|	size_t snamelen = qinfo->qname_len;
  502|  2.08k|	struct rrset_parse* rrset, *prev, *nsset=NULL;
  503|  2.08k|	int cname_length = 0; /* number of CNAMEs, or DNAMEs */
  504|  2.08k|	size_t num_glue = 0; /* number of A,AAAA RRs in additional */
  505|  2.08k|	int has_answer = 0; /* if answer section contains nonCNAME,nonDNAME */
  506|       |
  507|  2.08k|	if(FLAGS_GET_RCODE(msg->flags) != LDNS_RCODE_NOERROR &&
  ------------------
  |  |   74|  2.08k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (507:5): [True: 1.59k, False: 494]
  ------------------
  508|  1.59k|		FLAGS_GET_RCODE(msg->flags) != LDNS_RCODE_NXDOMAIN &&
  ------------------
  |  |   74|  1.59k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (508:3): [True: 1.47k, False: 122]
  ------------------
  509|  1.47k|		FLAGS_GET_RCODE(msg->flags) != LDNS_RCODE_YXDOMAIN)
  ------------------
  |  |   74|  1.47k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (509:3): [True: 1.35k, False: 116]
  ------------------
  510|  1.35k|		return 1;
  511|       |
  512|       |	/* For the ANSWER section, remove all "irrelevant" records and add
  513|       |	 * synthesized CNAMEs from DNAMEs
  514|       |	 * This will strip out-of-order CNAMEs as well. */
  515|       |
  516|       |	/* walk through the parse packet rrset list, keep track of previous
  517|       |	 * for insert and delete ease, and examine every RRset */
  518|    732|	prev = NULL;
  519|    732|	rrset = msg->rrset_first;
  520|  3.15k|	while(rrset && rrset->section == LDNS_SECTION_ANSWER) {
  ------------------
  |  Branch (520:8): [True: 2.99k, False: 156]
  |  Branch (520:17): [True: 2.45k, False: 536]
  ------------------
  521|  2.45k|		if((int)rrset->rrsig_count > env->cfg->iter_scrub_rrsig)
  ------------------
  |  Branch (521:6): [True: 47, False: 2.41k]
  ------------------
  522|     47|			shorten_rrsig(pkt, rrset, env->cfg->iter_scrub_rrsig);
  523|  2.45k|		if(cname_length > env->cfg->iter_scrub_cname) {
  ------------------
  |  Branch (523:6): [True: 299, False: 2.16k]
  ------------------
  524|       |			/* Too many CNAMEs, or DNAMEs, from the authority
  525|       |			 * server, scrub down the length to something
  526|       |			 * shorter. This deletes everything after the limit
  527|       |			 * is reached. The iterator is going to look up
  528|       |			 * the content one by one, if harden-cname-follow . */
  529|    299|			remove_rrset("normalize: removing because too many cnames:",
  530|    299|				pkt, msg, prev, &rrset);
  531|    299|			continue;
  532|    299|		}
  533|  2.16k|		if(rrset->type == LDNS_RR_TYPE_DNAME &&
  ------------------
  |  Branch (533:6): [True: 410, False: 1.75k]
  ------------------
  534|    410|			pkt_strict_sub(pkt, sname, rrset->dname) &&
  ------------------
  |  Branch (534:4): [True: 272, False: 138]
  ------------------
  535|    272|			pkt_sub(pkt, rrset->dname, zonename)) {
  ------------------
  |  Branch (535:4): [True: 126, False: 146]
  ------------------
  536|       |			/* check if next rrset is correct CNAME. else,
  537|       |			 * synthesize a CNAME */
  538|    126|			struct rrset_parse* nx = rrset->rrset_all_next;
  539|    126|			uint8_t alias[LDNS_MAX_DOMAINLEN+1];
  540|    126|			size_t aliaslen = 0;
  541|    126|			if(rrset->rr_count != 1) {
  ------------------
  |  Branch (541:7): [True: 3, False: 123]
  ------------------
  542|      3|				verbose(VERB_ALGO, "Found DNAME rrset with "
  543|      3|					"size > 1: %u", 
  544|      3|					(unsigned)rrset->rr_count);
  545|      3|				return 0;
  546|      3|			}
  547|    123|			if(has_answer) {
  ------------------
  |  Branch (547:7): [True: 19, False: 104]
  ------------------
  548|     19|				remove_rrset("normalize: removing DNAME redirection after answer:",
  549|     19|					pkt, msg, prev, &rrset);
  550|     19|				continue;
  551|     19|			}
  552|    104|			if(!synth_cname(sname, snamelen, rrset, alias, 
  ------------------
  |  Branch (552:7): [True: 104, False: 0]
  ------------------
  553|    104|				&aliaslen, pkt)) {
  554|    104|				verbose(VERB_ALGO, "synthesized CNAME "
  555|    104|					"too long");
  556|    104|				if(FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_YXDOMAIN) {
  ------------------
  |  |   74|    104|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (556:8): [True: 101, False: 3]
  ------------------
  557|    101|					prev = rrset;
  558|    101|					rrset = rrset->rrset_all_next;
  559|    101|					continue;
  560|    101|				}
  561|      3|				return 0;
  562|    104|			}
  563|      0|			cname_length++;
  564|      0|			if(nx && nx->type == LDNS_RR_TYPE_CNAME && 
  ------------------
  |  Branch (564:7): [True: 0, False: 0]
  |  Branch (564:13): [True: 0, False: 0]
  ------------------
  565|      0|			   dname_pkt_compare(pkt, sname, nx->dname) == 0) {
  ------------------
  |  Branch (565:7): [True: 0, False: 0]
  ------------------
  566|       |				/* check next cname */
  567|      0|				uint8_t* t = NULL;
  568|      0|				size_t tlen = 0;
  569|      0|				if(!parse_get_cname_target(nx, &t, &tlen, pkt))
  ------------------
  |  Branch (569:8): [True: 0, False: 0]
  ------------------
  570|      0|					return 0;
  571|      0|				if(dname_pkt_compare(pkt, alias, t) == 0) {
  ------------------
  |  Branch (571:8): [True: 0, False: 0]
  ------------------
  572|       |					/* it's OK and better capitalized */
  573|      0|					prev = rrset;
  574|      0|					rrset = nx;
  575|      0|					continue;
  576|      0|				}
  577|       |				/* synth ourselves */
  578|      0|			}
  579|       |			/* synth a CNAME rrset */
  580|      0|			prev = synth_cname_rrset(&sname, &snamelen, alias, 
  581|      0|				aliaslen, region, msg, rrset, rrset, nx, pkt);
  582|      0|			if(!prev) {
  ------------------
  |  Branch (582:7): [True: 0, False: 0]
  ------------------
  583|      0|				log_err("out of memory synthesizing CNAME");
  584|      0|				return 0;
  585|      0|			}
  586|      0|			rrset = nx;
  587|      0|			continue;
  588|       |
  589|      0|		}
  590|       |
  591|       |		/* The only records in the ANSWER section not allowed to */
  592|  2.03k|		if(dname_pkt_compare(pkt, sname, rrset->dname) != 0) {
  ------------------
  |  Branch (592:6): [True: 1.71k, False: 322]
  ------------------
  593|  1.71k|			remove_rrset("normalize: removing irrelevant RRset:", 
  594|  1.71k|				pkt, msg, prev, &rrset);
  595|  1.71k|			continue;
  596|  1.71k|		}
  597|       |
  598|       |		/* Follow the CNAME chain. */
  599|    322|		if(rrset->type == LDNS_RR_TYPE_CNAME) {
  ------------------
  |  Branch (599:6): [True: 101, False: 221]
  ------------------
  600|    101|			struct rrset_parse* nx = rrset->rrset_all_next;
  601|    101|			uint8_t* oldsname = sname;
  602|    101|			if(has_answer) {
  ------------------
  |  Branch (602:7): [True: 25, False: 76]
  ------------------
  603|     25|				remove_rrset("normalize: removing redirection after answer:",
  604|     25|					pkt, msg, prev, &rrset);
  605|     25|				continue;
  606|     25|			}
  607|     76|			cname_length++;
  608|       |			/* see if the next one is a DNAME, if so, swap them */
  609|     76|			if(nx && nx->section == LDNS_SECTION_ANSWER &&
  ------------------
  |  Branch (609:7): [True: 64, False: 12]
  |  Branch (609:13): [True: 60, False: 4]
  ------------------
  610|     60|				nx->type == LDNS_RR_TYPE_DNAME &&
  ------------------
  |  Branch (610:5): [True: 12, False: 48]
  ------------------
  611|     12|				nx->rr_count == 1 &&
  ------------------
  |  Branch (611:5): [True: 8, False: 4]
  ------------------
  612|      8|				pkt_strict_sub(pkt, sname, nx->dname) &&
  ------------------
  |  Branch (612:5): [True: 6, False: 2]
  ------------------
  613|      6|				pkt_sub(pkt, nx->dname, zonename)) {
  ------------------
  |  Branch (613:5): [True: 3, False: 3]
  ------------------
  614|       |				/* there is a DNAME after this CNAME, it 
  615|       |				 * is in the ANSWER section, and the DNAME
  616|       |				 * applies to the name we cover */
  617|       |				/* check if the alias of the DNAME equals
  618|       |				 * this CNAME */
  619|      3|				uint8_t alias[LDNS_MAX_DOMAINLEN+1];
  620|      3|				size_t aliaslen = 0;
  621|      3|				uint8_t* t = NULL;
  622|      3|				size_t tlen = 0;
  623|      3|				if(synth_cname(sname, snamelen, nx, alias,
  ------------------
  |  Branch (623:8): [True: 0, False: 3]
  ------------------
  624|      3|					&aliaslen, pkt) &&
  625|      0|					parse_get_cname_target(rrset, &t, &tlen, pkt) &&
  ------------------
  |  Branch (625:6): [True: 0, False: 0]
  ------------------
  626|      0|			   		dname_pkt_compare(pkt, alias, t) == 0) {
  ------------------
  |  Branch (626:9): [True: 0, False: 0]
  ------------------
  627|       |					/* the synthesized CNAME equals the
  628|       |					 * current CNAME.  This CNAME is the
  629|       |					 * one that the DNAME creates, and this
  630|       |					 * CNAME is better capitalised */
  631|      0|					verbose(VERB_ALGO, "normalize: re-order of DNAME and its CNAME");
  632|      0|					if(prev) prev->rrset_all_next = nx;
  ------------------
  |  Branch (632:9): [True: 0, False: 0]
  ------------------
  633|      0|					else msg->rrset_first = nx;
  634|      0|					if(nx->rrset_all_next == NULL)
  ------------------
  |  Branch (634:9): [True: 0, False: 0]
  ------------------
  635|      0|						msg->rrset_last = rrset;
  636|      0|					rrset->rrset_all_next =
  637|      0|						nx->rrset_all_next;
  638|      0|					nx->rrset_all_next = rrset;
  639|       |					/* prev = nx; unused, enable if there
  640|       |					 * is other rrset removal code after
  641|       |					 * this */
  642|      0|				}
  643|      3|			}
  644|       |
  645|       |			/* move to next name in CNAME chain */
  646|     76|			if(!parse_get_cname_target(rrset, &sname, &snamelen, pkt))
  ------------------
  |  Branch (646:7): [True: 34, False: 42]
  ------------------
  647|     34|				return 0;
  648|     42|			prev = rrset;
  649|     42|			rrset = rrset->rrset_all_next;
  650|       |			/* in CNAME ANY response, can have data after CNAME */
  651|     42|			if(qinfo->qtype == LDNS_RR_TYPE_ANY) {
  ------------------
  |  Branch (651:7): [True: 0, False: 42]
  ------------------
  652|      0|				while(rrset && rrset->section ==
  ------------------
  |  Branch (652:11): [True: 0, False: 0]
  |  Branch (652:20): [True: 0, False: 0]
  ------------------
  653|      0|					LDNS_SECTION_ANSWER &&
  654|      0|					dname_pkt_compare(pkt, oldsname,
  ------------------
  |  Branch (654:6): [True: 0, False: 0]
  ------------------
  655|      0|					rrset->dname) == 0) {
  656|      0|					if(rrset->type == LDNS_RR_TYPE_NS &&
  ------------------
  |  Branch (656:9): [True: 0, False: 0]
  ------------------
  657|      0|						rrset->rr_count > env->cfg->iter_scrub_ns) {
  ------------------
  |  Branch (657:7): [True: 0, False: 0]
  ------------------
  658|      0|						shorten_rrset(pkt, rrset, env->cfg->iter_scrub_ns);
  659|      0|					} else if(rrset->type == LDNS_RR_TYPE_DS &&
  ------------------
  |  Branch (659:16): [True: 0, False: 0]
  ------------------
  660|      0|						rrset->rr_count > env->cfg->iter_scrub_ns) {
  ------------------
  |  Branch (660:7): [True: 0, False: 0]
  ------------------
  661|      0|						shorten_rrset(pkt, rrset, env->cfg->iter_scrub_ns);
  662|      0|					}
  663|      0|					prev = rrset;
  664|      0|					rrset = rrset->rrset_all_next;
  665|      0|				}
  666|      0|			}
  667|     42|			continue;
  668|     76|		}
  669|       |
  670|       |		/* Otherwise, make sure that the RRset matches the qtype. */
  671|    221|		if(qinfo->qtype != LDNS_RR_TYPE_ANY && 
  ------------------
  |  Branch (671:6): [True: 221, False: 0]
  ------------------
  672|    221|			qinfo->qtype != rrset->type) {
  ------------------
  |  Branch (672:4): [True: 128, False: 93]
  ------------------
  673|    128|			remove_rrset("normalize: removing irrelevant RRset:", 
  674|    128|				pkt, msg, prev, &rrset);
  675|    128|			continue;
  676|    128|		}
  677|       |
  678|     93|		if(rrset->type == LDNS_RR_TYPE_NS &&
  ------------------
  |  Branch (678:6): [True: 0, False: 93]
  ------------------
  679|      0|			rrset->rr_count > env->cfg->iter_scrub_ns) {
  ------------------
  |  Branch (679:4): [True: 0, False: 0]
  ------------------
  680|      0|			shorten_rrset(pkt, rrset, env->cfg->iter_scrub_ns);
  681|     93|		} else if(rrset->type == LDNS_RR_TYPE_DS &&
  ------------------
  |  Branch (681:13): [True: 0, False: 93]
  ------------------
  682|      0|			rrset->rr_count > env->cfg->iter_scrub_ns) {
  ------------------
  |  Branch (682:4): [True: 0, False: 0]
  ------------------
  683|      0|			shorten_rrset(pkt, rrset, env->cfg->iter_scrub_ns);
  684|      0|		}
  685|       |
  686|       |		/* Mark the additional names from relevant rrset as OK. */
  687|       |		/* only for RRsets that match the query name, other ones
  688|       |		 * will be removed by sanitize, so no additional for them */
  689|     93|		if(dname_pkt_compare(pkt, qinfo->qname, rrset->dname) == 0)
  ------------------
  |  Branch (689:6): [True: 93, False: 0]
  ------------------
  690|     93|			mark_additional_rrset(pkt, msg, rrset);
  691|     93|		has_answer = 1;
  692|       |		
  693|     93|		prev = rrset;
  694|     93|		rrset = rrset->rrset_all_next;
  695|     93|	}
  696|       |
  697|       |	/* Mark additional names from AUTHORITY */
  698|  12.1k|	while(rrset && rrset->section == LDNS_SECTION_AUTHORITY) {
  ------------------
  |  Branch (698:8): [True: 11.6k, False: 488]
  |  Branch (698:17): [True: 11.4k, False: 204]
  ------------------
  699|       |		/* protect internals of recursor by making sure to del these */
  700|  11.4k|		if(rrset->type==LDNS_RR_TYPE_DNAME ||
  ------------------
  |  Branch (700:6): [True: 117, False: 11.2k]
  ------------------
  701|  11.2k|			rrset->type==LDNS_RR_TYPE_CNAME ||
  ------------------
  |  Branch (701:4): [True: 117, False: 11.1k]
  ------------------
  702|  11.1k|			rrset->type==LDNS_RR_TYPE_A ||
  ------------------
  |  Branch (702:4): [True: 1.35k, False: 9.83k]
  ------------------
  703|  9.83k|			rrset->type==LDNS_RR_TYPE_AAAA) {
  ------------------
  |  Branch (703:4): [True: 563, False: 9.26k]
  ------------------
  704|  2.14k|			remove_rrset("normalize: removing irrelevant "
  705|  2.14k|				"RRset:", pkt, msg, prev, &rrset);
  706|  2.14k|			continue;
  707|  2.14k|		}
  708|       |		/* Allowed list of types in the authority section */
  709|  9.26k|		if(env->cfg->harden_unknown_additional &&
  ------------------
  |  Branch (709:6): [True: 0, False: 9.26k]
  ------------------
  710|      0|			!type_allowed_in_authority_section(rrset->type)) {
  ------------------
  |  Branch (710:4): [True: 0, False: 0]
  ------------------
  711|      0|			remove_rrset("normalize: removing irrelevant "
  712|      0|				"RRset:", pkt, msg, prev, &rrset);
  713|      0|			continue;
  714|      0|		}
  715|  9.26k|		if((int)rrset->rrsig_count > env->cfg->iter_scrub_rrsig)
  ------------------
  |  Branch (715:6): [True: 38, False: 9.23k]
  ------------------
  716|     38|			shorten_rrsig(pkt, rrset, env->cfg->iter_scrub_rrsig);
  717|       |		/* only one NS set allowed in authority section */
  718|  9.26k|		if(rrset->type==LDNS_RR_TYPE_NS) {
  ------------------
  |  Branch (718:6): [True: 1.94k, False: 7.32k]
  ------------------
  719|       |			/* NS set must be pertinent to the query */
  720|  1.94k|			if(!sub_of_pkt(pkt, qinfo->qname, rrset->dname)) {
  ------------------
  |  Branch (720:7): [True: 110, False: 1.83k]
  ------------------
  721|    110|				remove_rrset("normalize: removing irrelevant "
  722|    110|					"RRset:", pkt, msg, prev, &rrset);
  723|    110|				continue;
  724|    110|			}
  725|       |			/* we don't want NS sets for NXDOMAIN answers,
  726|       |			 * because they could contain poisonous contents,
  727|       |			 * from. eg. fragmentation attacks, inserted after
  728|       |			 * long RRSIGs in the packet get to the packet
  729|       |			 * border and such */
  730|       |			/* also for NODATA answers */
  731|  1.83k|			if(FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NXDOMAIN ||
  ------------------
  |  |   74|  1.83k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (731:7): [True: 307, False: 1.52k]
  ------------------
  732|  1.52k|			   (FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NOERROR
  ------------------
  |  |   74|  1.52k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (732:8): [True: 1.25k, False: 274]
  ------------------
  733|  1.25k|			    && soa_in_auth(msg) && msg->an_rrsets == 0)) {
  ------------------
  |  Branch (733:11): [True: 545, False: 708]
  |  Branch (733:31): [True: 326, False: 219]
  ------------------
  734|    633|				remove_rrset("normalize: removing irrelevant "
  735|    633|					"RRset:", pkt, msg, prev, &rrset);
  736|    633|				continue;
  737|    633|			}
  738|       |			/* If the NS set is a promiscuous NS set, scrub that
  739|       |			 * to remove potential for poisonous contents that
  740|       |			 * affects other names in the same zone. Remove
  741|       |			 * promiscuous NS sets in positive answers, that
  742|       |			 * thus have records in the answer section. Nodata
  743|       |			 * and nxdomain promiscuous NS sets have been removed
  744|       |			 * already. Since the NS rrset is scrubbed, its
  745|       |			 * address records are also not marked to be allowed
  746|       |			 * and are removed later. */
  747|  1.20k|			if(FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NOERROR &&
  ------------------
  |  |   74|  1.20k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (747:7): [True: 927, False: 274]
  ------------------
  748|    927|				msg->an_rrsets != 0 &&
  ------------------
  |  Branch (748:5): [True: 290, False: 637]
  ------------------
  749|    290|				env->cfg->iter_scrub_promiscuous) {
  ------------------
  |  Branch (749:5): [True: 0, False: 290]
  ------------------
  750|      0|				remove_rrset("normalize: removing promiscuous "
  751|      0|					"RRset:", pkt, msg, prev, &rrset);
  752|      0|				continue;
  753|      0|			}
  754|       |			/* Also delete promiscuous NS for other RCODEs */
  755|  1.20k|			if(FLAGS_GET_RCODE(msg->flags) != LDNS_RCODE_NOERROR
  ------------------
  |  |   74|  1.20k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (755:7): [True: 274, False: 927]
  ------------------
  756|    274|				&& env->cfg->iter_scrub_promiscuous) {
  ------------------
  |  Branch (756:8): [True: 0, False: 274]
  ------------------
  757|      0|				remove_rrset("normalize: removing promiscuous "
  758|      0|					"RRset:", pkt, msg, prev, &rrset);
  759|      0|				continue;
  760|      0|			}
  761|       |			/* Also delete promiscuous NS for NOERROR with nodata
  762|       |			 * for authoritative answers, not for delegations.
  763|       |			 * NOERROR with an_rrsets!=0 already handled.
  764|       |			 * Also NOERROR and soa_in_auth already handled.
  765|       |			 * NOERROR with an_rrsets==0, and not a referral.
  766|       |			 * referral is (NS not the zonename, noSOA).
  767|       |			 */
  768|  1.20k|			if(FLAGS_GET_RCODE(msg->flags) == LDNS_RCODE_NOERROR
  ------------------
  |  |   74|  1.20k|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (768:7): [True: 927, False: 274]
  ------------------
  769|    927|				&& msg->an_rrsets == 0
  ------------------
  |  Branch (769:8): [True: 637, False: 290]
  ------------------
  770|    637|				&& !(dname_pkt_compare(pkt, rrset->dname,
  ------------------
  |  Branch (770:10): [True: 607, False: 30]
  ------------------
  771|    637|				     zonename) != 0 && !soa_in_auth(msg))
  ------------------
  |  Branch (771:28): [True: 607, False: 0]
  ------------------
  772|     30|				&& env->cfg->iter_scrub_promiscuous) {
  ------------------
  |  Branch (772:8): [True: 0, False: 30]
  ------------------
  773|      0|				remove_rrset("normalize: removing promiscuous "
  774|      0|					"RRset:", pkt, msg, prev, &rrset);
  775|      0|				continue;
  776|      0|			}
  777|  1.20k|			if(ntohs(rrset->rrset_class) != qinfo->qclass) {
  ------------------
  |  Branch (777:7): [True: 983, False: 218]
  ------------------
  778|    983|				remove_rrset("normalize: removing other class "
  779|    983|					"RRset:", pkt, msg, prev, &rrset);
  780|    983|				continue;
  781|    983|			}
  782|    218|			if(nsset == NULL) {
  ------------------
  |  Branch (782:7): [True: 213, False: 5]
  ------------------
  783|    213|				nsset = rrset;
  784|    213|			} else {
  785|      5|				remove_rrset("normalize: removing irrelevant "
  786|      5|					"RRset:", pkt, msg, prev, &rrset);
  787|      5|				continue;
  788|      5|			}
  789|    213|			if(rrset->rr_count > env->cfg->iter_scrub_ns) {
  ------------------
  |  Branch (789:7): [True: 213, False: 0]
  ------------------
  790|       |				/* If this is not a referral, and the NS RRset
  791|       |				 * is signed, then remove it entirely, so
  792|       |				 * that when it becomes bogus it does not
  793|       |				 * make the message that is otherwise fine
  794|       |				 * into a bogus message. */
  795|    213|				if(!(msg->an_rrsets == 0 &&
  ------------------
  |  Branch (795:10): [True: 197, False: 16]
  ------------------
  796|    197|					FLAGS_GET_RCODE(msg->flags) ==
  ------------------
  |  |   74|    197|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (796:6): [True: 183, False: 14]
  ------------------
  797|    197|					LDNS_RCODE_NOERROR &&
  798|    183|					!soa_in_auth(msg) &&
  ------------------
  |  Branch (798:6): [True: 183, False: 0]
  ------------------
  799|    183|					!(msg->flags & BIT_AA)) &&
  ------------------
  |  |   70|    183|#define BIT_AA 0x0400
  ------------------
  |  Branch (799:6): [True: 128, False: 55]
  ------------------
  800|     85|					rrset->rrsig_count != 0) {
  ------------------
  |  Branch (800:6): [True: 0, False: 85]
  ------------------
  801|      0|					remove_rrset("normalize: removing too large NS "
  802|      0|						"RRset:", pkt, msg, prev, &rrset);
  803|      0|					continue;
  804|    213|				} else {
  805|    213|					shorten_rrset(pkt, rrset, env->cfg->iter_scrub_ns);
  806|    213|				}
  807|    213|			}
  808|  7.32k|		} else if(rrset->type==LDNS_RR_TYPE_DS) {
  ------------------
  |  Branch (808:13): [True: 72, False: 7.25k]
  ------------------
  809|     72|			if(rrset->rr_count > env->cfg->iter_scrub_ns) {
  ------------------
  |  Branch (809:7): [True: 72, False: 0]
  ------------------
  810|     72|				shorten_rrset(pkt, rrset,
  811|     72|					env->cfg->iter_scrub_ns);
  812|     72|			}
  813|     72|		}
  814|       |		/* if this is type DS and we query for type DS we just got
  815|       |		 * a referral answer for our type DS query, fix packet */
  816|  7.53k|		if(rrset->type==LDNS_RR_TYPE_DS &&
  ------------------
  |  Branch (816:6): [True: 72, False: 7.46k]
  ------------------
  817|     72|			qinfo->qtype == LDNS_RR_TYPE_DS &&
  ------------------
  |  Branch (817:4): [True: 0, False: 72]
  ------------------
  818|      0|			dname_pkt_compare(pkt, qinfo->qname, rrset->dname) == 0) {
  ------------------
  |  Branch (818:4): [True: 0, False: 0]
  ------------------
  819|      0|			rrset->section = LDNS_SECTION_ANSWER;
  820|      0|			msg->ancount = rrset->rr_count + rrset->rrsig_count;
  821|      0|			msg->nscount = 0;
  822|      0|			msg->arcount = 0;
  823|      0|			msg->an_rrsets = 1;
  824|      0|			msg->ns_rrsets = 0;
  825|      0|			msg->ar_rrsets = 0;
  826|      0|			msg->rrset_count = 1;
  827|      0|			msg->rrset_first = rrset;
  828|      0|			msg->rrset_last = rrset;
  829|      0|			rrset->rrset_all_next = NULL;
  830|      0|			return 1;
  831|      0|		}
  832|       |		/* Only mark glue as allowed for type NS in the authority
  833|       |		 * section. Other RR types do not get glue for them, it
  834|       |		 * is allowed from the answer section, but not authority
  835|       |		 * so that a message can not have address records cached
  836|       |		 * as a side effect to the query. */
  837|  7.53k|		if(rrset->type==LDNS_RR_TYPE_NS)
  ------------------
  |  Branch (837:6): [True: 213, False: 7.32k]
  ------------------
  838|    213|			mark_additional_rrset(pkt, msg, rrset);
  839|  7.53k|		prev = rrset;
  840|  7.53k|		rrset = rrset->rrset_all_next;
  841|  7.53k|	}
  842|       |
  843|       |	/* For each record in the additional section, remove it if it is an
  844|       |	 * address record and not in the collection of additional names 
  845|       |	 * found in ANSWER and AUTHORITY. */
  846|       |	/* These records have not been marked OK previously */
  847|  8.65k|	while(rrset && rrset->section == LDNS_SECTION_ADDITIONAL) {
  ------------------
  |  Branch (847:8): [True: 7.95k, False: 692]
  |  Branch (847:17): [True: 7.95k, False: 0]
  ------------------
  848|  7.95k|		if(rrset->type==LDNS_RR_TYPE_A || 
  ------------------
  |  Branch (848:6): [True: 1.48k, False: 6.47k]
  ------------------
  849|  6.47k|			rrset->type==LDNS_RR_TYPE_AAAA) 
  ------------------
  |  Branch (849:4): [True: 389, False: 6.08k]
  ------------------
  850|  1.87k|		{
  851|  1.87k|			if((rrset->flags & RRSET_SCRUB_OK)) {
  ------------------
  |  |   59|  1.87k|#define RRSET_SCRUB_OK	0x80
  ------------------
  |  Branch (851:7): [True: 56, False: 1.82k]
  ------------------
  852|       |				/* remove flag to clean up flags variable */
  853|     56|				rrset->flags &= ~RRSET_SCRUB_OK;
  ------------------
  |  |   59|     56|#define RRSET_SCRUB_OK	0x80
  ------------------
  854|  1.82k|			} else {
  855|  1.82k|				remove_rrset("normalize: removing irrelevant "
  856|  1.82k|					"RRset:", pkt, msg, prev, &rrset);
  857|  1.82k|				continue;
  858|  1.82k|			}
  859|     56|			num_glue += rrset->rr_count;
  860|     56|			if(num_glue > env->cfg->iter_scrub_glue_count) {
  ------------------
  |  Branch (860:7): [True: 56, False: 0]
  ------------------
  861|     56|				remove_rrset("normalize: removing too large "
  862|     56|					"glue amount:", pkt, msg, prev, &rrset);
  863|     56|				continue;
  864|     56|			}
  865|     56|		}
  866|       |		/* protect internals of recursor by making sure to del these */
  867|  6.08k|		if(rrset->type==LDNS_RR_TYPE_DNAME || 
  ------------------
  |  Branch (867:6): [True: 143, False: 5.94k]
  ------------------
  868|  5.94k|			rrset->type==LDNS_RR_TYPE_CNAME ||
  ------------------
  |  Branch (868:4): [True: 101, False: 5.83k]
  ------------------
  869|  5.83k|			rrset->type==LDNS_RR_TYPE_NS) {
  ------------------
  |  Branch (869:4): [True: 538, False: 5.30k]
  ------------------
  870|    782|			remove_rrset("normalize: removing irrelevant "
  871|    782|				"RRset:", pkt, msg, prev, &rrset);
  872|    782|			continue;
  873|    782|		}
  874|       |		/* Allowed list of types in the additional section */
  875|  5.30k|		if(env->cfg->harden_unknown_additional &&
  ------------------
  |  Branch (875:6): [True: 0, False: 5.30k]
  ------------------
  876|      0|			!type_allowed_in_additional_section(rrset->type)) {
  ------------------
  |  Branch (876:4): [True: 0, False: 0]
  ------------------
  877|      0|			remove_rrset("normalize: removing irrelevant "
  878|      0|				"RRset:", pkt, msg, prev, &rrset);
  879|      0|			continue;
  880|      0|		}
  881|  5.30k|		if((int)rrset->rrsig_count > env->cfg->iter_scrub_rrsig)
  ------------------
  |  Branch (881:6): [True: 46, False: 5.25k]
  ------------------
  882|     46|			shorten_rrsig(pkt, rrset, env->cfg->iter_scrub_rrsig);
  883|  5.30k|		prev = rrset;
  884|  5.30k|		rrset = rrset->rrset_all_next;
  885|  5.30k|	}
  886|       |	
  887|    692|	return 1;
  888|    692|}
iter_scrub.c:shorten_rrsig:
  448|    131|{
  449|       |	/* The too large list of RRSIGs on the RRset is shortened.
  450|       |	 * This is so that too large content does not overwhelm the cache.
  451|       |	 * The validator does not validate more than a max number of
  452|       |	 * RRSIGs as well. */
  453|    131|	int i;
  454|    131|	struct rr_parse* rr = rrset->rrsig_first, *prev = NULL;
  455|    131|	if(!rr)
  ------------------
  |  Branch (455:5): [True: 0, False: 131]
  ------------------
  456|      0|		return;
  457|    131|	for(i=0; i<count; i++) {
  ------------------
  |  Branch (457:11): [True: 0, False: 131]
  ------------------
  458|      0|		prev = rr;
  459|      0|		rr = rr->next;
  460|      0|		if(!rr)
  ------------------
  |  Branch (460:6): [True: 0, False: 0]
  ------------------
  461|      0|			return; /* The RRSIG list is already short. */
  462|      0|	}
  463|    131|	if(verbosity >= VERB_QUERY
  ------------------
  |  Branch (463:5): [True: 0, False: 131]
  ------------------
  464|      0|		&& rrset->dname_len <= LDNS_MAX_DOMAINLEN) {
  ------------------
  |  |   29|      0|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (464:6): [True: 0, False: 0]
  ------------------
  465|      0|		uint8_t buf[LDNS_MAX_DOMAINLEN+1];
  466|      0|		dname_pkt_copy(pkt, buf, rrset->dname);
  467|      0|		log_nametypeclass(VERB_QUERY, "normalize: shorten RRSIGs:",
  468|      0|			buf, rrset->type, ntohs(rrset->rrset_class));
  469|      0|	}
  470|       |	/* remove further rrsigs */
  471|    131|	rrset->rrsig_last = prev;
  472|    131|	rrset->rrsig_count = count;
  473|  3.19k|	while(rr) {
  ------------------
  |  Branch (473:8): [True: 3.06k, False: 131]
  ------------------
  474|  3.06k|		rrset->size -= rr->size;
  475|  3.06k|		rr = rr->next;
  476|  3.06k|	}
  477|    131|	if(rrset->rrsig_last)
  ------------------
  |  Branch (477:5): [True: 0, False: 131]
  ------------------
  478|      0|		rrset->rrsig_last->next = NULL;
  479|    131|	else	rrset->rrsig_first = NULL;
  480|    131|}
iter_scrub.c:remove_rrset:
   65|  85.5k|{
   66|  85.5k|	if(verbosity >= VERB_QUERY && str
  ------------------
  |  Branch (66:5): [True: 0, False: 85.5k]
  |  Branch (66:32): [True: 0, False: 0]
  ------------------
   67|      0|		&& (*rrset)->dname_len <= LDNS_MAX_DOMAINLEN) {
  ------------------
  |  |   29|      0|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (67:6): [True: 0, False: 0]
  ------------------
   68|      0|		uint8_t buf[LDNS_MAX_DOMAINLEN+1];
   69|      0|		dname_pkt_copy(pkt, buf, (*rrset)->dname);
   70|      0|		log_nametypeclass(VERB_QUERY, str, buf, 
   71|      0|			(*rrset)->type, ntohs((*rrset)->rrset_class));
   72|      0|	}
   73|  85.5k|	if(prev)
  ------------------
  |  Branch (73:5): [True: 25.1k, False: 60.4k]
  ------------------
   74|  25.1k|		prev->rrset_all_next = (*rrset)->rrset_all_next;
   75|  60.4k|	else	msg->rrset_first = (*rrset)->rrset_all_next;
   76|  85.5k|	if(msg->rrset_last == *rrset)
  ------------------
  |  Branch (76:5): [True: 1.85k, False: 83.7k]
  ------------------
   77|  1.85k|		msg->rrset_last = prev;
   78|  85.5k|	msg->rrset_count --;
   79|  85.5k|	switch((*rrset)->section) {
   80|  12.5k|		case LDNS_SECTION_ANSWER: msg->an_rrsets--; break;
  ------------------
  |  Branch (80:3): [True: 12.5k, False: 73.0k]
  ------------------
   81|  30.2k|		case LDNS_SECTION_AUTHORITY: msg->ns_rrsets--; break;
  ------------------
  |  Branch (81:3): [True: 30.2k, False: 55.3k]
  ------------------
   82|  42.7k|		case LDNS_SECTION_ADDITIONAL: msg->ar_rrsets--; break;
  ------------------
  |  Branch (82:3): [True: 42.7k, False: 42.8k]
  ------------------
   83|      0|		default: log_assert(0);
  ------------------
  |  Branch (83:3): [True: 0, False: 85.5k]
  ------------------
   84|  85.5k|	}
   85|  85.5k|	msgparse_bucket_remove(msg, *rrset);
   86|  85.5k|	*rrset = (*rrset)->rrset_all_next;
   87|  85.5k|}
iter_scrub.c:pkt_strict_sub:
  343|  1.05k|{
  344|  1.05k|	uint8_t buf1[LDNS_MAX_DOMAINLEN+1];
  345|  1.05k|	uint8_t buf2[LDNS_MAX_DOMAINLEN+1];
  346|       |	/* decompress names */
  347|  1.05k|	dname_pkt_copy(pkt, buf1, sname);
  348|  1.05k|	dname_pkt_copy(pkt, buf2, dr);
  349|  1.05k|	return dname_strict_subdomain_c(buf1, buf2);
  350|  1.05k|}
iter_scrub.c:pkt_sub:
  355|  69.9k|{
  356|  69.9k|	uint8_t buf[LDNS_MAX_DOMAINLEN+1];
  357|  69.9k|	dname_pkt_copy(pkt, buf, comprname);
  358|  69.9k|	return dname_subdomain_c(buf, zone);
  359|  69.9k|}
iter_scrub.c:synth_cname:
  228|    107|{
  229|       |	/* we already know that sname is a strict subdomain of DNAME owner */
  230|    107|	uint8_t* dtarg = NULL;
  231|    107|	size_t dtarglen;
  232|    107|	if(!parse_get_cname_target(dname_rrset, &dtarg, &dtarglen, pkt))
  ------------------
  |  Branch (232:5): [True: 88, False: 19]
  ------------------
  233|     88|		return 0; 
  234|     19|	if(qnamelen <= dname_rrset->dname_len)
  ------------------
  |  Branch (234:5): [True: 19, False: 0]
  ------------------
  235|     19|		return 0;
  236|      0|	if(qnamelen == 0)
  ------------------
  |  Branch (236:5): [True: 0, False: 0]
  ------------------
  237|      0|		return 0;
  238|      0|	log_assert(qnamelen > dname_rrset->dname_len);
  239|       |	/* DNAME from com. to net. with qname example.com. -> example.net. */
  240|       |	/* so: \3com\0 to \3net\0 and qname \7example\3com\0 */
  241|      0|	*aliaslen = qnamelen + dtarglen - dname_rrset->dname_len;
  242|      0|	if(*aliaslen > LDNS_MAX_DOMAINLEN)
  ------------------
  |  |   29|      0|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (242:5): [True: 0, False: 0]
  ------------------
  243|      0|		return 0; /* should have been RCODE YXDOMAIN */
  244|       |	/* decompress dnames into buffer, we know it fits */
  245|      0|	dname_pkt_copy(pkt, alias, qname);
  246|      0|	dname_pkt_copy(pkt, alias+(qnamelen-dname_rrset->dname_len), dtarg);
  247|      0|	return 1;
  248|      0|}
iter_scrub.c:parse_get_cname_target:
  189|    405|{
  190|    405|	size_t oldpos, dlen;
  191|    405|	if(rrset->rr_count != 1) {
  ------------------
  |  Branch (191:5): [True: 44, False: 361]
  ------------------
  192|     44|		struct rr_parse* sig;
  193|     44|		verbose(VERB_ALGO, "Found CNAME rrset with "
  194|     44|			"size > 1: %u", (unsigned)rrset->rr_count);
  195|       |		/* use the first CNAME! */
  196|     44|		rrset->rr_count = 1;
  197|     44|		rrset->size = rrset->rr_first->size;
  198|  1.81k|		for(sig=rrset->rrsig_first; sig; sig=sig->next)
  ------------------
  |  Branch (198:31): [True: 1.76k, False: 44]
  ------------------
  199|  1.76k|			rrset->size += sig->size;
  200|     44|		rrset->rr_last = rrset->rr_first;
  201|     44|		rrset->rr_first->next = NULL;
  202|     44|	}
  203|    405|	if(rrset->rr_first->size < sizeof(uint16_t)+1)
  ------------------
  |  Branch (203:5): [True: 142, False: 263]
  ------------------
  204|    142|		return 0; /* CNAME rdata too small */
  205|    263|	*sname = rrset->rr_first->ttl_data + sizeof(uint32_t)
  206|    263|		+ sizeof(uint16_t); /* skip ttl, rdatalen */
  207|    263|	*snamelen = rrset->rr_first->size - sizeof(uint16_t);
  208|       |
  209|    263|	if(rrset->rr_first->outside_packet) {
  ------------------
  |  Branch (209:5): [True: 0, False: 263]
  ------------------
  210|      0|		if(!dname_valid(*sname, *snamelen))
  ------------------
  |  Branch (210:6): [True: 0, False: 0]
  ------------------
  211|      0|			return 0;
  212|      0|		return 1;
  213|      0|	}
  214|    263|	oldpos = sldns_buffer_position(pkt);
  215|    263|	sldns_buffer_set_position(pkt, (size_t)(*sname - sldns_buffer_begin(pkt)));
  216|    263|	dlen = pkt_dname_len(pkt);
  217|    263|	sldns_buffer_set_position(pkt, oldpos);
  218|    263|	if(dlen == 0)
  ------------------
  |  Branch (218:5): [True: 0, False: 263]
  ------------------
  219|      0|		return 0; /* parse fail on the rdata name */
  220|    263|	*snamelen = dlen;
  221|    263|	return 1;
  222|    263|}
iter_scrub.c:shorten_rrset:
  405|    285|{
  406|       |	/* The too large NS RRset is shortened. This is so that too large
  407|       |	 * content does not overwhelm the cache. It may make the rrset
  408|       |	 * bogus if it was signed, and then the domain is not resolved any
  409|       |	 * more, that is okay, the NS RRset was too large. During a referral
  410|       |	 * it can be shortened and then the first part of the list could
  411|       |	 * be used to resolve. The scrub continues to disallow glue for the
  412|       |	 * removed nameserver RRs and removes that too. Because the glue
  413|       |	 * is not marked as okay, since the RRs have been removed here. */
  414|    285|	int i;
  415|    285|	struct rr_parse* rr = rrset->rr_first, *prev = NULL;
  416|    285|	if(!rr)
  ------------------
  |  Branch (416:5): [True: 0, False: 285]
  ------------------
  417|      0|		return;
  418|    285|	if(count < 1)
  ------------------
  |  Branch (418:5): [True: 285, False: 0]
  ------------------
  419|    285|		return; /* cannot leave a still-linked rrset_parse with rr_count == 0 */
  420|      0|	for(i=0; i<count; i++) {
  ------------------
  |  Branch (420:11): [True: 0, False: 0]
  ------------------
  421|      0|		prev = rr;
  422|      0|		rr = rr->next;
  423|      0|		if(!rr)
  ------------------
  |  Branch (423:6): [True: 0, False: 0]
  ------------------
  424|      0|			return; /* The RRset is already short. */
  425|      0|	}
  426|      0|	if(verbosity >= VERB_QUERY
  ------------------
  |  Branch (426:5): [True: 0, False: 0]
  ------------------
  427|      0|		&& rrset->dname_len <= LDNS_MAX_DOMAINLEN) {
  ------------------
  |  |   29|      0|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (427:6): [True: 0, False: 0]
  ------------------
  428|      0|		uint8_t buf[LDNS_MAX_DOMAINLEN+1];
  429|      0|		dname_pkt_copy(pkt, buf, rrset->dname);
  430|      0|		log_nametypeclass(VERB_QUERY, "normalize: shorten RRset:", buf,
  431|      0|			rrset->type, ntohs(rrset->rrset_class));
  432|      0|	}
  433|       |	/* remove further rrs */
  434|      0|	rrset->rr_last = prev;
  435|      0|	rrset->rr_count = count;
  436|      0|	while(rr) {
  ------------------
  |  Branch (436:8): [True: 0, False: 0]
  ------------------
  437|      0|		rrset->size -= rr->size;
  438|      0|		rr = rr->next;
  439|      0|	}
  440|      0|	if(rrset->rr_last)
  ------------------
  |  Branch (440:5): [True: 0, False: 0]
  ------------------
  441|      0|		rrset->rr_last->next = NULL;
  442|      0|	else	rrset->rr_first = NULL;
  443|      0|}
iter_scrub.c:mark_additional_rrset:
  153|    306|{
  154|       |	/* Mark A and AAAA for NS as appropriate additional section info. */
  155|    306|	uint8_t* nm = NULL;
  156|    306|	size_t nmlen = 0;
  157|    306|	struct rr_parse* rr;
  158|       |
  159|    306|	if(!has_additional(rrset->type))
  ------------------
  |  Branch (159:5): [True: 93, False: 213]
  ------------------
  160|     93|		return;
  161|  2.08k|	for(rr = rrset->rr_first; rr; rr = rr->next) {
  ------------------
  |  Branch (161:28): [True: 1.86k, False: 213]
  ------------------
  162|  1.86k|		if(get_additional_name(rrset, rr, &nm, &nmlen, pkt)) {
  ------------------
  |  Branch (162:6): [True: 1.60k, False: 268]
  ------------------
  163|       |			/* mark A */
  164|  1.60k|			hashvalue_type h = pkt_hash_rrset(pkt, nm,
  165|  1.60k|				LDNS_RR_TYPE_A, rrset->rrset_class, 0);
  166|  1.60k|			struct rrset_parse* r = msgparse_hashtable_lookup(
  167|  1.60k|				msg, pkt, h, 0, nm, nmlen, 
  168|  1.60k|				LDNS_RR_TYPE_A, rrset->rrset_class);
  169|  1.60k|			if(r && r->section == LDNS_SECTION_ADDITIONAL) {
  ------------------
  |  Branch (169:7): [True: 901, False: 699]
  |  Branch (169:12): [True: 35, False: 866]
  ------------------
  170|     35|				r->flags |= RRSET_SCRUB_OK;
  ------------------
  |  |   59|     35|#define RRSET_SCRUB_OK	0x80
  ------------------
  171|     35|			}
  172|       |			
  173|       |			/* mark AAAA */
  174|  1.60k|			h = pkt_hash_rrset(pkt, nm, LDNS_RR_TYPE_AAAA, 
  175|  1.60k|				rrset->rrset_class, 0);
  176|  1.60k|			r = msgparse_hashtable_lookup(msg, pkt, h, 0, nm, 
  177|  1.60k|				nmlen, LDNS_RR_TYPE_AAAA, rrset->rrset_class);
  178|  1.60k|			if(r && r->section == LDNS_SECTION_ADDITIONAL) {
  ------------------
  |  Branch (178:7): [True: 432, False: 1.16k]
  |  Branch (178:12): [True: 21, False: 411]
  ------------------
  179|     21|				r->flags |= RRSET_SCRUB_OK;
  ------------------
  |  |   59|     21|#define RRSET_SCRUB_OK	0x80
  ------------------
  180|     21|			}
  181|  1.60k|		}
  182|  1.86k|	}
  183|    213|}
iter_scrub.c:has_additional:
   92|  55.7k|{
   93|  55.7k|	switch(t) {
  ------------------
  |  Branch (93:9): [True: 8.58k, False: 47.2k]
  ------------------
   94|  1.12k|		case LDNS_RR_TYPE_MB:
  ------------------
  |  Branch (94:3): [True: 1.12k, False: 54.6k]
  ------------------
   95|  1.91k|		case LDNS_RR_TYPE_MD:
  ------------------
  |  Branch (95:3): [True: 786, False: 55.0k]
  ------------------
   96|  3.16k|		case LDNS_RR_TYPE_MF:
  ------------------
  |  Branch (96:3): [True: 1.25k, False: 54.5k]
  ------------------
   97|  6.29k|		case LDNS_RR_TYPE_NS:
  ------------------
  |  Branch (97:3): [True: 3.12k, False: 52.6k]
  ------------------
   98|  6.75k|		case LDNS_RR_TYPE_MX:
  ------------------
  |  Branch (98:3): [True: 468, False: 55.3k]
  ------------------
   99|  7.42k|		case LDNS_RR_TYPE_KX:
  ------------------
  |  Branch (99:3): [True: 667, False: 55.1k]
  ------------------
  100|  8.34k|		case LDNS_RR_TYPE_SRV:
  ------------------
  |  Branch (100:3): [True: 921, False: 54.8k]
  ------------------
  101|  8.34k|			return 1;
  102|    235|		case LDNS_RR_TYPE_NAPTR:
  ------------------
  |  Branch (102:3): [True: 235, False: 55.5k]
  ------------------
  103|       |			/* TODO: NAPTR not supported, glue stripped off */
  104|    235|			return 0;
  105|  55.7k|	}
  106|  47.2k|	return 0;
  107|  55.7k|}
iter_scrub.c:get_additional_name:
  113|  1.86k|{
  114|  1.86k|	size_t offset = 0;
  115|  1.86k|	size_t len, oldpos;
  116|  1.86k|	switch(rrset->type) {
  117|      0|		case LDNS_RR_TYPE_MB:
  ------------------
  |  Branch (117:3): [True: 0, False: 1.86k]
  ------------------
  118|      0|		case LDNS_RR_TYPE_MD:
  ------------------
  |  Branch (118:3): [True: 0, False: 1.86k]
  ------------------
  119|      0|		case LDNS_RR_TYPE_MF:
  ------------------
  |  Branch (119:3): [True: 0, False: 1.86k]
  ------------------
  120|  1.86k|		case LDNS_RR_TYPE_NS:
  ------------------
  |  Branch (120:3): [True: 1.86k, False: 0]
  ------------------
  121|  1.86k|			offset = 0;
  122|  1.86k|			break;
  123|      0|		case LDNS_RR_TYPE_MX:
  ------------------
  |  Branch (123:3): [True: 0, False: 1.86k]
  ------------------
  124|      0|		case LDNS_RR_TYPE_KX:
  ------------------
  |  Branch (124:3): [True: 0, False: 1.86k]
  ------------------
  125|      0|			offset = 2;
  126|      0|			break;
  127|      0|		case LDNS_RR_TYPE_SRV:
  ------------------
  |  Branch (127:3): [True: 0, False: 1.86k]
  ------------------
  128|      0|			offset = 6;
  129|      0|			break;
  130|      0|		case LDNS_RR_TYPE_NAPTR:
  ------------------
  |  Branch (130:3): [True: 0, False: 1.86k]
  ------------------
  131|       |			/* TODO: NAPTR not supported, glue stripped off */
  132|      0|			return 0;
  133|      0|		default:
  ------------------
  |  Branch (133:3): [True: 0, False: 1.86k]
  ------------------
  134|      0|			return 0;
  135|  1.86k|	}
  136|  1.86k|	len = sldns_read_uint16(rr->ttl_data+sizeof(uint32_t));
  137|  1.86k|	if(len < offset+1)
  ------------------
  |  Branch (137:5): [True: 268, False: 1.60k]
  ------------------
  138|    268|		return 0; /* rdata field too small */
  139|  1.60k|	*nm = rr->ttl_data+sizeof(uint32_t)+sizeof(uint16_t)+offset;
  140|  1.60k|	oldpos = sldns_buffer_position(pkt);
  141|  1.60k|	sldns_buffer_set_position(pkt, (size_t)(*nm - sldns_buffer_begin(pkt)));
  142|  1.60k|	*nmlen = pkt_dname_len(pkt);
  143|  1.60k|	sldns_buffer_set_position(pkt, oldpos);
  144|  1.60k|	if(*nmlen == 0)
  ------------------
  |  Branch (144:5): [True: 0, False: 1.60k]
  ------------------
  145|      0|		return 0;
  146|  1.60k|	return 1;
  147|  1.60k|}
iter_scrub.c:sub_of_pkt:
  364|  2.11k|{
  365|  2.11k|	uint8_t buf[LDNS_MAX_DOMAINLEN+1];
  366|  2.11k|	dname_pkt_copy(pkt, buf, comprname);
  367|  2.11k|	return dname_subdomain_c(zone, buf);
  368|  2.11k|}
iter_scrub.c:scrub_sanitize:
 1043|  2.04k|{
 1044|  2.04k|	int del_addi = 0; /* if additional-holding rrsets are deleted, we
 1045|       |		do not trust the normalized additional-A-AAAA any more */
 1046|  2.04k|	uint8_t* ns_rrset_dname = NULL;
 1047|  2.04k|	int added_rrlen_ede = 0;
 1048|  2.04k|	struct rrset_parse* rrset, *prev;
 1049|  2.04k|	uint8_t* sname = qinfo->qname;
 1050|  2.04k|	size_t snamelen = qinfo->qname_len;
 1051|  2.04k|	prev = NULL;
 1052|  2.04k|	rrset = msg->rrset_first;
 1053|       |
 1054|       |	/* the first DNAME is allowed to stay. It needs checking before
 1055|       |	 * it can be used from the cache. After normalization, an initial 
 1056|       |	 * DNAME will have a correctly synthesized CNAME after it. */
 1057|  2.04k|	if(rrset && rrset->type == LDNS_RR_TYPE_DNAME && 
  ------------------
  |  Branch (1057:5): [True: 1.80k, False: 240]
  |  Branch (1057:14): [True: 99, False: 1.70k]
  ------------------
 1058|     99|		env->cfg->harden_cname_follow /* CNAME chain is cut off, one DNAME is allowed here. */ &&
  ------------------
  |  Branch (1058:3): [True: 0, False: 99]
  ------------------
 1059|      0|		rrset->section == LDNS_SECTION_ANSWER &&
  ------------------
  |  Branch (1059:3): [True: 0, False: 0]
  ------------------
 1060|      0|		pkt_strict_sub(pkt, qinfo->qname, rrset->dname) &&
  ------------------
  |  Branch (1060:3): [True: 0, False: 0]
  ------------------
 1061|      0|		pkt_sub(pkt, rrset->dname, zonename)) {
  ------------------
  |  Branch (1061:3): [True: 0, False: 0]
  ------------------
 1062|      0|		prev = rrset; /* DNAME allowed to stay in answer section */
 1063|      0|		rrset = rrset->rrset_all_next;
 1064|      0|	}
 1065|       |	
 1066|       |	/* remove all records from the answer section that are 
 1067|       |	 * not the same domain name as the query domain name.
 1068|       |	 * The answer section should contain rrsets with the same name
 1069|       |	 * as the question. For DNAMEs a CNAME has been synthesized.
 1070|       |	 * Wildcards have the query name in answer section.
 1071|       |	 * ANY queries get query name in answer section.
 1072|       |	 * Remainders of CNAME chains are cut off and resolved by iterator. */
 1073|  13.1k|	while(rrset && rrset->section == LDNS_SECTION_ANSWER) {
  ------------------
  |  Branch (1073:8): [True: 12.5k, False: 562]
  |  Branch (1073:17): [True: 11.0k, False: 1.46k]
  ------------------
 1074|  11.0k|		if(!env->cfg->harden_cname_follow /* CNAME chain is allowed to stay */ &&
  ------------------
  |  Branch (1074:6): [True: 11.0k, False: 0]
  ------------------
 1075|  11.0k|			rrset->type == LDNS_RR_TYPE_DNAME &&
  ------------------
  |  Branch (1075:4): [True: 638, False: 10.4k]
  ------------------
 1076|    638|			pkt_strict_sub(pkt, sname, rrset->dname) &&
  ------------------
  |  Branch (1076:4): [True: 309, False: 329]
  ------------------
 1077|    309|			pkt_sub(pkt, rrset->dname, zonename)) {
  ------------------
  |  Branch (1077:4): [True: 112, False: 197]
  ------------------
 1078|       |			/* This DNAME is allowed to stay, the synthesized
 1079|       |			 * CNAME follows next. */
 1080|    112|			prev = rrset;
 1081|    112|			rrset = rrset->rrset_all_next;
 1082|    112|			continue;
 1083|    112|		}
 1084|  10.9k|		if(dname_pkt_compare(pkt, sname, rrset->dname) != 0) {
  ------------------
  |  Branch (1084:6): [True: 6.07k, False: 4.90k]
  ------------------
 1085|  6.07k|			if(has_additional(rrset->type)) del_addi = 1;
  ------------------
  |  Branch (1085:7): [True: 868, False: 5.20k]
  ------------------
 1086|  6.07k|			remove_rrset("sanitize: removing extraneous answer "
 1087|  6.07k|				"RRset:", pkt, msg, prev, &rrset);
 1088|  6.07k|			continue;
 1089|  6.07k|		}
 1090|  4.90k|		if(!env->cfg->harden_cname_follow /* CNAME chain is allowed to stay */ &&
  ------------------
  |  Branch (1090:6): [True: 4.90k, False: 0]
  ------------------
 1091|  4.90k|			qinfo->qtype != LDNS_RR_TYPE_ANY &&
  ------------------
  |  Branch (1091:4): [True: 4.90k, False: 0]
  ------------------
 1092|  4.90k|			rrset->type == LDNS_RR_TYPE_CNAME &&
  ------------------
  |  Branch (1092:4): [True: 222, False: 4.68k]
  ------------------
 1093|    222|			dname_pkt_compare(pkt, sname, rrset->dname) == 0) {
  ------------------
  |  Branch (1093:4): [True: 222, False: 0]
  ------------------
 1094|       |			/* Follow the CNAME chain, and allow the elements
 1095|       |			 * that match the CNAME chain. Also allow a DNAME
 1096|       |			 * in front. */
 1097|    222|			if(!parse_get_cname_target(rrset, &sname, &snamelen,
  ------------------
  |  Branch (1097:7): [True: 20, False: 202]
  ------------------
 1098|    222|				pkt))
 1099|     20|				return 0;
 1100|    222|		}
 1101|  4.88k|		prev = rrset;
 1102|  4.88k|		rrset = rrset->rrset_all_next;
 1103|  4.88k|	}
 1104|       |
 1105|       |	/* At this point, we brutally remove ALL rrsets that aren't 
 1106|       |	 * children of the originating zone. The idea here is that, 
 1107|       |	 * as far as we know, the server that we contacted is ONLY 
 1108|       |	 * authoritative for the originating zone. It, of course, MAY 
 1109|       |	 * be authoritative for any other zones, and of course, MAY 
 1110|       |	 * NOT be authoritative for some subdomains of the originating 
 1111|       |	 * zone. */
 1112|  2.02k|	prev = NULL;
 1113|  2.02k|	rrset = msg->rrset_first;
 1114|  74.7k|	while(rrset) {
  ------------------
  |  Branch (1114:8): [True: 72.7k, False: 2.02k]
  ------------------
 1115|       |
 1116|       |		/* Sanity check for length of records */
 1117|  72.7k|		if(rrset->type == LDNS_RR_TYPE_A ||
  ------------------
  |  Branch (1117:6): [True: 17.2k, False: 55.4k]
  ------------------
 1118|  55.4k|			rrset->type == LDNS_RR_TYPE_AAAA) {
  ------------------
  |  Branch (1118:4): [True: 3.28k, False: 52.1k]
  ------------------
 1119|  20.5k|			if(scrub_sanitize_rr_length(pkt, msg, prev, &rrset,
  ------------------
  |  Branch (1119:7): [True: 5.19k, False: 15.3k]
  ------------------
 1120|  20.5k|				&added_rrlen_ede, qstate))
 1121|  5.19k|				continue;
 1122|  20.5k|		}
 1123|       |
 1124|       |		/* remove private addresses */
 1125|  67.5k|		if(rrset->type == LDNS_RR_TYPE_A ||
  ------------------
  |  Branch (1125:6): [True: 13.5k, False: 54.0k]
  ------------------
 1126|  54.0k|			rrset->type == LDNS_RR_TYPE_AAAA ||
  ------------------
  |  Branch (1126:4): [True: 1.83k, False: 52.1k]
  ------------------
 1127|  52.1k|			rrset->type == LDNS_RR_TYPE_SVCB ||
  ------------------
  |  Branch (1127:4): [True: 103, False: 52.0k]
  ------------------
 1128|  52.0k|			rrset->type == LDNS_RR_TYPE_HTTPS) {
  ------------------
  |  Branch (1128:4): [True: 152, False: 51.9k]
  ------------------
 1129|       |
 1130|       |			/* do not set servfail since this leads to too
 1131|       |			 * many drops of other people using rfc1918 space */
 1132|       |			/* also do not remove entire rrset, unless all records
 1133|       |			 * in it are bad */
 1134|  15.6k|			if(priv_rrset_bad(ie->priv, pkt, rrset)) {
  ------------------
  |  Branch (1134:7): [True: 0, False: 15.6k]
  ------------------
 1135|      0|				remove_rrset(NULL, pkt, msg, prev, &rrset);
 1136|      0|				continue;
 1137|      0|			}
 1138|  15.6k|		}
 1139|       |		
 1140|       |		/* skip DNAME records -- they will always be followed by a 
 1141|       |		 * synthesized CNAME, which will be relevant.
 1142|       |		 * FIXME: should this do something differently with DNAME 
 1143|       |		 * rrsets NOT in Section.ANSWER? */
 1144|       |		/* But since DNAME records are also subdomains of the zone,
 1145|       |		 * same check can be used */
 1146|       |
 1147|  67.5k|		if(!pkt_sub(pkt, rrset->dname, zonename)) {
  ------------------
  |  Branch (1147:6): [True: 64.9k, False: 2.61k]
  ------------------
 1148|  64.9k|			if(msg->an_rrsets == 0 && 
  ------------------
  |  Branch (1148:7): [True: 58.7k, False: 6.14k]
  ------------------
 1149|  58.7k|				rrset->type == LDNS_RR_TYPE_NS && 
  ------------------
  |  Branch (1149:5): [True: 2.51k, False: 56.2k]
  ------------------
 1150|  2.51k|				rrset->section == LDNS_SECTION_AUTHORITY &&
  ------------------
  |  Branch (1150:5): [True: 941, False: 1.57k]
  ------------------
 1151|    941|				FLAGS_GET_RCODE(msg->flags) == 
  ------------------
  |  |   74|    941|#define FLAGS_GET_RCODE(f) ((f) & 0xf)
  ------------------
  |  Branch (1151:5): [True: 174, False: 767]
  ------------------
 1152|    941|				LDNS_RCODE_NOERROR && !soa_in_auth(msg) &&
  ------------------
  |  Branch (1152:27): [True: 174, False: 0]
  ------------------
 1153|    174|				sub_of_pkt(pkt, zonename, rrset->dname)) {
  ------------------
  |  Branch (1153:5): [True: 174, False: 0]
  ------------------
 1154|       |				/* noerror, nodata and this NS rrset is above
 1155|       |				 * the zone. This is LAME! 
 1156|       |				 * Leave in the NS for lame classification. */
 1157|       |				/* remove everything from the additional
 1158|       |				 * (we dont want its glue that was approved
 1159|       |				 * during the normalize action) */
 1160|    174|				del_addi = 1;
 1161|  64.7k|			} else if(!env->cfg->harden_glue && (
  ------------------
  |  Branch (1161:14): [True: 64.7k, False: 0]
  ------------------
 1162|  64.7k|				rrset->type == LDNS_RR_TYPE_A ||
  ------------------
  |  Branch (1162:5): [True: 13.5k, False: 51.2k]
  ------------------
 1163|  51.2k|				rrset->type == LDNS_RR_TYPE_AAAA)) {
  ------------------
  |  Branch (1163:5): [True: 1.81k, False: 49.4k]
  ------------------
 1164|       |				/* store in cache! Since it is relevant
 1165|       |				 * (from normalize) it will be picked up 
 1166|       |				 * from the cache to be used later */
 1167|  15.3k|				store_rrset(pkt, msg, env, rrset);
 1168|  15.3k|				remove_rrset("sanitize: storing potential "
 1169|  15.3k|				"poison RRset:", pkt, msg, prev, &rrset);
 1170|  15.3k|				continue;
 1171|  49.4k|			} else {
 1172|  49.4k|				if(has_additional(rrset->type)) del_addi = 1;
  ------------------
  |  Branch (1172:8): [True: 7.26k, False: 42.1k]
  ------------------
 1173|  49.4k|				remove_rrset("sanitize: removing potential "
 1174|  49.4k|				"poison RRset:", pkt, msg, prev, &rrset);
 1175|  49.4k|				continue;
 1176|  49.4k|			}
 1177|  64.9k|		}
 1178|  2.79k|		if(rrset->type == LDNS_RR_TYPE_NS &&
  ------------------
  |  Branch (1178:6): [True: 362, False: 2.42k]
  ------------------
 1179|    362|			(rrset->section == LDNS_SECTION_AUTHORITY ||
  ------------------
  |  Branch (1179:5): [True: 243, False: 119]
  ------------------
 1180|    302|			rrset->section == LDNS_SECTION_ANSWER)) {
  ------------------
  |  Branch (1180:4): [True: 59, False: 60]
  ------------------
 1181|       |			/* If the type is NS, and we're in the
 1182|       |			 * answer or authority section, then
 1183|       |			 * store the dname so we can check
 1184|       |			 * against the glue records
 1185|       |			 * further down	*/
 1186|    302|			ns_rrset_dname = rrset->dname;
 1187|    302|		}
 1188|  2.79k|		if(del_addi && rrset->section == LDNS_SECTION_ADDITIONAL) {
  ------------------
  |  Branch (1188:6): [True: 1.12k, False: 1.67k]
  |  Branch (1188:18): [True: 329, False: 791]
  ------------------
 1189|    329|			remove_rrset("sanitize: removing potential "
 1190|    329|			"poison reference RRset:", pkt, msg, prev, &rrset);
 1191|    329|			continue;
 1192|    329|		}
 1193|       |		/* check if right hand side of NSEC is within zone */
 1194|  2.46k|		if(rrset->type == LDNS_RR_TYPE_NSEC &&
  ------------------
  |  Branch (1194:6): [True: 759, False: 1.70k]
  ------------------
 1195|    759|			sanitize_nsec_is_overreach(pkt, rrset, zonename)) {
  ------------------
  |  Branch (1195:4): [True: 512, False: 247]
  ------------------
 1196|    512|			remove_rrset("sanitize: removing overreaching NSEC "
 1197|    512|				"RRset:", pkt, msg, prev, &rrset);
 1198|    512|			continue;
 1199|    512|		}
 1200|  1.94k|		if(env->cfg->harden_unverified_glue && ns_rrset_dname &&
  ------------------
  |  Branch (1200:6): [True: 0, False: 1.94k]
  |  Branch (1200:42): [True: 0, False: 0]
  ------------------
 1201|      0|			rrset->section == LDNS_SECTION_ADDITIONAL &&
  ------------------
  |  Branch (1201:4): [True: 0, False: 0]
  ------------------
 1202|      0|			(rrset->type == LDNS_RR_TYPE_A || rrset->type == LDNS_RR_TYPE_AAAA) &&
  ------------------
  |  Branch (1202:5): [True: 0, False: 0]
  |  Branch (1202:38): [True: 0, False: 0]
  ------------------
 1203|      0|			!pkt_strict_sub(pkt, rrset->dname, ns_rrset_dname)) {
  ------------------
  |  Branch (1203:4): [True: 0, False: 0]
  ------------------
 1204|       |			/* We're in the additional section, looking
 1205|       |			 * at an A/AAAA rrset, have a previous
 1206|       |			 * delegation point and we notice that
 1207|       |			 * the glue records are NOT for strict
 1208|       |			 * subdomains of the delegation. So set a
 1209|       |			 * flag, recompute the hash for the rrset
 1210|       |			 * and write the A/AAAA record to cache.
 1211|       |			 * It'll be retrieved if we can't separately
 1212|       |			 * resolve the glue	*/
 1213|      0|			rrset->flags = PACKED_RRSET_UNVERIFIED_GLUE;
  ------------------
  |  |   72|      0|#define PACKED_RRSET_UNVERIFIED_GLUE 0x10
  ------------------
 1214|      0|			rrset->hash = pkt_hash_rrset(pkt, rrset->dname, rrset->type, rrset->rrset_class, rrset->flags);
 1215|      0|			store_rrset(pkt, msg, env, rrset);
 1216|      0|			remove_rrset("sanitize: storing potential "
 1217|      0|			"unverified glue reference RRset:", pkt, msg, prev, &rrset);
 1218|      0|			continue;
 1219|      0|		}
 1220|  1.94k|		prev = rrset;
 1221|  1.94k|		rrset = rrset->rrset_all_next;
 1222|  1.94k|	}
 1223|       |
 1224|       |	/* If the packet is empty now, but it was not before. And there
 1225|       |	 * was type NS in authority, then that indicates the answer is lame. */
 1226|  2.02k|	if(msg->rrset_first == NULL && pkt_before_NS) {
  ------------------
  |  Branch (1226:5): [True: 1.41k, False: 614]
  |  Branch (1226:33): [True: 84, False: 1.33k]
  ------------------
 1227|     84|		*msg_lame_empty = 1;
 1228|     84|		verbose(VERB_ALGO, "sanitize: empty message had referral to NS before, marked as lame");
 1229|  1.94k|	} else if(pkt_before_NS && msg->an_rrsets==0 &&
  ------------------
  |  Branch (1229:12): [True: 142, False: 1.80k]
  |  Branch (1229:29): [True: 142, False: 0]
  ------------------
 1230|    142|		!(msg->flags&BIT_AA) && !rdset) {
  ------------------
  |  |   70|    142|#define BIT_AA 0x0400
  ------------------
  |  Branch (1230:3): [True: 142, False: 0]
  |  Branch (1230:27): [True: 142, False: 0]
  ------------------
 1231|       |		/* If the packet is now a referral, not really a nodata,
 1232|       |		 * then if it was also with an empty answer section before,
 1233|       |		 * it is also lame. */
 1234|    142|		*msg_lame_referral = 1;
 1235|    142|		verbose(VERB_ALGO, "sanitize: message has referral not answer, marked as lame");
 1236|    142|	}
 1237|       |
 1238|  2.02k|	return 1;
 1239|  2.04k|}
iter_scrub.c:scrub_sanitize_rr_length:
  972|  20.5k|{
  973|  20.5k|	struct rr_parse* rr, *rr_prev = NULL;
  974|   364k|	for(rr = (*rrset)->rr_first; rr; rr = rr->next) {
  ------------------
  |  Branch (974:31): [True: 348k, False: 15.3k]
  ------------------
  975|       |
  976|       |		/* Sanity check for length of records
  977|       |		 * An A record should be 6 bytes only
  978|       |		 * (2 bytes for length and 4 for IPv4 addr)*/
  979|   348k|		if((*rrset)->type == LDNS_RR_TYPE_A && rr->size != 6 ) {
  ------------------
  |  Branch (979:6): [True: 340k, False: 7.99k]
  |  Branch (979:42): [True: 57.0k, False: 283k]
  ------------------
  980|  57.0k|			if(!*added_ede) {
  ------------------
  |  Branch (980:7): [True: 281, False: 56.7k]
  ------------------
  981|    281|				*added_ede = 1;
  982|    281|				errinf_ede(qstate, "sanitize: records of inappropriate length have been removed.",
  983|    281|					LDNS_EDE_OTHER);
  984|    281|			}
  985|  57.0k|			if(msgparse_rrset_remove_rr("sanitize: removing type A RR of inappropriate length:",
  ------------------
  |  Branch (985:7): [True: 3.74k, False: 53.2k]
  ------------------
  986|  57.0k|				pkt, *rrset, rr_prev, rr, NULL, 0)) {
  987|  3.74k|				remove_rrset("sanitize: removing type A RRset of inappropriate length:",
  988|  3.74k|					pkt, msg, prev, rrset);
  989|  3.74k|				return 1;
  990|  3.74k|			}
  991|  53.2k|			continue;
  992|  57.0k|		}
  993|       |
  994|       |		/* Sanity check for length of records
  995|       |		 * An AAAA record should be 18 bytes only
  996|       |		 * (2 bytes for length and 16 for IPv6 addr)*/
  997|   291k|		if((*rrset)->type == LDNS_RR_TYPE_AAAA && rr->size != 18 ) {
  ------------------
  |  Branch (997:6): [True: 7.99k, False: 283k]
  |  Branch (997:45): [True: 3.71k, False: 4.27k]
  ------------------
  998|  3.71k|			if(!*added_ede) {
  ------------------
  |  Branch (998:7): [True: 56, False: 3.66k]
  ------------------
  999|     56|				*added_ede = 1;
 1000|     56|				errinf_ede(qstate, "sanitize: records of inappropriate length have been removed.",
 1001|     56|					LDNS_EDE_OTHER);
 1002|     56|			}
 1003|  3.71k|			if(msgparse_rrset_remove_rr("sanitize: removing type AAAA RR of inappropriate length:",
  ------------------
  |  Branch (1003:7): [True: 1.45k, False: 2.26k]
  ------------------
 1004|  3.71k|				pkt, *rrset, rr_prev, rr, NULL, 0)) {
 1005|  1.45k|				remove_rrset("sanitize: removing type AAAA RRset of inappropriate length:",
 1006|  1.45k|					pkt, msg, prev, rrset);
 1007|  1.45k|				return 1;
 1008|  1.45k|			}
 1009|  2.26k|			continue;
 1010|  3.71k|		}
 1011|   288k|		rr_prev = rr;
 1012|   288k|	}
 1013|  15.3k|	return 0;
 1014|  20.5k|}
iter_scrub.c:store_rrset:
  903|  15.3k|{
  904|  15.3k|	struct ub_packed_rrset_key* k;
  905|  15.3k|	struct packed_rrset_data* d;
  906|  15.3k|	struct rrset_ref ref;
  907|  15.3k|	time_t now = *env->now;
  908|       |
  909|  15.3k|	k = alloc_special_obtain(env->alloc);
  910|  15.3k|	if(!k)
  ------------------
  |  Branch (910:5): [True: 0, False: 15.3k]
  ------------------
  911|      0|		return;
  912|  15.3k|	k->entry.data = NULL;
  913|  15.3k|	if(!parse_copy_decompress_rrset(pkt, msg, rrset, NULL, k)) {
  ------------------
  |  Branch (913:5): [True: 0, False: 15.3k]
  ------------------
  914|      0|		alloc_special_release(env->alloc, k);
  915|      0|		return;
  916|      0|	}
  917|  15.3k|	d = (struct packed_rrset_data*)k->entry.data;
  918|  15.3k|	packed_rrset_ttl_add(d, now);
  919|  15.3k|	ref.key = k;
  920|  15.3k|	ref.id = k->id;
  921|       |	/* if it was in the cache, ref updated */
  922|  15.3k|	rrset_cache_update_unlock(env->rrset_cache, &ref, env->alloc, now);
  923|  15.3k|}
iter_scrub.c:sanitize_nsec_is_overreach:
  934|    759|{
  935|    759|	struct rr_parse* rr;
  936|    759|	uint8_t* rhs;
  937|    759|	size_t len;
  938|    759|	log_assert(rrset->type == LDNS_RR_TYPE_NSEC);
  939|  2.45k|	for(rr = rrset->rr_first; rr; rr = rr->next) {
  ------------------
  |  Branch (939:28): [True: 2.21k, False: 247]
  ------------------
  940|  2.21k|		size_t pos = sldns_buffer_position(pkt);
  941|  2.21k|		size_t rhspos;
  942|  2.21k|		rhs = rr->ttl_data+4+2;
  943|  2.21k|		len = sldns_read_uint16(rr->ttl_data+4);
  944|  2.21k|		rhspos = rhs-sldns_buffer_begin(pkt);
  945|  2.21k|		sldns_buffer_set_position(pkt, rhspos);
  946|  2.21k|		if(pkt_dname_len(pkt) == 0) {
  ------------------
  |  Branch (946:6): [True: 77, False: 2.13k]
  ------------------
  947|       |			/* malformed */
  948|     77|			sldns_buffer_set_position(pkt, pos);
  949|     77|			return 1;
  950|     77|		}
  951|  2.13k|		if(sldns_buffer_position(pkt)-rhspos > len) {
  ------------------
  |  Branch (951:6): [True: 275, False: 1.85k]
  ------------------
  952|       |			/* outside of rdata boundaries */
  953|    275|			sldns_buffer_set_position(pkt, pos);
  954|    275|			return 1;
  955|    275|		}
  956|  1.85k|		sldns_buffer_set_position(pkt, pos);
  957|  1.85k|		if(!pkt_sub(pkt, rhs, zonename)) {
  ------------------
  |  Branch (957:6): [True: 160, False: 1.69k]
  ------------------
  958|       |			/* overreaching */
  959|    160|			return 1;
  960|    160|		}
  961|  1.85k|	}
  962|       |	/* all NSEC RRs OK */
  963|    247|	return 0;
  964|    759|}

rrset_cache_create:
   64|  4.66k|{
   65|  4.66k|	size_t slabs = (cfg?cfg->rrset_cache_slabs:HASH_DEFAULT_SLABS);
  ------------------
  |  |   49|      0|#define HASH_DEFAULT_SLABS 4
  ------------------
  |  Branch (65:18): [True: 4.66k, False: 0]
  ------------------
   66|  4.66k|	size_t startarray = HASH_DEFAULT_STARTARRAY;
  ------------------
  |  |  114|  4.66k|#define HASH_DEFAULT_STARTARRAY		1024 /* entries in array */
  ------------------
   67|  4.66k|	size_t maxmem = (cfg?cfg->rrset_cache_size:HASH_DEFAULT_MAXMEM);
  ------------------
  |  |  116|      0|#define HASH_DEFAULT_MAXMEM		4*1024*1024 /* bytes */
  ------------------
  |  Branch (67:19): [True: 4.66k, False: 0]
  ------------------
   68|       |
   69|  4.66k|	struct rrset_cache *r = (struct rrset_cache*)slabhash_create(slabs,
   70|  4.66k|		startarray, maxmem, ub_rrset_sizefunc, ub_rrset_compare,
   71|  4.66k|		ub_rrset_key_delete, rrset_data_delete, alloc);
   72|  4.66k|	if(!r)
  ------------------
  |  Branch (72:5): [True: 0, False: 4.66k]
  ------------------
   73|      0|		return NULL;
   74|  4.66k|	slabhash_setmarkdel(&r->table, &rrset_markdel);
   75|  4.66k|	return r;
   76|  4.66k|}
rrset_cache_delete:
   79|  4.66k|{
   80|  4.66k|	if(!r) 
  ------------------
  |  Branch (80:5): [True: 0, False: 4.66k]
  ------------------
   81|      0|		return;
   82|  4.66k|	slabhash_delete(&r->table);
   83|       |	/* slabhash delete also does free(r), since table is first in struct*/
   84|  4.66k|}
rrset_cache_update:
  210|  15.3k|{
  211|  15.3k|	struct lruhash_entry* e;
  212|  15.3k|	struct ub_packed_rrset_key* k = ref->key;
  213|  15.3k|	hashvalue_type h = k->entry.hash;
  214|  15.3k|	uint16_t rrset_type = ntohs(k->rk.type);
  215|  15.3k|	int equal = 0;
  216|  15.3k|	log_assert(ref->id != 0 && k->id != 0);
  217|  15.3k|	log_assert(k->rk.dname != NULL);
  218|  15.3k|	if((k->rk.flags&PACKED_RRSET_0TTL_GRACE) !=0) {
  ------------------
  |  |   76|  15.3k|#define PACKED_RRSET_0TTL_GRACE 0x40
  ------------------
  |  Branch (218:5): [True: 0, False: 15.3k]
  ------------------
  219|      0|		log_nametypeclass(VERB_ALGO, "rrset store of PACKED_RRSET_0TTL_GRACE rrset skipped", k->rk.dname, rrset_type, ntohs(k->rk.rrset_class));
  220|      0|		ub_packed_rrset_parsedelete(k, alloc);
  221|      0|		return 0; /* Do not store 0TTL items after apply of
  222|       |			the grace ttl amount.
  223|       |			This means the ref was not changed by the call. */
  224|      0|	}
  225|       |	/* looks up item with a readlock - no editing! */
  226|  15.3k|	if((e=slabhash_lookup(&r->table, h, k, 0)) != 0) {
  ------------------
  |  Branch (226:5): [True: 0, False: 15.3k]
  ------------------
  227|       |		/* return id and key as they will be used in the cache
  228|       |		 * since the lruhash_insert, if item already exists, deallocs
  229|       |		 * the passed key in favor of the already stored key.
  230|       |		 * because of the small gap (see below) this key ptr and id
  231|       |		 * may prove later to be already deleted, which is no problem
  232|       |		 * as it only makes a cache miss. 
  233|       |		 */
  234|      0|		ref->key = (struct ub_packed_rrset_key*)e->key;
  235|      0|		ref->id = ref->key->id;
  236|      0|		equal = rrsetdata_equal((struct packed_rrset_data*)k->entry.
  237|      0|			data, (struct packed_rrset_data*)e->data);
  238|      0|		if(!need_to_update_rrset(k->entry.data, e->data, timenow,
  ------------------
  |  Branch (238:6): [True: 0, False: 0]
  ------------------
  239|      0|			equal, (rrset_type==LDNS_RR_TYPE_NS),
  240|      0|			(rrset_type==LDNS_RR_TYPE_A || rrset_type==LDNS_RR_TYPE_AAAA))) {
  ------------------
  |  Branch (240:5): [True: 0, False: 0]
  |  Branch (240:35): [True: 0, False: 0]
  ------------------
  241|       |			/* cache is superior, return that value */
  242|      0|			if(equal) {
  ------------------
  |  Branch (242:7): [True: 0, False: 0]
  ------------------
  243|      0|				ub_packed_rrset_parsedelete(k, alloc);
  244|       |				/* return readlocked item. */
  245|      0|				return 2;
  246|      0|			}
  247|      0|			lock_rw_unlock(&e->lock);
  ------------------
  |  |  122|      0|#define lock_rw_unlock(lock) LOCKRET(pthread_rwlock_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  248|      0|			ub_packed_rrset_parsedelete(k, alloc);
  249|      0|			return 1;
  250|      0|		}
  251|      0|		lock_rw_unlock(&e->lock);
  ------------------
  |  |  122|      0|#define lock_rw_unlock(lock) LOCKRET(pthread_rwlock_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  252|       |		/* Go on and insert the passed item.
  253|       |		 * small gap here, where entry is not locked.
  254|       |		 * possibly entry is updated with something else.
  255|       |		 * we then overwrite that with our data.
  256|       |		 * this is just too bad, its cache anyway. */
  257|       |		/* use insert to update entry to manage lruhash
  258|       |		 * cache size values nicely. */
  259|      0|	}
  260|  15.3k|	log_assert(ref->key->id != 0);
  261|  15.3k|	slabhash_insert(&r->table, h, &k->entry, k->entry.data, alloc);
  262|  15.3k|	if(e) {
  ------------------
  |  Branch (262:5): [True: 0, False: 15.3k]
  ------------------
  263|       |		/* For NSEC, NSEC3, DNAME, when rdata is updated, update 
  264|       |		 * the ID number so that proofs in message cache are 
  265|       |		 * invalidated */
  266|      0|		if((rrset_type == LDNS_RR_TYPE_NSEC 
  ------------------
  |  Branch (266:7): [True: 0, False: 0]
  ------------------
  267|      0|			|| rrset_type == LDNS_RR_TYPE_NSEC3
  ------------------
  |  Branch (267:7): [True: 0, False: 0]
  ------------------
  268|      0|			|| rrset_type == LDNS_RR_TYPE_DNAME) && !equal) {
  ------------------
  |  Branch (268:7): [True: 0, False: 0]
  |  Branch (268:44): [True: 0, False: 0]
  ------------------
  269|      0|			rrset_update_id(ref, alloc);
  270|      0|		}
  271|      0|		return 1;
  272|      0|	}
  273|  15.3k|	return 0;
  274|  15.3k|}
rrset_cache_update_unlock:
  278|  15.3k|{
  279|  15.3k|	int ret = rrset_cache_update(r, ref, alloc, timenow);
  280|  15.3k|	if(ret == 2) {
  ------------------
  |  Branch (280:5): [True: 0, False: 15.3k]
  ------------------
  281|      0|		lock_rw_unlock(&ref->key->entry.lock);
  ------------------
  |  |  122|      0|#define lock_rw_unlock(lock) LOCKRET(pthread_rwlock_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  282|      0|	}
  283|  15.3k|}

sldns_rr_descript:
  647|  1.65M|{
  648|  1.65M|	size_t i;
  649|  1.65M|	if (type < LDNS_RDATA_FIELD_DESCRIPTORS_COMMON) {
  ------------------
  |  |   41|  1.65M|#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 259
  ------------------
  |  Branch (649:6): [True: 1.55M, False: 97.7k]
  ------------------
  650|  1.55M|		return &rdata_field_descriptors[type];
  651|  1.55M|	} else {
  652|       |		/* because not all array index equals type code */
  653|  97.7k|		for (i = LDNS_RDATA_FIELD_DESCRIPTORS_COMMON;
  ------------------
  |  |   41|  97.7k|#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 259
  ------------------
  654|   582k|		     i < LDNS_RDATA_FIELD_DESCRIPTORS_COUNT;
  ------------------
  |  |  643|   582k|	(sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0]))
  ------------------
  |  Branch (654:8): [True: 488k, False: 94.6k]
  ------------------
  655|   488k|		     i++) {
  656|   488k|		        if (rdata_field_descriptors[i]._type == type) {
  ------------------
  |  Branch (656:15): [True: 3.08k, False: 485k]
  ------------------
  657|  3.08k|		     		return &rdata_field_descriptors[i];
  658|  3.08k|			}
  659|   488k|		}
  660|  94.6k|                return &rdata_field_descriptors[0];
  661|  97.7k|	}
  662|  1.65M|}

sldns_buffer_new:
   20|  4.66k|{
   21|  4.66k|	sldns_buffer *buffer = (sldns_buffer*)malloc(sizeof(sldns_buffer));
   22|       |
   23|  4.66k|	if (!buffer) {
  ------------------
  |  Branch (23:6): [True: 0, False: 4.66k]
  ------------------
   24|      0|		return NULL;
   25|      0|	}
   26|       |	
   27|  4.66k|	buffer->_data = (uint8_t *) malloc(capacity);
   28|  4.66k|	if (!buffer->_data) {
  ------------------
  |  Branch (28:6): [True: 0, False: 4.66k]
  ------------------
   29|      0|		free(buffer);
   30|      0|		return NULL;
   31|      0|	}
   32|       |	
   33|  4.66k|	buffer->_position = 0;
   34|  4.66k|	buffer->_limit = buffer->_capacity = capacity;
   35|  4.66k|	buffer->_fixed = 0;
   36|  4.66k|	buffer->_status_err = 0;
   37|       |	
   38|  4.66k|	sldns_buffer_invariant(buffer);
   39|       |	
   40|  4.66k|	return buffer;
   41|  4.66k|}
sldns_buffer_new_frm_data:
   45|  4.66k|{
   46|  4.66k|	assert(data != NULL);
   47|       |
   48|  4.66k|	buffer->_position = 0; 
   49|  4.66k|	buffer->_limit = buffer->_capacity = size;
   50|  4.66k|	buffer->_fixed = 0;
   51|  4.66k|	if (!buffer->_fixed && buffer->_data)
  ------------------
  |  Branch (51:6): [True: 4.66k, False: 0]
  |  Branch (51:25): [True: 4.66k, False: 0]
  ------------------
   52|  4.66k|		free(buffer->_data);
   53|  4.66k|	buffer->_data = malloc(size);
   54|  4.66k|	if(!buffer->_data) {
  ------------------
  |  Branch (54:5): [True: 0, False: 4.66k]
  ------------------
   55|      0|		buffer->_status_err = 1;
   56|      0|		return;
   57|      0|	}
   58|  4.66k|	memcpy(buffer->_data, data, size);
   59|  4.66k|	buffer->_status_err = 0;
   60|       |	
   61|  4.66k|	sldns_buffer_invariant(buffer);
   62|  4.66k|}
sldns_buffer_free:
  139|  4.66k|{
  140|  4.66k|	if (!buffer) {
  ------------------
  |  Branch (140:6): [True: 0, False: 4.66k]
  ------------------
  141|      0|		return;
  142|      0|	}
  143|       |
  144|  4.66k|	if (!buffer->_fixed)
  ------------------
  |  Branch (144:6): [True: 4.66k, False: 0]
  ------------------
  145|  4.66k|		free(buffer->_data);
  146|       |
  147|  4.66k|	free(buffer);
  148|  4.66k|}

dname.c:sldns_buffer_remaining:
  394|  2.74M|{
  395|  2.74M|	return sldns_buffer_remaining_at(buffer, buffer->_position);
  396|  2.74M|}
dname.c:sldns_buffer_remaining_at:
  380|  2.74M|{
  381|  2.74M|	sldns_buffer_invariant(buffer);
  382|  2.74M|	assert(at <= buffer->_limit);
  383|  2.74M|	return at < buffer->_limit ? buffer->_limit - at : 0;
  ------------------
  |  Branch (383:9): [True: 2.74M, False: 1.41k]
  ------------------
  384|  2.74M|}
dname.c:sldns_buffer_invariant:
  143|  2.74M|{
  144|  2.74M|}
dname.c:sldns_buffer_read_u8:
  638|  2.50M|{
  639|  2.50M|	uint8_t result = sldns_buffer_read_u8_at(buffer, buffer->_position);
  640|  2.50M|	buffer->_position += sizeof(uint8_t);
  641|  2.50M|	return result;
  642|  2.50M|}
dname.c:sldns_buffer_read_u8_at:
  626|  2.50M|{
  627|       |	assert(sldns_buffer_available_at(buffer, at, sizeof(uint8_t)));
  628|  2.50M|	return buffer->_data[at];
  629|  2.50M|}
dname.c:sldns_buffer_skip:
  259|   239k|{
  260|       |	assert(buffer->_position + count <= buffer->_limit);
  261|   239k|	buffer->_position += count;
  262|   239k|}
dname.c:sldns_buffer_limit:
  271|   432k|{
  272|   432k|	return buffer->_limit;
  273|   432k|}
dname.c:sldns_buffer_at:
  331|   223k|{
  332|       |	assert(at <= buffer->_limit);
  333|   223k|	return buffer->_data + at;
  334|   223k|}
dname.c:sldns_buffer_position:
  233|  80.4k|{
  234|  80.4k|	return buffer->_position;
  235|  80.4k|}
dname.c:sldns_buffer_set_position:
  245|   285k|{
  246|       |	assert(mark <= buffer->_limit);
  247|   285k|	buffer->_position = mark;
  248|   285k|}
msgparse.c:sldns_buffer_remaining:
  394|  8.77M|{
  395|  8.77M|	return sldns_buffer_remaining_at(buffer, buffer->_position);
  396|  8.77M|}
msgparse.c:sldns_buffer_remaining_at:
  380|  8.77M|{
  381|  8.77M|	sldns_buffer_invariant(buffer);
  382|  8.77M|	assert(at <= buffer->_limit);
  383|  8.77M|	return at < buffer->_limit ? buffer->_limit - at : 0;
  ------------------
  |  Branch (383:9): [True: 8.77M, False: 3.26k]
  ------------------
  384|  8.77M|}
msgparse.c:sldns_buffer_invariant:
  143|  8.77M|{
  144|  8.77M|}
msgparse.c:sldns_buffer_read:
  613|  1.72M|{
  614|  1.72M|	sldns_buffer_read_at(buffer, buffer->_position, data, count);
  615|  1.72M|	buffer->_position += count;
  616|  1.72M|}
msgparse.c:sldns_buffer_read_at:
  600|  1.72M|{
  601|       |	assert(sldns_buffer_available_at(buffer, at, count));
  602|  1.72M|	memcpy(data, buffer->_data + at, count);
  603|  1.72M|}
msgparse.c:sldns_buffer_read_u16:
  664|  8.93M|{
  665|  8.93M|	uint16_t result = sldns_buffer_read_u16_at(buffer, buffer->_position);
  666|  8.93M|	buffer->_position += sizeof(uint16_t);
  667|  8.93M|	return result;
  668|  8.93M|}
msgparse.c:sldns_buffer_read_u16_at:
  652|  8.93M|{
  653|       |	assert(sldns_buffer_available_at(buffer, at, sizeof(uint16_t)));
  654|  8.93M|	return sldns_read_uint16(buffer->_data + at);
  655|  8.93M|}
msgparse.c:sldns_buffer_limit:
  271|  13.9k|{
  272|  13.9k|	return buffer->_limit;
  273|  13.9k|}
msgparse.c:sldns_buffer_at:
  331|  7.90M|{
  332|       |	assert(at <= buffer->_limit);
  333|  7.90M|	return buffer->_data + at;
  334|  7.90M|}
msgparse.c:sldns_buffer_position:
  233|  5.01M|{
  234|  5.01M|	return buffer->_position;
  235|  5.01M|}
msgparse.c:sldns_buffer_skip:
  259|  8.46M|{
  260|       |	assert(buffer->_position + count <= buffer->_limit);
  261|  8.46M|	buffer->_position += count;
  262|  8.46M|}
msgparse.c:sldns_buffer_set_position:
  245|  9.34M|{
  246|       |	assert(mark <= buffer->_limit);
  247|  9.34M|	buffer->_position = mark;
  248|  9.34M|}
msgparse.c:sldns_read_uint16:
   36|  8.93M|{
   37|       |#ifdef ALLOW_UNALIGNED_ACCESSES
   38|       |        return ntohs(*(const uint16_t *) src);
   39|       |#else
   40|  8.93M|        const uint8_t *p = (const uint8_t *) src;
   41|  8.93M|        return ((uint16_t) p[0] << 8) | (uint16_t) p[1];
   42|  8.93M|#endif
   43|  8.93M|}
msgparse.c:sldns_buffer_begin:
  344|  4.57M|{
  345|  4.57M|	return sldns_buffer_at(buffer, 0);
  346|  4.57M|}
msgparse.c:sldns_buffer_read_u8:
  638|  17.8k|{
  639|  17.8k|	uint8_t result = sldns_buffer_read_u8_at(buffer, buffer->_position);
  640|  17.8k|	buffer->_position += sizeof(uint8_t);
  641|  17.8k|	return result;
  642|  17.8k|}
msgparse.c:sldns_buffer_read_u8_at:
  626|  17.8k|{
  627|       |	assert(sldns_buffer_available_at(buffer, at, sizeof(uint8_t)));
  628|  17.8k|	return buffer->_data[at];
  629|  17.8k|}
msgparse.c:sldns_buffer_current:
  367|  3.31M|{
  368|  3.31M|	return sldns_buffer_at(buffer, buffer->_position);
  369|  3.31M|}
msgreply.c:sldns_read_uint32:
   47|   298k|{
   48|       |#ifdef ALLOW_UNALIGNED_ACCESSES
   49|       |        return ntohl(*(const uint32_t *) src);
   50|       |#else
   51|   298k|        const uint8_t *p = (const uint8_t *) src;
   52|   298k|        return (  ((uint32_t) p[0] << 24)
   53|   298k|                | ((uint32_t) p[1] << 16)
   54|   298k|                | ((uint32_t) p[2] << 8)
   55|   298k|                |  (uint32_t) p[3]);
   56|   298k|#endif
   57|   298k|}
msgreply.c:sldns_buffer_set_position:
  245|   318k|{
  246|       |	assert(mark <= buffer->_limit);
  247|   318k|	buffer->_position = mark;
  248|   318k|}
msgreply.c:sldns_buffer_begin:
  344|   298k|{
  345|   298k|	return sldns_buffer_at(buffer, 0);
  346|   298k|}
msgreply.c:sldns_buffer_at:
  331|   668k|{
  332|       |	assert(at <= buffer->_limit);
  333|   668k|	return buffer->_data + at;
  334|   668k|}
msgreply.c:sldns_read_uint16:
   36|   298k|{
   37|       |#ifdef ALLOW_UNALIGNED_ACCESSES
   38|       |        return ntohs(*(const uint16_t *) src);
   39|       |#else
   40|   298k|        const uint8_t *p = (const uint8_t *) src;
   41|   298k|        return ((uint16_t) p[0] << 8) | (uint16_t) p[1];
   42|   298k|#endif
   43|   298k|}
msgreply.c:sldns_buffer_position:
  233|  40.6k|{
  234|  40.6k|	return buffer->_position;
  235|  40.6k|}
msgreply.c:sldns_buffer_skip:
  259|  71.1k|{
  260|       |	assert(buffer->_position + count <= buffer->_limit);
  261|  71.1k|	buffer->_position += count;
  262|  71.1k|}
msgreply.c:sldns_buffer_current:
  367|   370k|{
  368|   370k|	return sldns_buffer_at(buffer, buffer->_position);
  369|   370k|}
msgreply.c:sldns_buffer_remaining:
  394|   298k|{
  395|   298k|	return sldns_buffer_remaining_at(buffer, buffer->_position);
  396|   298k|}
msgreply.c:sldns_buffer_remaining_at:
  380|   298k|{
  381|   298k|	sldns_buffer_invariant(buffer);
  382|   298k|	assert(at <= buffer->_limit);
  383|   298k|	return at < buffer->_limit ? buffer->_limit - at : 0;
  ------------------
  |  Branch (383:9): [True: 298k, False: 0]
  ------------------
  384|   298k|}
msgreply.c:sldns_buffer_invariant:
  143|   298k|{
  144|   298k|}
msgreply.c:sldns_buffer_read_u16:
  664|   298k|{
  665|   298k|	uint16_t result = sldns_buffer_read_u16_at(buffer, buffer->_position);
  666|   298k|	buffer->_position += sizeof(uint16_t);
  667|   298k|	return result;
  668|   298k|}
msgreply.c:sldns_buffer_read_u16_at:
  652|   298k|{
  653|       |	assert(sldns_buffer_available_at(buffer, at, sizeof(uint16_t)));
  654|   298k|	return sldns_read_uint16(buffer->_data + at);
  655|   298k|}
iter_scrub.c:sldns_buffer_position:
  233|  6.20k|{
  234|  6.20k|	return buffer->_position;
  235|  6.20k|}
iter_scrub.c:sldns_buffer_set_position:
  245|  8.14k|{
  246|       |	assert(mark <= buffer->_limit);
  247|  8.14k|	buffer->_position = mark;
  248|  8.14k|}
iter_scrub.c:sldns_buffer_begin:
  344|  4.07k|{
  345|  4.07k|	return sldns_buffer_at(buffer, 0);
  346|  4.07k|}
iter_scrub.c:sldns_buffer_at:
  331|  4.07k|{
  332|       |	assert(at <= buffer->_limit);
  333|  4.07k|	return buffer->_data + at;
  334|  4.07k|}
iter_scrub.c:sldns_read_uint16:
   36|  4.07k|{
   37|       |#ifdef ALLOW_UNALIGNED_ACCESSES
   38|       |        return ntohs(*(const uint16_t *) src);
   39|       |#else
   40|  4.07k|        const uint8_t *p = (const uint8_t *) src;
   41|  4.07k|        return ((uint16_t) p[0] << 8) | (uint16_t) p[1];
   42|  4.07k|#endif
   43|  4.07k|}
sbuffer.c:sldns_buffer_invariant:
  143|  9.33k|{
  144|  9.33k|}

alloc_init:
  105|  4.66k|{
  106|  4.66k|	memset(alloc, 0, sizeof(*alloc));
  107|  4.66k|	alloc->super = super;
  108|  4.66k|	alloc->thread_num = thread_num;
  109|  4.66k|	alloc->next_id = (uint64_t)thread_num; 	/* in steps, so that type */
  110|  4.66k|	alloc->next_id <<= THRNUM_SHIFT; 	/* of *_id is used. */
  ------------------
  |  |   51|  4.66k|#define THRNUM_SHIFT	48	/* for 65k threads, 2^48 rrsets per thr. */
  ------------------
  111|  4.66k|	alloc->last_id = 1; 			/* so no 64bit constants, */
  112|  4.66k|	alloc->last_id <<= THRNUM_SHIFT; 	/* or implicit 'int' ops. */
  ------------------
  |  |   51|  4.66k|#define THRNUM_SHIFT	48	/* for 65k threads, 2^48 rrsets per thr. */
  ------------------
  113|  4.66k|	alloc->last_id -= 1; 			/* for compiler portability. */
  114|  4.66k|	alloc->last_id |= alloc->next_id;
  115|  4.66k|	alloc->next_id += 1;			/* because id=0 is special. */
  116|  4.66k|	alloc->max_reg_blocks = 100;
  117|  4.66k|	alloc->num_reg_blocks = 0;
  118|  4.66k|	alloc->reg_list = NULL;
  119|  4.66k|	alloc->cleanup = NULL;
  120|  4.66k|	alloc->cleanup_arg = NULL;
  121|  4.66k|	if(alloc->super)
  ------------------
  |  Branch (121:5): [True: 0, False: 4.66k]
  ------------------
  122|      0|		prealloc_blocks(alloc, alloc->max_reg_blocks);
  123|  4.66k|	if(!alloc->super) {
  ------------------
  |  Branch (123:5): [True: 4.66k, False: 0]
  ------------------
  124|  4.66k|		lock_quick_init(&alloc->lock);
  ------------------
  |  |  144|  4.66k|#define lock_quick_init(lock) LOCKRET(pthread_spin_init(lock, PTHREAD_PROCESS_PRIVATE))
  |  |  ------------------
  |  |  |  |   67|  4.66k|#define LOCKRET(func) do {\
  |  |  |  |   68|  4.66k|	int lockret_err;		\
  |  |  |  |   69|  4.66k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 4.66k]
  |  |  |  |  ------------------
  |  |  |  |   70|  4.66k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  4.66k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 4.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  125|  4.66k|		lock_protect(&alloc->lock, alloc, sizeof(*alloc));
  126|  4.66k|	}
  127|  4.66k|}
alloc_clear:
  161|  4.66k|{
  162|  4.66k|	alloc_special_type* p;
  163|  4.66k|	struct regional* r, *nr;
  164|  4.66k|	if(!alloc)
  ------------------
  |  Branch (164:5): [True: 0, False: 4.66k]
  ------------------
  165|      0|		return;
  166|  4.66k|	if(!alloc->super) {
  ------------------
  |  Branch (166:5): [True: 4.66k, False: 0]
  ------------------
  167|  4.66k|		lock_quick_destroy(&alloc->lock);
  ------------------
  |  |  145|  4.66k|#define lock_quick_destroy(lock) LOCKRET(pthread_spin_destroy(lock))
  |  |  ------------------
  |  |  |  |   67|  4.66k|#define LOCKRET(func) do {\
  |  |  |  |   68|  4.66k|	int lockret_err;		\
  |  |  |  |   69|  4.66k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 4.66k]
  |  |  |  |  ------------------
  |  |  |  |   70|  4.66k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  4.66k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 4.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  168|  4.66k|	}
  169|  4.66k|	if(alloc->super && alloc->quar) {
  ------------------
  |  Branch (169:5): [True: 0, False: 4.66k]
  |  Branch (169:21): [True: 0, False: 0]
  ------------------
  170|       |		/* push entire list into super */
  171|      0|		p = alloc->quar;
  172|      0|		while(alloc_special_next(p)) /* find last */
  ------------------
  |  |   60|      0|#define alloc_special_next(x) ((alloc_special_type*)((x)->entry.overflow_next))
  |  |  ------------------
  |  |  |  Branch (60:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  173|      0|			p = alloc_special_next(p);
  ------------------
  |  |   60|      0|#define alloc_special_next(x) ((alloc_special_type*)((x)->entry.overflow_next))
  ------------------
  174|      0|		lock_quick_lock(&alloc->super->lock);
  ------------------
  |  |  146|      0|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|      0|		alloc_set_special_next(p, alloc->super->quar);
  ------------------
  |  |   63|      0|	((x)->entry.overflow_next) = (struct lruhash_entry*)(y);
  ------------------
  176|      0|		alloc->super->quar = alloc->quar;
  177|      0|		alloc->super->num_quar += alloc->num_quar;
  178|      0|		lock_quick_unlock(&alloc->super->lock);
  ------------------
  |  |  147|      0|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|  4.66k|	} else {
  180|  4.66k|		alloc_clear_special_list(alloc);
  181|  4.66k|	}
  182|  4.66k|	alloc->quar = 0;
  183|  4.66k|	alloc->num_quar = 0;
  184|  4.66k|	r = alloc->reg_list;
  185|  4.66k|	while(r) {
  ------------------
  |  Branch (185:8): [True: 0, False: 4.66k]
  ------------------
  186|      0|		nr = (struct regional*)r->next;
  187|      0|		free(r);
  188|      0|		r = nr;
  189|      0|	}
  190|       |	alloc->reg_list = NULL;
  191|  4.66k|	alloc->num_reg_blocks = 0;
  192|  4.66k|}
alloc_get_id:
  196|  15.3k|{
  197|  15.3k|	uint64_t id = alloc->next_id++;
  198|  15.3k|	if(id == alloc->last_id) {
  ------------------
  |  Branch (198:5): [True: 0, False: 15.3k]
  ------------------
  199|      0|		log_warn("rrset alloc: out of 64bit ids. Clearing cache.");
  200|      0|		fptr_ok(fptr_whitelist_alloc_cleanup(alloc->cleanup));
  ------------------
  |  |   71|      0|	do { if(!(x)) \
  |  |  ------------------
  |  |  |  Branch (71:10): [True: 0, False: 0]
  |  |  ------------------
  |  |   72|      0|		fatal_exit("%s:%d: %s: pointer whitelist %s failed", \
  |  |   73|      0|		__FILE__, __LINE__, __func__, #x); \
  |  |   74|      0|	} while(0);
  |  |  ------------------
  |  |  |  Branch (74:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  201|      0|		(*alloc->cleanup)(alloc->cleanup_arg);
  202|       |
  203|       |		/* start back at first number */   	/* like in alloc_init*/
  204|      0|		alloc->next_id = (uint64_t)alloc->thread_num; 	
  205|      0|		alloc->next_id <<= THRNUM_SHIFT; 	/* in steps for comp. */
  ------------------
  |  |   51|      0|#define THRNUM_SHIFT	48	/* for 65k threads, 2^48 rrsets per thr. */
  ------------------
  206|      0|		alloc->next_id += 1;			/* portability. */
  207|       |		/* and generate new and safe id */
  208|      0|		id = alloc->next_id++;
  209|      0|	}
  210|  15.3k|	return id;
  211|  15.3k|}
alloc_special_obtain:
  215|  15.3k|{
  216|  15.3k|	alloc_special_type* p;
  217|  15.3k|	log_assert(alloc);
  218|       |	/* see if in local cache */
  219|  15.3k|	if(alloc->quar) {
  ------------------
  |  Branch (219:5): [True: 13.5k, False: 1.79k]
  ------------------
  220|  13.5k|		p = alloc->quar;
  221|  13.5k|		alloc->quar = alloc_special_next(p);
  ------------------
  |  |   60|  13.5k|#define alloc_special_next(x) ((alloc_special_type*)((x)->entry.overflow_next))
  ------------------
  222|  13.5k|		alloc->num_quar--;
  223|  13.5k|		p->id = alloc_get_id(alloc);
  224|  13.5k|		return p;
  225|  13.5k|	}
  226|       |	/* see if in global cache */
  227|  1.79k|	if(alloc->super) {
  ------------------
  |  Branch (227:5): [True: 0, False: 1.79k]
  ------------------
  228|       |		/* could maybe grab alloc_max/2 entries in one go,
  229|       |		 * but really, isn't that just as fast as this code? */
  230|      0|		lock_quick_lock(&alloc->super->lock);
  ------------------
  |  |  146|      0|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|      0|		if((p = alloc->super->quar)) {
  ------------------
  |  Branch (231:6): [True: 0, False: 0]
  ------------------
  232|      0|			alloc->super->quar = alloc_special_next(p);
  ------------------
  |  |   60|      0|#define alloc_special_next(x) ((alloc_special_type*)((x)->entry.overflow_next))
  ------------------
  233|      0|			alloc->super->num_quar--;
  234|      0|		}
  235|      0|		lock_quick_unlock(&alloc->super->lock);
  ------------------
  |  |  147|      0|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|      0|		if(p) {
  ------------------
  |  Branch (236:6): [True: 0, False: 0]
  ------------------
  237|      0|			p->id = alloc_get_id(alloc);
  238|      0|			return p;
  239|      0|		}
  240|      0|	}
  241|       |	/* allocate new */
  242|  1.79k|	prealloc_setup(alloc);
  243|  1.79k|	if(!(p = (alloc_special_type*)malloc(sizeof(alloc_special_type)))) {
  ------------------
  |  Branch (243:5): [True: 0, False: 1.79k]
  ------------------
  244|      0|		log_err("alloc_special_obtain: out of memory");
  245|      0|		return NULL;
  246|      0|	}
  247|  1.79k|	alloc_setup_special(p);
  248|  1.79k|	p->id = alloc_get_id(alloc);
  249|  1.79k|	return p;
  250|  1.79k|}
alloc_special_release:
  280|  15.3k|{
  281|  15.3k|	log_assert(alloc);
  282|  15.3k|	if(!mem)
  ------------------
  |  Branch (282:5): [True: 0, False: 15.3k]
  ------------------
  283|      0|		return;
  284|  15.3k|	if(!alloc->super) { 
  ------------------
  |  Branch (284:5): [True: 15.3k, False: 0]
  ------------------
  285|  15.3k|		lock_quick_lock(&alloc->lock); /* superalloc needs locking */
  ------------------
  |  |  146|  15.3k|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|  15.3k|	}
  287|       |
  288|  15.3k|	alloc_special_clean(mem);
  ------------------
  |  |   58|  15.3k|#define alloc_special_clean(x) (x)->id = 0;
  ------------------
  289|  15.3k|	if(alloc->super && alloc->num_quar >= ALLOC_SPECIAL_MAX) {
  ------------------
  |  |   66|      0|#define ALLOC_SPECIAL_MAX 10
  ------------------
  |  Branch (289:5): [True: 0, False: 15.3k]
  |  Branch (289:21): [True: 0, False: 0]
  ------------------
  290|       |		/* push it to the super structure */
  291|      0|		pushintosuper(alloc, mem);
  292|      0|		return;
  293|      0|	}
  294|       |
  295|  15.3k|	alloc_set_special_next(mem, alloc->quar);
  ------------------
  |  |   63|  15.3k|	((x)->entry.overflow_next) = (struct lruhash_entry*)(y);
  ------------------
  296|  15.3k|	alloc->quar = mem;
  297|  15.3k|	alloc->num_quar++;
  298|  15.3k|	if(!alloc->super) {
  ------------------
  |  Branch (298:5): [True: 15.3k, False: 0]
  ------------------
  299|  15.3k|		lock_quick_unlock(&alloc->lock);
  ------------------
  |  |  147|  15.3k|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  300|  15.3k|	}
  301|  15.3k|}
alloc.c:alloc_clear_special_list:
  132|  4.66k|{
  133|  4.66k|	alloc_special_type* p, *np;
  134|       |	/* free */
  135|  4.66k|	p = alloc->quar;
  136|  24.4k|	while(p) {
  ------------------
  |  Branch (136:8): [True: 19.7k, False: 4.66k]
  ------------------
  137|  19.7k|		np = alloc_special_next(p);
  ------------------
  |  |   60|  19.7k|#define alloc_special_next(x) ((alloc_special_type*)((x)->entry.overflow_next))
  ------------------
  138|       |		/* deinit special type */
  139|  19.7k|		lock_rw_destroy(&p->entry.lock);
  ------------------
  |  |  119|  19.7k|#define lock_rw_destroy(lock) LOCKRET(pthread_rwlock_destroy(lock))
  |  |  ------------------
  |  |  |  |   67|  19.7k|#define LOCKRET(func) do {\
  |  |  |  |   68|  19.7k|	int lockret_err;		\
  |  |  |  |   69|  19.7k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 19.7k]
  |  |  |  |  ------------------
  |  |  |  |   70|  19.7k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  19.7k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 19.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  140|  19.7k|		free(p);
  141|  19.7k|		p = np;
  142|  19.7k|	}
  143|  4.66k|}
alloc.c:prealloc_setup:
   68|  1.79k|{
   69|  1.79k|	alloc_special_type* p;
   70|  1.79k|	int i;
   71|  19.7k|	for(i=0; i<ALLOC_SPECIAL_MAX; i++) {
  ------------------
  |  |   66|  19.7k|#define ALLOC_SPECIAL_MAX 10
  ------------------
  |  Branch (71:11): [True: 17.9k, False: 1.79k]
  ------------------
   72|  17.9k|		if(!(p = (alloc_special_type*)malloc(
  ------------------
  |  Branch (72:6): [True: 0, False: 17.9k]
  ------------------
   73|  17.9k|			sizeof(alloc_special_type)))) {
   74|      0|			log_err("prealloc: out of memory");
   75|      0|			return;
   76|      0|		}
   77|  17.9k|		alloc_setup_special(p);
   78|  17.9k|		alloc_set_special_next(p, alloc->quar);
  ------------------
  |  |   63|  17.9k|	((x)->entry.overflow_next) = (struct lruhash_entry*)(y);
  ------------------
   79|  17.9k|		alloc->quar = p;
   80|  17.9k|		alloc->num_quar++;
   81|  17.9k|	}
   82|  1.79k|}
alloc.c:alloc_setup_special:
   56|  19.7k|{
   57|  19.7k|	memset(t, 0, sizeof(*t));
   58|  19.7k|	lock_rw_init(&t->entry.lock);
  ------------------
  |  |  118|  19.7k|#define lock_rw_init(lock) LOCKRET(pthread_rwlock_init(lock, NULL))
  |  |  ------------------
  |  |  |  |   67|  19.7k|#define LOCKRET(func) do {\
  |  |  |  |   68|  19.7k|	int lockret_err;		\
  |  |  |  |   69|  19.7k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 19.7k]
  |  |  |  |  ------------------
  |  |  |  |   70|  19.7k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  19.7k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 19.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   59|  19.7k|	t->entry.key = t;
   60|  19.7k|}

pkt_dname_len:
  184|  14.2k|{
  185|  14.2k|	size_t len = 0;
  186|  14.2k|	int ptrcount = 0;
  187|  14.2k|	uint8_t labellen;
  188|  14.2k|	size_t endpos = 0;
  189|       |
  190|       |	/* read dname and determine length */
  191|       |	/* check compression pointers, loops, out of bounds */
  192|  24.6k|	while(1) {
  ------------------
  |  Branch (192:8): [True: 24.6k, Folded]
  ------------------
  193|       |		/* read next label */
  194|  24.6k|		if(sldns_buffer_remaining(pkt) < 1)
  ------------------
  |  Branch (194:6): [True: 16, False: 24.6k]
  ------------------
  195|     16|			goto fail;
  196|  24.6k|		labellen = sldns_buffer_read_u8(pkt);
  197|  24.6k|		if(LABEL_IS_PTR(labellen)) {
  ------------------
  |  |  233|  24.6k|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 5.08k, False: 19.5k]
  |  |  ------------------
  ------------------
  198|       |			/* compression ptr */
  199|  5.08k|			uint16_t ptr;
  200|  5.08k|			if(sldns_buffer_remaining(pkt) < 1)
  ------------------
  |  Branch (200:7): [True: 2, False: 5.08k]
  ------------------
  201|      2|				goto fail;
  202|  5.08k|			ptr = PTR_OFFSET(labellen, sldns_buffer_read_u8(pkt));
  ------------------
  |  |  236|  5.08k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  203|  5.08k|			if(ptrcount++ > MAX_COMPRESS_PTRS)
  ------------------
  |  |   51|  5.08k|#define MAX_COMPRESS_PTRS 256
  ------------------
  |  Branch (203:7): [True: 4, False: 5.08k]
  ------------------
  204|      4|				goto fail; /* loop! */
  205|  5.08k|			if(sldns_buffer_limit(pkt) <= ptr)
  ------------------
  |  Branch (205:7): [True: 15, False: 5.06k]
  ------------------
  206|     15|				goto fail; /* out of bounds! */
  207|  5.06k|			if(!endpos)
  ------------------
  |  Branch (207:7): [True: 2.11k, False: 2.95k]
  ------------------
  208|  2.11k|				endpos = sldns_buffer_position(pkt);
  209|  5.06k|			sldns_buffer_set_position(pkt, ptr);
  210|  19.5k|		} else {
  211|       |			/* label contents */
  212|  19.5k|			if(labellen > 0x3f)
  ------------------
  |  Branch (212:7): [True: 11, False: 19.5k]
  ------------------
  213|     11|				goto fail; /* label too long */
  214|  19.5k|			len += 1 + labellen;
  215|  19.5k|			if(len > LDNS_MAX_DOMAINLEN)
  ------------------
  |  |   29|  19.5k|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (215:7): [True: 14, False: 19.5k]
  ------------------
  216|     14|				goto fail;
  217|  19.5k|			if(labellen == 0) {
  ------------------
  |  Branch (217:7): [True: 14.1k, False: 5.36k]
  ------------------
  218|       |				/* end of dname */
  219|  14.1k|				break;
  220|  14.1k|			}
  221|  5.36k|			if(sldns_buffer_remaining(pkt) < labellen)
  ------------------
  |  Branch (221:7): [True: 15, False: 5.35k]
  ------------------
  222|     15|				goto fail;
  223|  5.35k|			sldns_buffer_skip(pkt, (ssize_t)labellen);
  224|  5.35k|		}
  225|  24.6k|	}
  226|  14.1k|	if(endpos)
  ------------------
  |  Branch (226:5): [True: 2.08k, False: 12.0k]
  ------------------
  227|  2.08k|		sldns_buffer_set_position(pkt, endpos);
  228|       |
  229|  14.1k|	return len;
  230|     77|fail:
  231|       |	/* Restore the position on failure too: callers (rdata_copy) compute
  232|       |	 * the consumed field length from the buffer position and must not
  233|       |	 * see a partial walk of a name that failed to parse. */
  234|     77|	if(endpos)
  ------------------
  |  Branch (234:5): [True: 29, False: 48]
  ------------------
  235|     29|		sldns_buffer_set_position(pkt, endpos);
  236|     77|	return 0;
  237|  14.2k|}
pkt_dname_len_budget:
  241|  1.82M|{
  242|  1.82M|	size_t len = 0;
  243|  1.82M|	int ptrcount = 0;
  244|  1.82M|	uint8_t labellen;
  245|  1.82M|	size_t endpos = 0;
  246|       |
  247|       |	/* read dname and determine length */
  248|       |	/* check compression pointers, loops, out of bounds */
  249|  2.26M|	while(1) {
  ------------------
  |  Branch (249:8): [True: 2.26M, Folded]
  ------------------
  250|       |		/* read next label */
  251|  2.26M|		if(sldns_buffer_remaining(pkt) < 1)
  ------------------
  |  Branch (251:6): [True: 830, False: 2.26M]
  ------------------
  252|    830|			return 0;
  253|  2.26M|		labellen = sldns_buffer_read_u8(pkt);
  254|  2.26M|		if(LABEL_IS_PTR(labellen)) {
  ------------------
  |  |  233|  2.26M|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 204k, False: 2.06M]
  |  |  ------------------
  ------------------
  255|       |			/* compression ptr */
  256|   204k|			uint16_t ptr;
  257|   204k|			if(sldns_buffer_remaining(pkt) < 1)
  ------------------
  |  Branch (257:7): [True: 242, False: 204k]
  ------------------
  258|    242|				return 0;
  259|   204k|			ptr = PTR_OFFSET(labellen, sldns_buffer_read_u8(pkt));
  ------------------
  |  |  236|   204k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  260|   204k|			if(++(*budget) > limit) {
  ------------------
  |  Branch (260:7): [True: 751, False: 203k]
  ------------------
  261|    751|				verbose(VERB_ALGO, "The decompression pointer "
  262|    751|					"limit of %d has been exceeded", limit);
  263|    751|				return 0; /* too many decompression pointers */
  264|    751|			}
  265|   203k|			if(ptrcount++ > MAX_COMPRESS_PTRS)
  ------------------
  |  |   51|   203k|#define MAX_COMPRESS_PTRS 256
  ------------------
  |  Branch (265:7): [True: 210, False: 203k]
  ------------------
  266|    210|				return 0; /* loop! */
  267|   203k|			if(sldns_buffer_limit(pkt) <= ptr)
  ------------------
  |  Branch (267:7): [True: 379, False: 203k]
  ------------------
  268|    379|				return 0; /* out of bounds! */
  269|   203k|			if(!endpos)
  ------------------
  |  Branch (269:7): [True: 78.3k, False: 125k]
  ------------------
  270|  78.3k|				endpos = sldns_buffer_position(pkt);
  271|   203k|			sldns_buffer_set_position(pkt, ptr);
  272|  2.06M|		} else {
  273|       |			/* label contents */
  274|  2.06M|			if(labellen > 0x3f)
  ------------------
  |  Branch (274:7): [True: 456, False: 2.06M]
  ------------------
  275|    456|				return 0; /* label too long */
  276|  2.06M|			len += 1 + labellen;
  277|  2.06M|			if(len > LDNS_MAX_DOMAINLEN)
  ------------------
  |  |   29|  2.06M|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (277:7): [True: 1.71k, False: 2.05M]
  ------------------
  278|  1.71k|				return 0;
  279|  2.05M|			if(labellen == 0) {
  ------------------
  |  Branch (279:7): [True: 1.82M, False: 234k]
  ------------------
  280|       |				/* end of dname */
  281|  1.82M|				break;
  282|  1.82M|			}
  283|   234k|			if(sldns_buffer_remaining(pkt) < labellen)
  ------------------
  |  Branch (283:7): [True: 413, False: 234k]
  ------------------
  284|    413|				return 0;
  285|   234k|			sldns_buffer_skip(pkt, (ssize_t)labellen);
  286|   234k|		}
  287|  2.26M|	}
  288|  1.82M|	if(endpos)
  ------------------
  |  Branch (288:5): [True: 75.2k, False: 1.74M]
  ------------------
  289|  75.2k|		sldns_buffer_set_position(pkt, endpos);
  290|       |
  291|  1.82M|	return len;
  292|  1.82M|}
dname_pkt_compare:
  296|  1.82M|{
  297|  1.82M|	uint8_t len1, len2;
  298|  1.82M|	int count1 = 0, count2 = 0;
  299|  1.82M|	log_assert(pkt && d1 && d2);
  300|  1.82M|	len1 = *d1++;
  301|  1.82M|	len2 = *d2++;
  302|  2.08M|	while( len1 != 0 || len2 != 0 ) {
  ------------------
  |  Branch (302:9): [True: 233k, False: 1.85M]
  |  Branch (302:22): [True: 40.0k, False: 1.81M]
  ------------------
  303|       |		/* resolve ptrs */
  304|   273k|		if(LABEL_IS_PTR(len1)) {
  ------------------
  |  |  233|   273k|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 61.5k, False: 211k]
  |  |  ------------------
  ------------------
  305|  61.5k|			if((size_t)PTR_OFFSET(len1, *d1)
  ------------------
  |  |  236|  61.5k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  |  Branch (305:7): [True: 0, False: 61.5k]
  ------------------
  306|  61.5k|				>= sldns_buffer_limit(pkt))
  307|      0|				return -1;
  308|  61.5k|			if(count1++ > MAX_COMPRESS_PTRS)
  ------------------
  |  |   51|  61.5k|#define MAX_COMPRESS_PTRS 256
  ------------------
  |  Branch (308:7): [True: 0, False: 61.5k]
  ------------------
  309|      0|				return -1;
  310|  61.5k|			d1 = sldns_buffer_at(pkt, PTR_OFFSET(len1, *d1));
  ------------------
  |  |  236|  61.5k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  311|  61.5k|			len1 = *d1++;
  312|  61.5k|			continue;
  313|  61.5k|		}
  314|   211k|		if(LABEL_IS_PTR(len2)) {
  ------------------
  |  |  233|   211k|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 62.7k, False: 148k]
  |  |  ------------------
  ------------------
  315|  62.7k|			if((size_t)PTR_OFFSET(len2, *d2)
  ------------------
  |  |  236|  62.7k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  |  Branch (315:7): [True: 0, False: 62.7k]
  ------------------
  316|  62.7k|				>= sldns_buffer_limit(pkt))
  317|      0|				return 1;
  318|  62.7k|			if(count2++ > MAX_COMPRESS_PTRS)
  ------------------
  |  |   51|  62.7k|#define MAX_COMPRESS_PTRS 256
  ------------------
  |  Branch (318:7): [True: 0, False: 62.7k]
  ------------------
  319|      0|				return 1;
  320|  62.7k|			d2 = sldns_buffer_at(pkt, PTR_OFFSET(len2, *d2));
  ------------------
  |  |  236|  62.7k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  321|  62.7k|			len2 = *d2++;
  322|  62.7k|			continue;
  323|  62.7k|		}
  324|       |		/* check label length */
  325|   148k|		log_assert(len1 <= LDNS_MAX_LABELLEN);
  326|   148k|		log_assert(len2 <= LDNS_MAX_LABELLEN);
  327|   148k|		if(len1 != len2) {
  ------------------
  |  Branch (327:6): [True: 10.0k, False: 138k]
  ------------------
  328|  10.0k|			if(len1 < len2) return -1;
  ------------------
  |  Branch (328:7): [True: 2.96k, False: 7.10k]
  ------------------
  329|  7.10k|			return 1;
  330|  10.0k|		}
  331|   138k|		log_assert(len1 == len2 && len1 != 0);
  332|       |		/* compare labels */
  333|  1.23M|		while(len1--) {
  ------------------
  |  Branch (333:9): [True: 1.10M, False: 137k]
  ------------------
  334|  1.10M|			if(tolower((unsigned char)*d1) != tolower((unsigned char)*d2)) {
  ------------------
  |  Branch (334:7): [True: 0, False: 0]
  |  Branch (334:7): [True: 0, False: 0]
  |  Branch (334:7): [Folded, False: 1.10M]
  |  Branch (334:7): [True: 1.55k, False: 1.10M]
  |  Branch (334:38): [True: 0, False: 0]
  |  Branch (334:38): [True: 0, False: 0]
  |  Branch (334:38): [Folded, False: 1.10M]
  ------------------
  335|  1.55k|				if(tolower((unsigned char)*d1) < tolower((unsigned char)*d2))
  ------------------
  |  Branch (335:8): [True: 0, False: 0]
  |  Branch (335:8): [True: 0, False: 0]
  |  Branch (335:8): [Folded, False: 1.55k]
  |  Branch (335:8): [True: 1.02k, False: 539]
  |  Branch (335:38): [True: 0, False: 0]
  |  Branch (335:38): [True: 0, False: 0]
  |  Branch (335:38): [Folded, False: 1.55k]
  ------------------
  336|  1.02k|					return -1;
  337|    539|				return 1;
  338|  1.55k|			}
  339|  1.10M|			d1++;
  340|  1.10M|			d2++;
  341|  1.10M|		}
  342|   137k|		len1 = *d1++;
  343|   137k|		len2 = *d2++;
  344|   137k|	}
  345|  1.81M|	return 0;
  346|  1.82M|}
dname_query_hash:
  350|    921|{
  351|    921|	uint8_t labuf[LDNS_MAX_LABELLEN+1];
  352|    921|	uint8_t lablen;
  353|    921|	int i;
  354|       |
  355|       |	/* preserve case of query, make hash label by label */
  356|    921|	lablen = *dname++;
  357|  2.63k|	while(lablen) {
  ------------------
  |  Branch (357:8): [True: 1.71k, False: 921]
  ------------------
  358|  1.71k|		log_assert(lablen <= LDNS_MAX_LABELLEN);
  359|  1.71k|		labuf[0] = lablen;
  360|  1.71k|		i=0;
  361|  18.6k|		while(lablen--) {
  ------------------
  |  Branch (361:9): [True: 16.8k, False: 1.71k]
  ------------------
  362|  16.8k|			labuf[++i] = (uint8_t)tolower((unsigned char)*dname);
  ------------------
  |  Branch (362:26): [True: 0, False: 0]
  |  Branch (362:26): [True: 0, False: 0]
  |  Branch (362:26): [Folded, False: 16.8k]
  ------------------
  363|  16.8k|			dname++;
  364|  16.8k|		}
  365|  1.71k|		h = hashlittle(labuf, labuf[0] + 1, h);
  366|  1.71k|		lablen = *dname++;
  367|  1.71k|	}
  368|       |
  369|    921|	return h;
  370|    921|}
dname_pkt_hash:
  374|  1.72M|{
  375|  1.72M|	uint8_t labuf[LDNS_MAX_LABELLEN+1];
  376|  1.72M|	uint8_t lablen;
  377|  1.72M|	int i;
  378|  1.72M|	int count = 0;
  379|       |
  380|       |	/* preserve case of query, make hash label by label */
  381|  1.72M|	lablen = *dname++;
  382|  2.00M|	while(lablen) {
  ------------------
  |  Branch (382:8): [True: 273k, False: 1.72M]
  ------------------
  383|   273k|		if(LABEL_IS_PTR(lablen)) {
  ------------------
  |  |  233|   273k|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 80.6k, False: 193k]
  |  |  ------------------
  ------------------
  384|       |			/* follow pointer */
  385|  80.6k|			if((size_t)PTR_OFFSET(lablen, *dname)
  ------------------
  |  |  236|  80.6k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  |  Branch (385:7): [True: 0, False: 80.6k]
  ------------------
  386|  80.6k|				>= sldns_buffer_limit(pkt))
  387|      0|				return h;
  388|  80.6k|			if(count++ > MAX_COMPRESS_PTRS)
  ------------------
  |  |   51|  80.6k|#define MAX_COMPRESS_PTRS 256
  ------------------
  |  Branch (388:7): [True: 0, False: 80.6k]
  ------------------
  389|      0|				return h;
  390|  80.6k|			dname = sldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
  ------------------
  |  |  236|  80.6k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  391|  80.6k|			lablen = *dname++;
  392|  80.6k|			continue;
  393|  80.6k|		}
  394|   193k|		log_assert(lablen <= LDNS_MAX_LABELLEN);
  395|   193k|		labuf[0] = lablen;
  396|   193k|		i=0;
  397|  1.83M|		while(lablen--) {
  ------------------
  |  Branch (397:9): [True: 1.64M, False: 193k]
  ------------------
  398|  1.64M|			labuf[++i] = (uint8_t)tolower((unsigned char)*dname);
  ------------------
  |  Branch (398:26): [True: 0, False: 0]
  |  Branch (398:26): [True: 0, False: 0]
  |  Branch (398:26): [Folded, False: 1.64M]
  ------------------
  399|  1.64M|			dname++;
  400|  1.64M|		}
  401|   193k|		h = hashlittle(labuf, labuf[0] + 1, h);
  402|   193k|		lablen = *dname++;
  403|   193k|	}
  404|       |
  405|  1.72M|	return h;
  406|  1.72M|}
dname_pkt_copy:
  409|  99.7k|{
  410|       |	/* copy over the dname and decompress it at the same time */
  411|  99.7k|	size_t comprcount = 0;
  412|  99.7k|	size_t len = 0;
  413|  99.7k|	uint8_t lablen;
  414|  99.7k|	lablen = *dname++;
  415|   166k|	while(lablen) {
  ------------------
  |  Branch (415:8): [True: 66.5k, False: 99.7k]
  ------------------
  416|  66.5k|		if(LABEL_IS_PTR(lablen)) {
  ------------------
  |  |  233|  66.5k|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 18.4k, False: 48.1k]
  |  |  ------------------
  ------------------
  417|  18.4k|			if(comprcount++ > MAX_COMPRESS_PTRS) {
  ------------------
  |  |   51|  18.4k|#define MAX_COMPRESS_PTRS 256
  ------------------
  |  Branch (417:7): [True: 0, False: 18.4k]
  ------------------
  418|       |				/* too many compression pointers */
  419|      0|				*to = 0; /* end the result prematurely */
  420|      0|				return;
  421|      0|			}
  422|       |			/* follow pointer */
  423|  18.4k|			if((size_t)PTR_OFFSET(lablen, *dname)
  ------------------
  |  |  236|  18.4k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  |  Branch (423:7): [True: 0, False: 18.4k]
  ------------------
  424|  18.4k|				>= sldns_buffer_limit(pkt))
  425|      0|				return;
  426|  18.4k|			dname = sldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
  ------------------
  |  |  236|  18.4k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  427|  18.4k|			lablen = *dname++;
  428|  18.4k|			continue;
  429|  18.4k|		}
  430|  48.1k|		if(lablen > LDNS_MAX_LABELLEN) {
  ------------------
  |  |   27|  48.1k|#define LDNS_MAX_LABELLEN     63
  ------------------
  |  Branch (430:6): [True: 0, False: 48.1k]
  ------------------
  431|      0|			*to = 0; /* end the result prematurely */
  432|      0|			return;
  433|      0|		}
  434|  48.1k|		log_assert(lablen <= LDNS_MAX_LABELLEN);
  435|  48.1k|		len += (size_t)lablen+1;
  436|  48.1k|		if(len >= LDNS_MAX_DOMAINLEN) {
  ------------------
  |  |   29|  48.1k|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (436:6): [True: 0, False: 48.1k]
  ------------------
  437|      0|			*to = 0; /* end the result prematurely */
  438|      0|			log_err("bad dname in dname_pkt_copy");
  439|      0|			return;
  440|      0|		}
  441|  48.1k|		*to++ = lablen;
  442|  48.1k|		memmove(to, dname, lablen);
  443|  48.1k|		dname += lablen;
  444|  48.1k|		to += lablen;
  445|  48.1k|		lablen = *dname++;
  446|  48.1k|	}
  447|       |	/* copy last \0 */
  448|  99.7k|	*to = 0;
  449|  99.7k|}
dname_count_labels:
  494|   146k|{
  495|   146k|	uint8_t lablen;
  496|   146k|	int labs = 1;
  497|       |
  498|   146k|	lablen = *dname++;
  499|   260k|	while(lablen) {
  ------------------
  |  Branch (499:8): [True: 113k, False: 146k]
  ------------------
  500|   113k|		labs++;
  501|   113k|		dname += lablen;
  502|   113k|		lablen = *dname++;
  503|   113k|	}
  504|   146k|	return labs;
  505|   146k|}
dname_lab_cmp:
  549|  20.1k|{
  550|  20.1k|	uint8_t len1, len2;
  551|  20.1k|	int atlabel = labs1;
  552|  20.1k|	int lastmlabs;
  553|  20.1k|	int lastdiff = 0;
  554|       |	/* first skip so that we compare same label. */
  555|  20.1k|	if(labs1 > labs2) {
  ------------------
  |  Branch (555:5): [True: 9.43k, False: 10.6k]
  ------------------
  556|  30.9k|		while(atlabel > labs2) {
  ------------------
  |  Branch (556:9): [True: 21.4k, False: 9.43k]
  ------------------
  557|  21.4k|			len1 = *d1++;
  558|  21.4k|			d1 += len1;
  559|  21.4k|			atlabel--;
  560|  21.4k|		}
  561|  9.43k|		log_assert(atlabel == labs2);
  562|  10.6k|	} else if(labs1 < labs2) {
  ------------------
  |  Branch (562:12): [True: 0, False: 10.6k]
  ------------------
  563|      0|		atlabel = labs2;
  564|      0|		while(atlabel > labs1) {
  ------------------
  |  Branch (564:9): [True: 0, False: 0]
  ------------------
  565|      0|			len2 = *d2++;
  566|      0|			d2 += len2;
  567|      0|			atlabel--;
  568|      0|		}
  569|      0|		log_assert(atlabel == labs1);
  570|      0|	}
  571|  20.1k|	lastmlabs = atlabel+1;
  572|       |	/* now at same label in d1 and d2, atlabel */
  573|       |	/* www.example.com.                  */
  574|       |	/* 4   3       2  1   atlabel number */
  575|       |	/* repeat until at root label (which is always the same) */
  576|  39.2k|	while(atlabel > 1) {
  ------------------
  |  Branch (576:8): [True: 19.1k, False: 20.1k]
  ------------------
  577|  19.1k|		len1 = *d1++;
  578|  19.1k|		len2 = *d2++;
  579|  19.1k|		if(len1 != len2) {
  ------------------
  |  Branch (579:6): [True: 11.6k, False: 7.52k]
  ------------------
  580|  11.6k|			log_assert(len1 != 0 && len2 != 0);
  581|  11.6k|			if(len1<len2)
  ------------------
  |  Branch (581:7): [True: 3.36k, False: 8.25k]
  ------------------
  582|  3.36k|				lastdiff = -1;
  583|  8.25k|			else	lastdiff = 1;
  584|  11.6k|			lastmlabs = atlabel;
  585|  11.6k|			d1 += len1;
  586|  11.6k|			d2 += len2;
  587|  11.6k|		} else {
  588|       |			/* memlowercmp is inlined here; or just like
  589|       |			 * if((c=memlowercmp(d1, d2, len1)) != 0) { 
  590|       |			 *	lastdiff = c;
  591|       |			 *	lastmlabs = atlabel; } apart from d1++,d2++ */
  592|  19.9k|			while(len1) {
  ------------------
  |  Branch (592:10): [True: 13.8k, False: 6.07k]
  ------------------
  593|  13.8k|				if(*d1 != *d2 && tolower((unsigned char)*d1) 
  ------------------
  |  Branch (593:8): [True: 5.59k, False: 8.24k]
  |  Branch (593:22): [True: 0, False: 0]
  |  Branch (593:22): [True: 0, False: 0]
  |  Branch (593:22): [Folded, False: 5.59k]
  |  Branch (593:22): [True: 1.44k, False: 4.14k]
  ------------------
  594|  5.59k|					!= tolower((unsigned char)*d2)) {
  ------------------
  |  Branch (594:9): [True: 0, False: 0]
  |  Branch (594:9): [True: 0, False: 0]
  |  Branch (594:9): [Folded, False: 5.59k]
  ------------------
  595|  1.44k|					if(tolower((unsigned char)*d1) < 
  ------------------
  |  Branch (595:9): [True: 0, False: 0]
  |  Branch (595:9): [True: 0, False: 0]
  |  Branch (595:9): [Folded, False: 1.44k]
  |  Branch (595:9): [True: 992, False: 457]
  ------------------
  596|  1.44k|						tolower((unsigned char)*d2)) {
  ------------------
  |  Branch (596:7): [True: 0, False: 0]
  |  Branch (596:7): [True: 0, False: 0]
  |  Branch (596:7): [Folded, False: 1.44k]
  ------------------
  597|    992|						lastdiff = -1;
  598|    992|						lastmlabs = atlabel;
  599|    992|						d1 += len1;
  600|    992|						d2 += len1;
  601|    992|						break;
  602|    992|					}
  603|    457|					lastdiff = 1;
  604|    457|					lastmlabs = atlabel;
  605|    457|					d1 += len1;
  606|    457|					d2 += len1;
  607|    457|					break; /* out of memlowercmp */
  608|  1.44k|				}
  609|  12.3k|				d1++;
  610|  12.3k|				d2++;
  611|  12.3k|				len1--;
  612|  12.3k|			}
  613|  7.52k|		}
  614|  19.1k|		atlabel--;
  615|  19.1k|	}
  616|       |	/* last difference atlabel number, so number of labels matching,
  617|       |	 * at the right side, is one less. */
  618|  20.1k|	*mlabs = lastmlabs-1;
  619|  20.1k|	if(lastdiff == 0) {
  ------------------
  |  Branch (619:5): [True: 7.15k, False: 12.9k]
  ------------------
  620|       |		/* all labels compared were equal, check if one has more
  621|       |		 * labels, so that example.com. > com. */
  622|  7.15k|		if(labs1 > labs2)
  ------------------
  |  Branch (622:6): [True: 4.65k, False: 2.49k]
  ------------------
  623|  4.65k|			return 1;
  624|  2.49k|		else if(labs1 < labs2)
  ------------------
  |  Branch (624:11): [True: 0, False: 2.49k]
  ------------------
  625|      0|			return -1;
  626|  7.15k|	}
  627|  15.4k|	return lastdiff;
  628|  20.1k|}
dname_strict_subdomain:
  744|  1.05k|{
  745|  1.05k|	int m;
  746|       |	/* check subdomain: d1: www.example.com. and d2: example.com. */
  747|  1.05k|	if(labs2 >= labs1) 
  ------------------
  |  Branch (747:5): [True: 202, False: 854]
  ------------------
  748|    202|		return 0;
  749|    854|	if(dname_lab_cmp(d1, labs1, d2, labs2, &m) > 0) {
  ------------------
  |  Branch (749:5): [True: 731, False: 123]
  ------------------
  750|       |		/* subdomain if all labels match */
  751|    731|		return (m == labs2);
  752|    731|	}
  753|    123|	return 0;
  754|    854|}
dname_strict_subdomain_c:
  758|  1.05k|{
  759|  1.05k|	return dname_strict_subdomain(d1, dname_count_labels(d1), d2,
  760|  1.05k|		dname_count_labels(d2));
  761|  1.05k|}
dname_subdomain_c:
  765|  72.1k|{
  766|  72.1k|	int m;
  767|       |	/* check subdomain: d1: www.example.com. and d2: example.com. */
  768|       |	/*  	or 	    d1: example.com. and d2: example.com. */
  769|  72.1k|	int labs1 = dname_count_labels(d1);
  770|  72.1k|	int labs2 = dname_count_labels(d2);
  771|  72.1k|	if(labs2 > labs1) 
  ------------------
  |  Branch (771:5): [True: 52.8k, False: 19.2k]
  ------------------
  772|  52.8k|		return 0;
  773|  19.2k|	if(dname_lab_cmp(d1, labs1, d2, labs2, &m) < 0) {
  ------------------
  |  Branch (773:5): [True: 4.17k, False: 15.0k]
  ------------------
  774|       |		/* must have been example.com , www.example.com - wrong */
  775|       |		/* or otherwise different dnames */
  776|  4.17k|		return 0;
  777|  4.17k|	}
  778|  15.0k|	return (m == labs2);
  779|  19.2k|}

pkt_hash_rrset:
  180|  8.55k|{
  181|       |	/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
  182|       |	/* this routine handles compressed names */
  183|  8.55k|	hashvalue_type h = 0xab;
  184|  8.55k|	h = dname_pkt_hash(pkt, dname, h);
  185|  8.55k|	h = hashlittle(&type, sizeof(type), h);		/* host order */
  186|  8.55k|	h = hashlittle(&dclass, sizeof(dclass), h);	/* netw order */
  187|  8.55k|	h = hashlittle(&rrset_flags, sizeof(uint32_t), h);
  188|  8.55k|	return h;
  189|  8.55k|}
msgparse_hashtable_lookup:
  235|  1.49M|{
  236|  1.49M|	struct rrset_parse* p = msg->hashtable[h & (PARSE_TABLE_SIZE-1)];
  ------------------
  |  |   79|  1.49M|#define PARSE_TABLE_SIZE 32
  ------------------
  237|  18.0M|	while(p) {
  ------------------
  |  Branch (237:8): [True: 17.3M, False: 648k]
  ------------------
  238|  17.3M|		if(rrset_parse_equals(p, pkt, h, rrset_flags, dname, dnamelen,
  ------------------
  |  Branch (238:6): [True: 848k, False: 16.5M]
  ------------------
  239|  17.3M|			type, dclass))
  240|   848k|			return p;
  241|  16.5M|		p = p->rrset_bucket_next;
  242|  16.5M|	}
  243|   648k|	return NULL;
  244|  1.49M|}
msgparse_bucket_remove:
  279|  86.1k|{
  280|  86.1k|	struct rrset_parse** p;
  281|  86.1k|	p = &msg->hashtable[ rrset->hash & (PARSE_TABLE_SIZE-1) ];
  ------------------
  |  |   79|  86.1k|#define PARSE_TABLE_SIZE 32
  ------------------
  282|   889k|	while(*p) {
  ------------------
  |  Branch (282:8): [True: 889k, False: 0]
  ------------------
  283|   889k|		if(*p == rrset) {
  ------------------
  |  Branch (283:6): [True: 86.1k, False: 803k]
  ------------------
  284|  86.1k|			*p = rrset->rrset_bucket_next;
  285|  86.1k|			return;
  286|  86.1k|		}
  287|   803k|		p = &( (*p)->rrset_bucket_next );
  288|   803k|	}
  289|  86.1k|}
get_rdf_size:
  619|   331k|{
  620|   331k|	switch(rdf) {
  621|      0|		case LDNS_RDF_TYPE_CLASS:
  ------------------
  |  Branch (621:3): [True: 0, False: 331k]
  ------------------
  622|  47.2k|		case LDNS_RDF_TYPE_ALG:
  ------------------
  |  Branch (622:3): [True: 47.2k, False: 284k]
  ------------------
  623|  94.4k|		case LDNS_RDF_TYPE_INT8:
  ------------------
  |  Branch (623:3): [True: 47.2k, False: 284k]
  ------------------
  624|  94.4k|			return 1;
  625|      0|			break;
  626|  47.8k|		case LDNS_RDF_TYPE_INT16:
  ------------------
  |  Branch (626:3): [True: 47.8k, False: 283k]
  ------------------
  627|  95.0k|		case LDNS_RDF_TYPE_TYPE:
  ------------------
  |  Branch (627:3): [True: 47.2k, False: 284k]
  ------------------
  628|  95.0k|		case LDNS_RDF_TYPE_CERT_ALG:
  ------------------
  |  Branch (628:3): [True: 0, False: 331k]
  ------------------
  629|  95.0k|			return 2;
  630|      0|			break;
  631|  47.2k|		case LDNS_RDF_TYPE_INT32:
  ------------------
  |  Branch (631:3): [True: 47.2k, False: 284k]
  ------------------
  632|   141k|		case LDNS_RDF_TYPE_TIME:
  ------------------
  |  Branch (632:3): [True: 94.4k, False: 236k]
  ------------------
  633|   141k|		case LDNS_RDF_TYPE_A:
  ------------------
  |  Branch (633:3): [True: 0, False: 331k]
  ------------------
  634|   141k|		case LDNS_RDF_TYPE_PERIOD:
  ------------------
  |  Branch (634:3): [True: 0, False: 331k]
  ------------------
  635|   141k|			return 4;
  636|      0|			break;
  637|      0|		case LDNS_RDF_TYPE_TSIGTIME:
  ------------------
  |  Branch (637:3): [True: 0, False: 331k]
  ------------------
  638|      0|			return 6;
  639|      0|			break;
  640|      0|		case LDNS_RDF_TYPE_AAAA:
  ------------------
  |  Branch (640:3): [True: 0, False: 331k]
  ------------------
  641|      0|			return 16;
  642|      0|			break;
  643|      0|		default:
  ------------------
  |  Branch (643:3): [True: 0, False: 331k]
  ------------------
  644|      0|			log_assert(0); /* add type above */
  645|       |			/* only types that appear before a domain  *
  646|       |			 * name are needed. rest is simply copied. */
  647|   331k|	}
  648|      0|	return 0;
  649|   331k|}
parse_packet:
  937|  4.66k|{
  938|  4.66k|	int ret, budget = 0, limit = PARSE_DECOMPRESS_LIMIT;
  ------------------
  |  |   59|  4.66k|#define PARSE_DECOMPRESS_LIMIT 2048
  ------------------
  939|  4.66k|	if(sldns_buffer_remaining(pkt) < LDNS_HEADER_SIZE)
  ------------------
  |  |   26|  4.66k|#define	LDNS_HEADER_SIZE	12
  ------------------
  |  Branch (939:5): [True: 8, False: 4.65k]
  ------------------
  940|      8|		return LDNS_RCODE_FORMERR;
  941|       |	/* read the header */
  942|  4.65k|	sldns_buffer_read(pkt, &msg->id, sizeof(uint16_t));
  943|  4.65k|	msg->flags = sldns_buffer_read_u16(pkt);
  944|  4.65k|	msg->qdcount = sldns_buffer_read_u16(pkt);
  945|  4.65k|	msg->ancount = sldns_buffer_read_u16(pkt);
  946|  4.65k|	msg->nscount = sldns_buffer_read_u16(pkt);
  947|  4.65k|	msg->arcount = sldns_buffer_read_u16(pkt);
  948|  4.65k|	if(msg->qdcount > 1)
  ------------------
  |  Branch (948:5): [True: 15, False: 4.64k]
  ------------------
  949|     15|		return LDNS_RCODE_FORMERR;
  950|  4.64k|	if((ret = parse_query_section(pkt, msg, &budget, limit)) != 0)
  ------------------
  |  Branch (950:5): [True: 31, False: 4.61k]
  ------------------
  951|     31|		return ret;
  952|  4.61k|	if((ret = parse_section(pkt, msg, region, LDNS_SECTION_ANSWER,
  ------------------
  |  Branch (952:5): [True: 1.28k, False: 3.32k]
  ------------------
  953|  4.61k|		msg->ancount, &msg->an_rrsets, &budget, limit)) != 0)
  954|  1.28k|		return ret;
  955|  3.32k|	if((ret = parse_section(pkt, msg, region, LDNS_SECTION_AUTHORITY,
  ------------------
  |  Branch (955:5): [True: 753, False: 2.57k]
  ------------------
  956|  3.32k|		msg->nscount, &msg->ns_rrsets, &budget, limit)) != 0)
  957|    753|		return ret;
  958|  2.57k|	if(sldns_buffer_remaining(pkt) == 0 && msg->arcount == 1) {
  ------------------
  |  Branch (958:5): [True: 1.09k, False: 1.48k]
  |  Branch (958:41): [True: 315, False: 775]
  ------------------
  959|       |		/* BIND accepts leniently that an EDNS record is missing.
  960|       |		 * so, we do too. */
  961|  2.25k|	} else if((ret = parse_section(pkt, msg, region,
  ------------------
  |  Branch (961:12): [True: 332, False: 1.92k]
  ------------------
  962|  2.25k|		LDNS_SECTION_ADDITIONAL, msg->arcount, &msg->ar_rrsets,
  963|  2.25k|		&budget, limit)) != 0)
  964|    332|		return ret;
  965|       |	/* if(sldns_buffer_remaining(pkt) > 0) { */
  966|       |		/* there is spurious data at end of packet. ignore */
  967|       |	/* } */
  968|  2.24k|	msg->rrset_count = msg->an_rrsets + msg->ns_rrsets + msg->ar_rrsets;
  969|  2.24k|	return 0;
  970|  2.57k|}
parse_extract_edns_from_response_msg:
 1194|  2.24k|{
 1195|  2.24k|	struct rrset_parse* rrset = msg->rrset_first;
 1196|  2.24k|	struct rrset_parse* prev = 0;
 1197|  2.24k|	struct rrset_parse* found = 0;
 1198|  2.24k|	struct rrset_parse* found_prev = 0;
 1199|  2.24k|	size_t rdata_len;
 1200|  2.24k|	uint8_t* rdata_ptr;
 1201|  2.24k|	int i = 0;
 1202|       |	/* since the class encodes the UDP size, we cannot use hash table to
 1203|       |	 * find the EDNS OPT record. Scan the packet. */
 1204|  90.8k|	while(rrset) {
  ------------------
  |  Branch (1204:8): [True: 88.5k, False: 2.24k]
  ------------------
 1205|  88.5k|		if(rrset->type == LDNS_RR_TYPE_OPT) {
  ------------------
  |  Branch (1205:6): [True: 161, False: 88.4k]
  ------------------
 1206|       |			/* only one OPT RR allowed. */
 1207|    161|			if(found) return LDNS_RCODE_FORMERR;
  ------------------
  |  Branch (1207:7): [True: 1, False: 160]
  ------------------
 1208|       |			/* found it! */
 1209|    160|			found_prev = prev;
 1210|    160|			found = rrset;
 1211|    160|		}
 1212|  88.5k|		prev = rrset;
 1213|  88.5k|		rrset = rrset->rrset_all_next;
 1214|  88.5k|	}
 1215|  2.24k|	if(!found) {
  ------------------
  |  Branch (1215:5): [True: 2.08k, False: 159]
  ------------------
 1216|  2.08k|		memset(edns, 0, sizeof(*edns));
 1217|  2.08k|		edns->udp_size = 512;
 1218|  2.08k|		return 0;
 1219|  2.08k|	}
 1220|       |	/* check the found RRset */
 1221|       |	/* most lenient check possible. ignore dname, use last opt */
 1222|    159|	if(found->section != LDNS_SECTION_ADDITIONAL)
  ------------------
  |  Branch (1222:5): [True: 2, False: 157]
  ------------------
 1223|      2|		return LDNS_RCODE_FORMERR; 
 1224|    157|	if(found->rr_count == 0)
  ------------------
  |  Branch (1224:5): [True: 0, False: 157]
  ------------------
 1225|      0|		return LDNS_RCODE_FORMERR;
 1226|    157|	if(0) { /* strict checking of dname and RRcount */
  ------------------
  |  Branch (1226:5): [Folded, False: 157]
  ------------------
 1227|      0|		if(found->dname_len != 1 || !found->dname 
  ------------------
  |  Branch (1227:6): [True: 0, False: 0]
  |  Branch (1227:31): [True: 0, False: 0]
  ------------------
 1228|      0|			|| found->dname[0] != 0) return LDNS_RCODE_FORMERR; 
  ------------------
  |  Branch (1228:7): [True: 0, False: 0]
  ------------------
 1229|      0|		if(found->rr_count != 1) return LDNS_RCODE_FORMERR; 
  ------------------
  |  Branch (1229:6): [True: 0, False: 0]
  ------------------
 1230|      0|	}
 1231|    157|	log_assert(found->rr_first && found->rr_last);
 1232|       |
 1233|       |	/* remove from packet */
 1234|    157|	if(found_prev)	found_prev->rrset_all_next = found->rrset_all_next;
  ------------------
  |  Branch (1234:5): [True: 53, False: 104]
  ------------------
 1235|    104|	else	msg->rrset_first = found->rrset_all_next;
 1236|    157|	if(found == msg->rrset_last)
  ------------------
  |  Branch (1236:5): [True: 110, False: 47]
  ------------------
 1237|    110|		msg->rrset_last = found_prev;
 1238|    157|	msg->arcount --;
 1239|    157|	msg->ar_rrsets --;
 1240|    157|	msg->rrset_count --;
 1241|       |	
 1242|       |	/* take the data ! */
 1243|    157|	edns->edns_present = 1;
 1244|    157|	edns->ext_rcode = found->rr_last->ttl_data[0];
 1245|    157|	edns->edns_version = found->rr_last->ttl_data[1];
 1246|    157|	edns->bits = sldns_read_uint16(&found->rr_last->ttl_data[2]);
 1247|    157|	edns->udp_size = ntohs(found->rrset_class);
 1248|    157|	edns->opt_list_in = NULL;
 1249|    157|	edns->opt_list_out = NULL;
 1250|    157|	edns->opt_list_inplace_cb_out = NULL;
 1251|    157|	edns->padding_block_size = 0;
 1252|    157|	edns->cookie_present = 0;
 1253|    157|	edns->cookie_valid = 0;
 1254|       |
 1255|       |	/* take the options */
 1256|    157|	rdata_len = found->rr_first->size-2;
 1257|    157|	rdata_ptr = found->rr_first->ttl_data+6;
 1258|       |
 1259|       |	/* while still more options, and have code+len to read */
 1260|       |	/* ignores partial content (i.e. rdata len 3) */
 1261|  2.09k|	while(rdata_len >= 4 && i < MAX_PARSED_EDNS_OPTIONS) {
  ------------------
  |  |   56|  2.01k|#define MAX_PARSED_EDNS_OPTIONS 100
  ------------------
  |  Branch (1261:8): [True: 2.01k, False: 77]
  |  Branch (1261:26): [True: 2.00k, False: 4]
  ------------------
 1262|  2.00k|		uint16_t opt_code = sldns_read_uint16(rdata_ptr);
 1263|  2.00k|		uint16_t opt_len = sldns_read_uint16(rdata_ptr+2);
 1264|  2.00k|		rdata_ptr += 4;
 1265|  2.00k|		rdata_len -= 4;
 1266|  2.00k|		if(opt_len > rdata_len)
  ------------------
  |  Branch (1266:6): [True: 76, False: 1.93k]
  ------------------
 1267|     76|			break; /* option code partial */
 1268|       |			/* This is lenient for partially broken messages
 1269|       |			 * from upstream. With a partial EDNS option. */
 1270|       |
 1271|  1.93k|		if(!edns_opt_list_append(&edns->opt_list_in,
  ------------------
  |  Branch (1271:6): [True: 0, False: 1.93k]
  ------------------
 1272|  1.93k|				opt_code, opt_len, rdata_ptr, region)) {
 1273|      0|			log_err("out of memory");
 1274|      0|			break;
 1275|      0|		}
 1276|  1.93k|		rdata_ptr += opt_len;
 1277|  1.93k|		rdata_len -= opt_len;
 1278|  1.93k|		i++;
 1279|  1.93k|	}
 1280|       |	/* ignore rrsigs */
 1281|    157|	return LDNS_RCODE_NOERROR;
 1282|    157|}
msgparse_rrset_remove_rr:
 1386|  60.7k|{
 1387|  60.7k|	if(verbosity >= VERB_QUERY && rrset->dname_len <= LDNS_MAX_DOMAINLEN && str) {
  ------------------
  |  |   29|  60.7k|#define LDNS_MAX_DOMAINLEN    255
  ------------------
  |  Branch (1387:5): [True: 0, False: 60.7k]
  |  Branch (1387:32): [True: 0, False: 0]
  |  Branch (1387:74): [True: 0, False: 0]
  ------------------
 1388|      0|		uint8_t buf[LDNS_MAX_DOMAINLEN+1];
 1389|      0|		dname_pkt_copy(pkt, buf, rrset->dname);
 1390|      0|		if(addr)
  ------------------
  |  Branch (1390:6): [True: 0, False: 0]
  ------------------
 1391|      0|			log_name_addr(VERB_QUERY, str, buf, addr, addrlen);
 1392|      0|		else	log_nametypeclass(VERB_QUERY, str, buf,
 1393|      0|				rrset->type, ntohs(rrset->rrset_class));
 1394|      0|	}
 1395|  60.7k|	if(prev)
  ------------------
  |  Branch (1395:5): [True: 41.6k, False: 19.1k]
  ------------------
 1396|  41.6k|		prev->next = rr->next;
 1397|  19.1k|	else	rrset->rr_first = rr->next;
 1398|  60.7k|	if(rrset->rr_last == rr)
  ------------------
  |  Branch (1398:5): [True: 5.83k, False: 54.9k]
  ------------------
 1399|  5.83k|		rrset->rr_last = prev;
 1400|  60.7k|	rrset->rr_count --;
 1401|  60.7k|	rrset->size -= rr->size;
 1402|       |	/* rr struct still exists, but is unlinked, so that in the for loop
 1403|       |	 * the rr->next works fine to continue. */
 1404|  60.7k|	return rrset->rr_count == 0;
 1405|  60.7k|}
msgparse.c:rrset_parse_equals:
  222|  17.3M|{
  223|  17.3M|	if(p->hash == h && p->dname_len == dnamelen && p->type == type &&
  ------------------
  |  Branch (223:5): [True: 857k, False: 16.5M]
  |  Branch (223:21): [True: 852k, False: 4.80k]
  |  Branch (223:49): [True: 851k, False: 1.54k]
  ------------------
  224|   851k|		p->rrset_class == dclass && p->flags == rrset_flags &&
  ------------------
  |  Branch (224:3): [True: 850k, False: 1.01k]
  |  Branch (224:31): [True: 849k, False: 461]
  ------------------
  225|   849k|		dname_pkt_compare(pkt, dname, p->dname) == 0)
  ------------------
  |  Branch (225:3): [True: 848k, False: 964]
  ------------------
  226|   848k|		return 1;
  227|  16.5M|	return 0;
  228|  17.3M|}
msgparse.c:parse_query_section:
  599|  4.64k|{
  600|  4.64k|	if(msg->qdcount == 0)
  ------------------
  |  Branch (600:5): [True: 2.79k, False: 1.84k]
  ------------------
  601|  2.79k|		return 0;
  602|  1.84k|	if(msg->qdcount > 1)
  ------------------
  |  Branch (602:5): [True: 0, False: 1.84k]
  ------------------
  603|      0|		return LDNS_RCODE_FORMERR;
  604|  1.84k|	log_assert(msg->qdcount == 1);
  605|  1.84k|	if(sldns_buffer_remaining(pkt) <= 0)
  ------------------
  |  Branch (605:5): [True: 1, False: 1.84k]
  ------------------
  606|      1|		return LDNS_RCODE_FORMERR;
  607|  1.84k|	msg->qname = sldns_buffer_current(pkt);
  608|  1.84k|	if((msg->qname_len = pkt_dname_len_budget(pkt, budget, limit)) == 0)
  ------------------
  |  Branch (608:5): [True: 17, False: 1.82k]
  ------------------
  609|     17|		return LDNS_RCODE_FORMERR;
  610|  1.82k|	if(sldns_buffer_remaining(pkt) < sizeof(uint16_t)*2)
  ------------------
  |  Branch (610:5): [True: 13, False: 1.81k]
  ------------------
  611|     13|		return LDNS_RCODE_FORMERR;
  612|  1.81k|	msg->qtype = sldns_buffer_read_u16(pkt);
  613|  1.81k|	msg->qclass = sldns_buffer_read_u16(pkt);
  614|  1.81k|	return 0;
  615|  1.82k|}
msgparse.c:parse_section:
  852|  10.1k|{
  853|  10.1k|	uint16_t i;
  854|  10.1k|	uint8_t* dname, *prev_dname_f = NULL, *prev_dname_l = NULL;
  855|  10.1k|	size_t dnamelen, prev_dnamelen = 0;
  856|  10.1k|	uint16_t type, prev_type = 0;
  857|  10.1k|	uint16_t dclass, prev_dclass = 0;
  858|  10.1k|	uint32_t rrset_flags = 0;
  859|  10.1k|	hashvalue_type hash = 0;
  860|  10.1k|	struct rrset_parse* rrset = NULL;
  861|  10.1k|	int r;
  862|       |
  863|  10.1k|	if(num_rrs == 0)
  ------------------
  |  Branch (863:5): [True: 4.52k, False: 5.67k]
  ------------------
  864|  4.52k|		return 0;
  865|  5.67k|	if(sldns_buffer_remaining(pkt) <= 0)
  ------------------
  |  Branch (865:5): [True: 53, False: 5.62k]
  ------------------
  866|     53|		return LDNS_RCODE_FORMERR;
  867|  1.72M|	for(i=0; i<num_rrs; i++) {
  ------------------
  |  Branch (867:11): [True: 1.71M, False: 3.30k]
  ------------------
  868|       |		/* parse this RR. */
  869|  1.71M|		dname = sldns_buffer_current(pkt);
  870|  1.71M|		if((dnamelen = pkt_dname_len_budget(pkt, budget, limit)) == 0) {
  ------------------
  |  Branch (870:6): [True: 849, False: 1.71M]
  ------------------
  871|    849|			if(*budget > limit) return LDNS_RCODE_SERVFAIL;
  ------------------
  |  Branch (871:7): [True: 15, False: 834]
  ------------------
  872|    834|			return LDNS_RCODE_FORMERR;
  873|    849|		}
  874|  1.71M|		if(sldns_buffer_remaining(pkt) < 10) /* type, class, ttl, len */
  ------------------
  |  Branch (874:6): [True: 208, False: 1.71M]
  ------------------
  875|    208|			return LDNS_RCODE_FORMERR;
  876|  1.71M|		type = sldns_buffer_read_u16(pkt);
  877|  1.71M|		sldns_buffer_read(pkt, &dclass, sizeof(dclass));
  878|       |
  879|  1.71M|		if(0) { /* debug show what is being parsed. */
  ------------------
  |  Branch (879:6): [Folded, False: 1.71M]
  ------------------
  880|      0|			if(type == LDNS_RR_TYPE_RRSIG) {
  ------------------
  |  Branch (880:7): [True: 0, False: 0]
  ------------------
  881|      0|				uint16_t t;
  882|      0|				if(pkt_rrsig_covered(pkt, 
  ------------------
  |  Branch (882:8): [True: 0, False: 0]
  ------------------
  883|      0|					sldns_buffer_current(pkt), &t))
  884|      0|					fprintf(stderr, "parse of %s(%d) [%s(%d)]",
  885|      0|					sldns_rr_descript(type)?
  ------------------
  |  Branch (885:6): [True: 0, False: 0]
  ------------------
  886|      0|					sldns_rr_descript(type)->_name: "??",
  887|      0|					(int)type,
  888|      0|					sldns_rr_descript(t)?
  ------------------
  |  Branch (888:6): [True: 0, False: 0]
  ------------------
  889|      0|					sldns_rr_descript(t)->_name: "??",
  890|      0|					(int)t);
  891|      0|			} else
  892|      0|			  fprintf(stderr, "parse of %s(%d)",
  893|      0|				sldns_rr_descript(type)?
  ------------------
  |  Branch (893:5): [True: 0, False: 0]
  ------------------
  894|      0|				sldns_rr_descript(type)->_name: "??",
  895|      0|				(int)type);
  896|      0|			fprintf(stderr, " %s(%d) ",
  897|      0|				sldns_lookup_by_id(sldns_rr_classes, 
  ------------------
  |  Branch (897:5): [True: 0, False: 0]
  ------------------
  898|      0|				(int)ntohs(dclass))?sldns_lookup_by_id(
  899|      0|				sldns_rr_classes, (int)ntohs(dclass))->name: 
  900|      0|				"??", (int)ntohs(dclass));
  901|      0|			dname_print(stderr, pkt, dname);
  902|      0|			fprintf(stderr, "\n");
  903|      0|		}
  904|       |
  905|       |		/* see if it is part of an existing RR set */
  906|  1.71M|		if(!find_rrset(msg, pkt, dname, dnamelen, type, dclass, &hash, 
  ------------------
  |  Branch (906:6): [True: 0, False: 1.71M]
  ------------------
  907|  1.71M|			&rrset_flags, &prev_dname_f, &prev_dname_l, 
  908|  1.71M|			&prev_dnamelen, &prev_type, &prev_dclass, &rrset, 
  909|  1.71M|			section, region, budget, limit))
  910|      0|			return LDNS_RCODE_SERVFAIL;
  911|  1.71M|		if(!rrset) {
  ------------------
  |  Branch (911:6): [True: 124k, False: 1.59M]
  ------------------
  912|       |			/* it is a new RR set. hash&flags already calculated.*/
  913|   124k|			(*num_rrsets)++;
  914|   124k|			rrset = new_rrset(msg, dname, dnamelen, type, dclass,
  915|   124k|				hash, rrset_flags, section, region);
  916|   124k|			if(!rrset) 
  ------------------
  |  Branch (916:7): [True: 0, False: 124k]
  ------------------
  917|      0|				return LDNS_RCODE_SERVFAIL;
  918|   124k|		}
  919|  1.59M|		else if(0)	{ 
  ------------------
  |  Branch (919:11): [Folded, False: 1.59M]
  ------------------
  920|      0|			fprintf(stderr, "is part of existing: ");
  921|      0|			dname_print(stderr, pkt, rrset->dname);
  922|      0|			fprintf(stderr, " type %s(%d)\n",
  923|      0|				sldns_rr_descript(rrset->type)?
  ------------------
  |  Branch (923:5): [True: 0, False: 0]
  ------------------
  924|      0|				sldns_rr_descript(rrset->type)->_name: "??",
  925|      0|				(int)rrset->type);
  926|      0|		}
  927|       |		/* add to rrset. */
  928|  1.71M|		if((r=add_rr_to_rrset(rrset, pkt, msg, region, section, 
  ------------------
  |  Branch (928:6): [True: 1.26k, False: 1.71M]
  ------------------
  929|  1.71M|			type, budget, limit)) != 0)
  930|  1.26k|			return r;
  931|  1.71M|	}
  932|  3.30k|	return 0;
  933|  5.62k|}
msgparse.c:find_rrset:
  484|  1.71M|{
  485|  1.71M|	hashvalue_type dname_h = pkt_hash_rrset_first(pkt, dname);
  486|  1.71M|	uint16_t covtype;
  487|  1.71M|	if(*rrset_prev) {
  ------------------
  |  Branch (487:5): [True: 1.71M, False: 5.54k]
  ------------------
  488|       |		/* check if equal to previous item */
  489|  1.71M|		if(type == *prev_type && dclass == *prev_dclass &&
  ------------------
  |  Branch (489:6): [True: 1.23M, False: 480k]
  |  Branch (489:28): [True: 1.02M, False: 210k]
  ------------------
  490|  1.02M|			dnamelen == *prev_dnamelen &&
  ------------------
  |  Branch (490:4): [True: 947k, False: 74.0k]
  ------------------
  491|   947k|			smart_compare(pkt, dname, *prev_dname_first, 
  ------------------
  |  Branch (491:4): [True: 947k, False: 587]
  ------------------
  492|   947k|				*prev_dname_last) == 0 &&
  493|   947k|			type != LDNS_RR_TYPE_RRSIG) {
  ------------------
  |  Branch (493:4): [True: 936k, False: 10.5k]
  ------------------
  494|       |			/* same as previous */
  495|   936k|			*prev_dname_last = dname;
  496|   936k|			return 1;
  497|   936k|		}
  498|       |		/* check if rrsig over previous item */
  499|   776k|		if(type == LDNS_RR_TYPE_RRSIG && dclass == *prev_dclass &&
  ------------------
  |  Branch (499:6): [True: 59.1k, False: 717k]
  |  Branch (499:36): [True: 45.0k, False: 14.1k]
  ------------------
  500|  45.0k|			pkt_rrsig_covered_equals(pkt, sldns_buffer_current(pkt),
  ------------------
  |  Branch (500:4): [True: 20.8k, False: 24.1k]
  ------------------
  501|  45.0k|				*prev_type) &&
  502|  20.8k|			smart_compare(pkt, dname, *prev_dname_first,
  ------------------
  |  Branch (502:4): [True: 19.2k, False: 1.63k]
  ------------------
  503|  20.8k|				*prev_dname_last) == 0) {
  504|       |			/* covers previous */
  505|  19.2k|			*prev_dname_last = dname;
  506|  19.2k|			return 1;
  507|  19.2k|		}
  508|   776k|	}
  509|       |	/* find by hashing and lookup in hashtable */
  510|   762k|	*rrset_flags = pkt_rrset_flags(pkt, type, section, budget, limit);
  511|       |	
  512|       |	/* if rrsig - try to lookup matching data set first */
  513|   762k|	if(type == LDNS_RR_TYPE_RRSIG && pkt_rrsig_covered(pkt, 
  ------------------
  |  Branch (513:5): [True: 41.0k, False: 721k]
  |  Branch (513:35): [True: 29.4k, False: 11.5k]
  ------------------
  514|  41.0k|		sldns_buffer_current(pkt), &covtype)) {
  515|  29.4k|		*hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, 
  516|  29.4k|			*rrset_flags);
  517|  29.4k|		*rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, 
  518|  29.4k|			*rrset_flags, dname, dnamelen, covtype, dclass);
  519|  29.4k|		if(!*rrset_prev && covtype == LDNS_RR_TYPE_NSEC) {
  ------------------
  |  Branch (519:6): [True: 12.7k, False: 16.7k]
  |  Branch (519:22): [True: 1.53k, False: 11.2k]
  ------------------
  520|       |			/* if NSEC try with NSEC apex bit twiddled */
  521|  1.53k|			*rrset_flags ^= PACKED_RRSET_NSEC_AT_APEX;
  ------------------
  |  |   53|  1.53k|#define PACKED_RRSET_NSEC_AT_APEX 0x1
  ------------------
  522|  1.53k|			*hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, 
  523|  1.53k|				*rrset_flags);
  524|  1.53k|			*rrset_prev = msgparse_hashtable_lookup(msg, pkt, 
  525|  1.53k|				*hash, *rrset_flags, dname, dnamelen, covtype, 
  526|  1.53k|				dclass);
  527|  1.53k|			if(!*rrset_prev) /* untwiddle if not found */
  ------------------
  |  Branch (527:7): [True: 1.23k, False: 291]
  ------------------
  528|  1.23k|				*rrset_flags ^= PACKED_RRSET_NSEC_AT_APEX;
  ------------------
  |  |   53|  1.23k|#define PACKED_RRSET_NSEC_AT_APEX 0x1
  ------------------
  529|  1.53k|		}
  530|  29.4k|		if(!*rrset_prev && covtype == LDNS_RR_TYPE_SOA) {
  ------------------
  |  Branch (530:6): [True: 12.4k, False: 17.0k]
  |  Branch (530:22): [True: 1.84k, False: 10.5k]
  ------------------
  531|       |			/* if SOA try with SOA neg flag twiddled */
  532|  1.84k|			*rrset_flags ^= PACKED_RRSET_SOA_NEG;
  ------------------
  |  |   59|  1.84k|#define PACKED_RRSET_SOA_NEG 0x4
  ------------------
  533|  1.84k|			*hash = pkt_hash_rrset_rest(dname_h, covtype, dclass, 
  534|  1.84k|				*rrset_flags);
  535|  1.84k|			*rrset_prev = msgparse_hashtable_lookup(msg, pkt, 
  536|  1.84k|				*hash, *rrset_flags, dname, dnamelen, covtype, 
  537|  1.84k|				dclass);
  538|  1.84k|			if(!*rrset_prev) /* untwiddle if not found */
  ------------------
  |  Branch (538:7): [True: 1.42k, False: 420]
  ------------------
  539|  1.42k|				*rrset_flags ^= PACKED_RRSET_SOA_NEG;
  ------------------
  |  |   59|  1.42k|#define PACKED_RRSET_SOA_NEG 0x4
  ------------------
  540|  1.84k|		}
  541|  29.4k|		if(*rrset_prev) {
  ------------------
  |  Branch (541:6): [True: 17.4k, False: 12.0k]
  ------------------
  542|  17.4k|			*prev_dname_first = (*rrset_prev)->dname;
  543|  17.4k|			*prev_dname_last = dname;
  544|  17.4k|			*prev_dnamelen = dnamelen;
  545|  17.4k|			*prev_type = covtype;
  546|  17.4k|			*prev_dclass = dclass;
  547|  17.4k|			return 1;
  548|  17.4k|		}
  549|  29.4k|	}
  550|   745k|	if(type != LDNS_RR_TYPE_RRSIG) {
  ------------------
  |  Branch (550:5): [True: 721k, False: 23.5k]
  ------------------
  551|   721k|		int hasother = 0;
  552|       |		/* find matching rrsig */
  553|   721k|		*hash = pkt_hash_rrset_rest(dname_h, LDNS_RR_TYPE_RRSIG, 
  554|   721k|			dclass, 0);
  555|   721k|		*rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, 
  556|   721k|			0, dname, dnamelen, LDNS_RR_TYPE_RRSIG, 
  557|   721k|			dclass);
  558|   721k|		if(*rrset_prev && rrset_has_sigover(pkt, *rrset_prev, type,
  ------------------
  |  Branch (558:6): [True: 214k, False: 506k]
  |  Branch (558:21): [True: 5.35k, False: 209k]
  ------------------
  559|   214k|			&hasother)) {
  560|       |			/* yes! */
  561|  5.35k|			*prev_dname_first = (*rrset_prev)->dname;
  562|  5.35k|			*prev_dname_last = dname;
  563|  5.35k|			*prev_dnamelen = dnamelen;
  564|  5.35k|			*prev_type = type;
  565|  5.35k|			*prev_dclass = dclass;
  566|  5.35k|			*rrset_prev = change_rrsig_rrset(*rrset_prev, msg, 
  567|  5.35k|				pkt, type, *rrset_flags, hasother, section, 
  568|  5.35k|				region);
  569|  5.35k|			if(!*rrset_prev) return 0;
  ------------------
  |  Branch (569:7): [True: 0, False: 5.35k]
  ------------------
  570|  5.35k|			return 1;
  571|  5.35k|		}
  572|   721k|	}
  573|       |
  574|   739k|	*hash = pkt_hash_rrset_rest(dname_h, type, dclass, *rrset_flags);
  575|   739k|	*rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash, *rrset_flags, 
  576|   739k|		dname, dnamelen, type, dclass);
  577|   739k|	if(*rrset_prev)
  ------------------
  |  Branch (577:5): [True: 615k, False: 124k]
  ------------------
  578|   615k|		*prev_dname_first = (*rrset_prev)->dname;
  579|   124k|	else 	*prev_dname_first = dname;
  580|   739k|	*prev_dname_last = dname;
  581|   739k|	*prev_dnamelen = dnamelen;
  582|   739k|	*prev_type = type;
  583|   739k|	*prev_dclass = dclass;
  584|   739k|	return 1;
  585|   745k|}
msgparse.c:pkt_hash_rrset_first:
  194|  1.71M|{
  195|       |	/* works together with pkt_hash_rrset_rest */
  196|       |	/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
  197|       |	/* this routine handles compressed names */
  198|  1.71M|	hashvalue_type h = 0xab;
  199|  1.71M|	h = dname_pkt_hash(pkt, dname, h);
  200|  1.71M|	return h;
  201|  1.71M|}
msgparse.c:smart_compare:
   65|   968k|{
   66|   968k|	if(LABEL_IS_PTR(*dnow)) {
  ------------------
  |  |  233|   968k|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 13.9k, False: 954k]
  |  |  ------------------
  ------------------
   67|       |		/* ptr points to a previous dname */
   68|  13.9k|		uint8_t* p;
   69|  13.9k|		if((size_t)PTR_OFFSET(dnow[0], dnow[1])
  ------------------
  |  |  236|  13.9k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
  |  Branch (69:6): [True: 0, False: 13.9k]
  ------------------
   70|  13.9k|			>= sldns_buffer_limit(pkt))
   71|      0|			return -1;
   72|  13.9k|		p = sldns_buffer_at(pkt, PTR_OFFSET(dnow[0], dnow[1]));
  ------------------
  |  |  236|  13.9k|#define PTR_OFFSET(x, y) ( ((x)&0x3f)<<8 | (y) )
  ------------------
   73|  13.9k|		if( p == dprfirst || p == dprlast )
  ------------------
  |  Branch (73:7): [True: 1.11k, False: 12.8k]
  |  Branch (73:24): [True: 27, False: 12.8k]
  ------------------
   74|  1.13k|			return 0;
   75|       |		/* prev dname is also a ptr, both ptrs are the same. */
   76|  12.8k|		if(LABEL_IS_PTR(*dprlast) &&
  ------------------
  |  |  233|  25.6k|#define LABEL_IS_PTR(x) ( ((x)&0xc0) == 0xc0 )
  |  |  ------------------
  |  |  |  Branch (233:25): [True: 11.1k, False: 1.72k]
  |  |  ------------------
  ------------------
   77|  11.1k|			dprlast[0] == dnow[0] && dprlast[1] == dnow[1])
  ------------------
  |  Branch (77:4): [True: 10.0k, False: 1.02k]
  |  Branch (77:29): [True: 9.12k, False: 967]
  ------------------
   78|  9.12k|			return 0;
   79|  12.8k|	}
   80|   958k|	return dname_pkt_compare(pkt, dnow, dprlast);
   81|   968k|}
msgparse.c:pkt_rrsig_covered_equals:
  270|  4.53M|{
  271|  4.53M|	uint16_t t;
  272|  4.53M|	if(pkt_rrsig_covered(pkt, here, &t) && t == type)
  ------------------
  |  Branch (272:5): [True: 669k, False: 3.86M]
  |  Branch (272:41): [True: 179k, False: 490k]
  ------------------
  273|   179k|		return 1;
  274|  4.35M|	return 0;
  275|  4.53M|}
msgparse.c:pkt_rrset_flags:
  167|   762k|{
  168|   762k|	uint32_t f = 0;
  169|   762k|	if(type == LDNS_RR_TYPE_NSEC && nsec_at_apex(pkt, budget, limit)) {
  ------------------
  |  Branch (169:5): [True: 40.0k, False: 722k]
  |  Branch (169:34): [True: 2.41k, False: 37.5k]
  ------------------
  170|  2.41k|		f |= PACKED_RRSET_NSEC_AT_APEX;
  ------------------
  |  |   53|  2.41k|#define PACKED_RRSET_NSEC_AT_APEX 0x1
  ------------------
  171|   760k|	} else if(type == LDNS_RR_TYPE_SOA && sec == LDNS_SECTION_AUTHORITY) {
  ------------------
  |  Branch (171:12): [True: 3.25k, False: 757k]
  |  Branch (171:40): [True: 1.12k, False: 2.13k]
  ------------------
  172|  1.12k|		f |= PACKED_RRSET_SOA_NEG;
  ------------------
  |  |   59|  1.12k|#define PACKED_RRSET_SOA_NEG 0x4
  ------------------
  173|  1.12k|	}
  174|   762k|	return f;
  175|   762k|}
msgparse.c:nsec_at_apex:
  121|  40.0k|{
  122|       |	/* we are at ttl position in packet. */
  123|  40.0k|	size_t pos = sldns_buffer_position(pkt);
  124|  40.0k|	uint16_t rdatalen;
  125|  40.0k|	if(sldns_buffer_remaining(pkt) < 7) /* ttl+len+root */
  ------------------
  |  Branch (125:5): [True: 45, False: 39.9k]
  ------------------
  126|     45|		return 0; /* eek! */
  127|  39.9k|	sldns_buffer_skip(pkt, 4); /* ttl */;
  128|  39.9k|	rdatalen = sldns_buffer_read_u16(pkt);
  129|  39.9k|	if(sldns_buffer_remaining(pkt) < rdatalen) {
  ------------------
  |  Branch (129:5): [True: 53, False: 39.9k]
  ------------------
  130|     53|		sldns_buffer_set_position(pkt, pos);
  131|     53|		return 0; /* parse error happens later */
  132|     53|	}
  133|       |	/* must validate the nsec next domain name format */
  134|  39.9k|	if(pkt_dname_len_budget(pkt, budget, limit) == 0) {
  ------------------
  |  Branch (134:5): [True: 3.92k, False: 35.9k]
  ------------------
  135|  3.92k|		sldns_buffer_set_position(pkt, pos);
  136|  3.92k|		return 0; /* parse error */
  137|  3.92k|	}
  138|       |
  139|       |	/* see if SOA bit is set. */
  140|  35.9k|	if(sldns_buffer_position(pkt) < pos+6+rdatalen) {
  ------------------
  |  Branch (140:5): [True: 7.91k, False: 28.0k]
  ------------------
  141|       |		/* nsec type bitmap contains items */
  142|  7.91k|		uint8_t win, blen, bits;
  143|       |		/* need: windownum, bitmap len, firstbyte */
  144|  7.91k|		if(sldns_buffer_position(pkt)+3 > pos+6+rdatalen) {
  ------------------
  |  Branch (144:6): [True: 1.96k, False: 5.95k]
  ------------------
  145|  1.96k|			sldns_buffer_set_position(pkt, pos);
  146|  1.96k|			return 0; /* malformed nsec */
  147|  1.96k|		}
  148|  5.95k|		win = sldns_buffer_read_u8(pkt);
  149|  5.95k|		blen = sldns_buffer_read_u8(pkt);
  150|  5.95k|		bits = sldns_buffer_read_u8(pkt);
  151|       |		/* 0window always first window. bitlen >=1 or parse
  152|       |		   error really. bit 0x2 is SOA. */
  153|  5.95k|		if(win == 0 && blen >= 1 && (bits & 0x02)) {
  ------------------
  |  Branch (153:6): [True: 4.58k, False: 1.36k]
  |  Branch (153:18): [True: 3.24k, False: 1.33k]
  |  Branch (153:31): [True: 2.41k, False: 828]
  ------------------
  154|  2.41k|			sldns_buffer_set_position(pkt, pos);
  155|  2.41k|			return 1;
  156|  2.41k|		}
  157|  5.95k|	}
  158|       |
  159|  31.6k|	sldns_buffer_set_position(pkt, pos);
  160|  31.6k|	return 0;
  161|  35.9k|}
msgparse.c:pkt_rrsig_covered:
  249|  4.57M|{
  250|  4.57M|	size_t pos = sldns_buffer_position(pkt);
  251|  4.57M|	sldns_buffer_set_position(pkt, (size_t)(here-sldns_buffer_begin(pkt)));
  252|       |	/* ttl + len + size of small rrsig(rootlabel, no signature) */
  253|  4.57M|	if(sldns_buffer_remaining(pkt) < 4+2+19) {
  ------------------
  |  Branch (253:5): [True: 730, False: 4.57M]
  ------------------
  254|    730|		sldns_buffer_set_position(pkt, pos);
  255|    730|		return 0;
  256|    730|	}
  257|  4.57M|	sldns_buffer_skip(pkt, 4); /* ttl */
  258|  4.57M|	if(sldns_buffer_read_u16(pkt) < 19) /* too short */ {
  ------------------
  |  Branch (258:5): [True: 3.87M, False: 699k]
  ------------------
  259|  3.87M|		sldns_buffer_set_position(pkt, pos);
  260|  3.87M|		return 0;
  261|  3.87M|	}
  262|   699k|	*type = sldns_buffer_read_u16(pkt);
  263|   699k|	sldns_buffer_set_position(pkt, pos);
  264|   699k|	return 1;
  265|  4.57M|}
msgparse.c:pkt_hash_rrset_rest:
  207|  1.49M|{
  208|       |	/* works together with pkt_hash_rrset_first */
  209|       |	/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
  210|  1.49M|	hashvalue_type h;
  211|  1.49M|	h = hashlittle(&type, sizeof(type), dname_h);	/* host order */
  212|  1.49M|	h = hashlittle(&dclass, sizeof(dclass), h);	/* netw order */
  213|  1.49M|	h = hashlittle(&rrset_flags, sizeof(uint32_t), h);
  214|  1.49M|	return h;
  215|  1.49M|}
msgparse.c:rrset_has_sigover:
  339|   214k|{
  340|   214k|	int res = 0;
  341|   214k|	struct rr_parse* rr = rrset->rr_first;
  342|   214k|	log_assert( rrset->type == LDNS_RR_TYPE_RRSIG );
  343|  4.54M|	while(rr) {
  ------------------
  |  Branch (343:8): [True: 4.32M, False: 214k]
  ------------------
  344|  4.32M|		if(pkt_rrsig_covered_equals(pkt, rr->ttl_data, type))
  ------------------
  |  Branch (344:6): [True: 79.8k, False: 4.24M]
  ------------------
  345|  79.8k|			res = 1;
  346|  4.24M|		else	*hasother = 1;
  347|  4.32M|		rr = rr->next;
  348|  4.32M|	}
  349|   214k|	return res;
  350|   214k|}
msgparse.c:change_rrsig_rrset:
  406|  5.35k|{
  407|  5.35k|	struct rrset_parse* dataset = sigset;
  408|  5.35k|	hashvalue_type hash = pkt_hash_rrset(pkt, sigset->dname, datatype, 
  409|  5.35k|		sigset->rrset_class, rrset_flags);
  410|  5.35k|	log_assert( sigset->type == LDNS_RR_TYPE_RRSIG );
  411|  5.35k|	log_assert( datatype != LDNS_RR_TYPE_RRSIG );
  412|  5.35k|	if(hasother) {
  ------------------
  |  Branch (412:5): [True: 4.82k, False: 533]
  ------------------
  413|       |		/* need to make new rrset to hold data type */
  414|  4.82k|		dataset = new_rrset(msg, sigset->dname, sigset->dname_len, 
  415|  4.82k|			datatype, sigset->rrset_class, hash, rrset_flags, 
  416|  4.82k|			section, region);
  417|  4.82k|		if(!dataset) 
  ------------------
  |  Branch (417:6): [True: 0, False: 4.82k]
  ------------------
  418|      0|			return NULL;
  419|  4.82k|		switch(section) {
  420|  2.46k|			case LDNS_SECTION_ANSWER: msg->an_rrsets++; break;
  ------------------
  |  Branch (420:4): [True: 2.46k, False: 2.35k]
  ------------------
  421|  1.33k|			case LDNS_SECTION_AUTHORITY: msg->ns_rrsets++; break;
  ------------------
  |  Branch (421:4): [True: 1.33k, False: 3.48k]
  ------------------
  422|  1.02k|			case LDNS_SECTION_ADDITIONAL: msg->ar_rrsets++; break;
  ------------------
  |  Branch (422:4): [True: 1.02k, False: 3.79k]
  ------------------
  423|      0|			default: log_assert(0);
  ------------------
  |  Branch (423:4): [True: 0, False: 4.82k]
  ------------------
  424|  4.82k|		}
  425|  4.82k|		if(!moveover_rrsigs(pkt, region, sigset, dataset, 
  ------------------
  |  Branch (425:6): [True: 0, False: 4.82k]
  ------------------
  426|  4.82k|			msg->qtype == LDNS_RR_TYPE_RRSIG ||
  ------------------
  |  Branch (426:4): [True: 3.53k, False: 1.28k]
  ------------------
  427|  1.28k|			(msg->qtype == LDNS_RR_TYPE_ANY &&
  ------------------
  |  Branch (427:5): [True: 1.01k, False: 275]
  ------------------
  428|  1.01k|			section != LDNS_SECTION_ANSWER) ))
  ------------------
  |  Branch (428:4): [True: 1.00k, False: 3]
  ------------------
  429|      0|			return NULL;
  430|  4.82k|		return dataset;
  431|  4.82k|	}
  432|       |	/* changeover the type of the rrset to data set */
  433|    533|	msgparse_bucket_remove(msg, dataset);
  434|       |	/* insert into new hash bucket */
  435|    533|	dataset->rrset_bucket_next = msg->hashtable[hash&(PARSE_TABLE_SIZE-1)];
  ------------------
  |  |   79|    533|#define PARSE_TABLE_SIZE 32
  ------------------
  436|    533|	msg->hashtable[hash&(PARSE_TABLE_SIZE-1)] = dataset;
  ------------------
  |  |   79|    533|#define PARSE_TABLE_SIZE 32
  ------------------
  437|    533|	dataset->hash = hash;
  438|       |	/* use section of data item for result */
  439|    533|	change_section(msg, dataset, section);
  440|    533|	dataset->type = datatype;
  441|    533|	dataset->flags = rrset_flags;
  442|    533|	dataset->rrsig_count += dataset->rr_count;
  443|    533|	dataset->rr_count = 0;
  444|       |	/* move sigs to end of siglist */
  445|    533|	if(dataset->rrsig_last)
  ------------------
  |  Branch (445:5): [True: 0, False: 533]
  ------------------
  446|      0|		dataset->rrsig_last->next = dataset->rr_first;
  447|    533|	else	dataset->rrsig_first = dataset->rr_first;
  448|    533|	dataset->rrsig_last = dataset->rr_last;
  449|    533|	dataset->rr_first = 0;
  450|    533|	dataset->rr_last = 0;
  451|    533|	return dataset;
  452|  5.35k|}
msgparse.c:moveover_rrsigs:
  356|  4.82k|{
  357|  4.82k|	struct rr_parse* sig = sigset->rr_first;
  358|  4.82k|	struct rr_parse* prev = NULL;
  359|  4.82k|	struct rr_parse* insert;
  360|  4.82k|	struct rr_parse* nextsig;
  361|   170k|	while(sig) {
  ------------------
  |  Branch (361:8): [True: 165k, False: 4.82k]
  ------------------
  362|   165k|		nextsig = sig->next;
  363|   165k|		if(pkt_rrsig_covered_equals(pkt, sig->ttl_data, 
  ------------------
  |  Branch (363:6): [True: 79.0k, False: 86.8k]
  ------------------
  364|   165k|			dataset->type)) {
  365|  79.0k|			if(duplicate) {
  ------------------
  |  Branch (365:7): [True: 77.1k, False: 1.88k]
  ------------------
  366|       |				/* new */
  367|  77.1k|				insert = (struct rr_parse*)regional_alloc(
  368|  77.1k|					region, sizeof(struct rr_parse));
  369|  77.1k|				if(!insert) return 0;
  ------------------
  |  Branch (369:8): [True: 0, False: 77.1k]
  ------------------
  370|  77.1k|				insert->outside_packet = 0;
  371|  77.1k|				insert->ttl_data = sig->ttl_data;
  372|  77.1k|				insert->size = sig->size;
  373|       |				/* prev not used */
  374|  77.1k|			} else {
  375|       |				/* remove from sigset */
  376|  1.88k|				if(prev) prev->next = sig->next;
  ------------------
  |  Branch (376:8): [True: 1.29k, False: 588]
  ------------------
  377|    588|				else	sigset->rr_first = sig->next;
  378|  1.88k|				if(sigset->rr_last == sig)
  ------------------
  |  Branch (378:8): [True: 185, False: 1.69k]
  ------------------
  379|    185|					sigset->rr_last = prev;
  380|  1.88k|				sigset->rr_count--;
  381|  1.88k|				sigset->size -= sig->size;
  382|  1.88k|				insert = sig;
  383|       |				/* prev not changed */
  384|  1.88k|			}
  385|       |			/* add to dataset */
  386|  79.0k|			dataset->rrsig_count++;
  387|  79.0k|			insert->next = 0;
  388|  79.0k|			if(dataset->rrsig_last) 
  ------------------
  |  Branch (388:7): [True: 74.2k, False: 4.82k]
  ------------------
  389|  74.2k|				dataset->rrsig_last->next = insert;
  390|  4.82k|			else	dataset->rrsig_first = insert;
  391|  79.0k|			dataset->rrsig_last = insert;
  392|  79.0k|			dataset->size += insert->size;
  393|  86.8k|		} else  {
  394|  86.8k|			prev = sig;
  395|  86.8k|		}
  396|   165k|		sig = nextsig;
  397|   165k|	}
  398|  4.82k|	return 1;
  399|  4.82k|}
msgparse.c:change_section:
  295|    533|{
  296|    533|	struct rrset_parse *p, *prev;
  297|       |	/* remove from list */
  298|    533|	if(section == rrset->section)
  ------------------
  |  Branch (298:5): [True: 406, False: 127]
  ------------------
  299|    406|		return;
  300|    127|	p = msg->rrset_first;
  301|    127|	prev = 0;
  302|  1.32k|	while(p) {
  ------------------
  |  Branch (302:8): [True: 1.32k, False: 0]
  ------------------
  303|  1.32k|		if(p == rrset) {
  ------------------
  |  Branch (303:6): [True: 127, False: 1.19k]
  ------------------
  304|    127|			if(prev) prev->rrset_all_next = p->rrset_all_next;
  ------------------
  |  Branch (304:7): [True: 75, False: 52]
  ------------------
  305|     52|			else	msg->rrset_first = p->rrset_all_next;
  306|    127|			if(msg->rrset_last == rrset)
  ------------------
  |  Branch (306:7): [True: 21, False: 106]
  ------------------
  307|     21|				msg->rrset_last = prev;
  308|    127|			break;
  309|    127|		}
  310|  1.19k|		prev = p;
  311|  1.19k|		p = p->rrset_all_next;
  312|  1.19k|	}
  313|       |	/* remove from count */
  314|    127|	switch(rrset->section) {
  315|     71|		case LDNS_SECTION_ANSWER: msg->an_rrsets--; break;
  ------------------
  |  Branch (315:3): [True: 71, False: 56]
  ------------------
  316|     56|		case LDNS_SECTION_AUTHORITY: msg->ns_rrsets--; break;
  ------------------
  |  Branch (316:3): [True: 56, False: 71]
  ------------------
  317|      0|		case LDNS_SECTION_ADDITIONAL: msg->ar_rrsets--; break;
  ------------------
  |  Branch (317:3): [True: 0, False: 127]
  ------------------
  318|      0|		default: log_assert(0);
  ------------------
  |  Branch (318:3): [True: 0, False: 127]
  ------------------
  319|    127|	}
  320|       |	/* insert at end of list */
  321|    127|	rrset->rrset_all_next = 0;
  322|    127|	if(msg->rrset_last)
  ------------------
  |  Branch (322:5): [True: 117, False: 10]
  ------------------
  323|    117|		msg->rrset_last->rrset_all_next = rrset;
  324|     10|	else	msg->rrset_first = rrset;
  325|    127|	msg->rrset_last = rrset;
  326|       |	/* up count of new section */
  327|    127|	switch(section) {
  328|     52|		case LDNS_SECTION_AUTHORITY: msg->ns_rrsets++; break;
  ------------------
  |  Branch (328:3): [True: 52, False: 75]
  ------------------
  329|     75|		case LDNS_SECTION_ADDITIONAL: msg->ar_rrsets++; break;
  ------------------
  |  Branch (329:3): [True: 75, False: 52]
  ------------------
  330|      0|		default: log_assert(0);
  ------------------
  |  Branch (330:3): [True: 0, False: 127]
  ------------------
  331|    127|	}
  332|    127|	rrset->section = section;
  333|    127|}
msgparse.c:new_rrset:
   91|   129k|{
   92|   129k|	struct rrset_parse* p = regional_alloc(region, sizeof(*p));
   93|   129k|	if(!p) return NULL;
  ------------------
  |  Branch (93:5): [True: 0, False: 129k]
  ------------------
   94|   129k|	p->rrset_bucket_next = msg->hashtable[hash & (PARSE_TABLE_SIZE-1)];
  ------------------
  |  |   79|   129k|#define PARSE_TABLE_SIZE 32
  ------------------
   95|   129k|	msg->hashtable[hash & (PARSE_TABLE_SIZE-1)] = p;
  ------------------
  |  |   79|   129k|#define PARSE_TABLE_SIZE 32
  ------------------
   96|   129k|	p->rrset_all_next = 0;
   97|   129k|	if(msg->rrset_last)
  ------------------
  |  Branch (97:5): [True: 125k, False: 4.42k]
  ------------------
   98|   125k|		msg->rrset_last->rrset_all_next = p;
   99|  4.42k|	else 	msg->rrset_first = p;
  100|   129k|	msg->rrset_last = p;
  101|   129k|	p->hash = hash;
  102|   129k|	p->section = section;
  103|   129k|	p->dname = dname;
  104|   129k|	p->dname_len = dnamelen;
  105|   129k|	p->type = type;
  106|   129k|	p->rrset_class = dclass;
  107|   129k|	p->flags = rrset_flags;
  108|   129k|	p->rr_count = 0;
  109|   129k|	p->size = 0;
  110|   129k|	p->rr_first = 0;
  111|   129k|	p->rr_last = 0;
  112|   129k|	p->rrsig_count = 0;
  113|   129k|	p->rrsig_first = 0;
  114|   129k|	p->rrsig_last = 0;
  115|   129k|	return p;
  116|   129k|}
msgparse.c:add_rr_to_rrset:
  776|  1.71M|{
  777|  1.71M|	struct rr_parse* rr;
  778|       |	/* check section of rrset. */
  779|  1.71M|	if(rrset->section != section && type != LDNS_RR_TYPE_RRSIG &&
  ------------------
  |  Branch (779:5): [True: 365k, False: 1.35M]
  |  Branch (779:34): [True: 352k, False: 13.2k]
  ------------------
  780|   352k|		rrset->type != LDNS_RR_TYPE_RRSIG) {
  ------------------
  |  Branch (780:3): [True: 352k, False: 0]
  ------------------
  781|       |		/* silently drop it - we drop the last part, since
  782|       |		 * trust in rr data depends on the section it is in. 
  783|       |		 * the less trustworthy part is discarded. 
  784|       |		 * also the last part is more likely to be incomplete.
  785|       |		 * RFC 2181: must put RRset only once in response. */
  786|       |		/*
  787|       |		verbose(VERB_QUERY, "Packet contains rrset data in "
  788|       |			"multiple sections, dropped last part.");
  789|       |		log_buf(VERB_QUERY, "packet was", pkt);
  790|       |		*/
  791|       |		/* forwards */
  792|   352k|		if(!skip_ttl_rdata(pkt))
  ------------------
  |  Branch (792:6): [True: 64, False: 352k]
  ------------------
  793|     64|			return LDNS_RCODE_FORMERR;
  794|   352k|		return 0;
  795|   352k|	} 
  796|       |
  797|  1.36M|	if( (msg->qtype == LDNS_RR_TYPE_RRSIG ||
  ------------------
  |  Branch (797:7): [True: 55.4k, False: 1.31M]
  ------------------
  798|  1.31M|	     msg->qtype == LDNS_RR_TYPE_ANY) 
  ------------------
  |  Branch (798:7): [True: 94.5k, False: 1.21M]
  ------------------
  799|   149k|	    && sig_is_double(pkt, rrset, sldns_buffer_current(pkt))) {
  ------------------
  |  Branch (799:9): [True: 11.8k, False: 138k]
  ------------------
  800|  11.8k|		if(!skip_ttl_rdata(pkt))
  ------------------
  |  Branch (800:6): [True: 0, False: 11.8k]
  ------------------
  801|      0|			return LDNS_RCODE_FORMERR;
  802|  11.8k|		return 0;
  803|  11.8k|	}
  804|       |	
  805|       |	/* create rr */
  806|  1.35M|	if(!(rr = (struct rr_parse*)regional_alloc(region, sizeof(*rr))))
  ------------------
  |  Branch (806:5): [True: 0, False: 1.35M]
  ------------------
  807|      0|		return LDNS_RCODE_SERVFAIL;
  808|  1.35M|	rr->outside_packet = 0;
  809|  1.35M|	rr->ttl_data = sldns_buffer_current(pkt);
  810|  1.35M|	rr->next = 0;
  811|  1.35M|	if(type == LDNS_RR_TYPE_RRSIG && rrset->type != LDNS_RR_TYPE_RRSIG) {
  ------------------
  |  Branch (811:5): [True: 48.7k, False: 1.30M]
  |  Branch (811:35): [True: 23.7k, False: 24.9k]
  ------------------
  812|  23.7k|		if(rrset->rrsig_last) 
  ------------------
  |  Branch (812:6): [True: 23.1k, False: 652]
  ------------------
  813|  23.1k|			rrset->rrsig_last->next = rr;
  814|    652|		else	rrset->rrsig_first = rr;
  815|  23.7k|		rrset->rrsig_last = rr;
  816|  23.7k|		rrset->rrsig_count++;
  817|  1.33M|	} else {
  818|  1.33M|		if(rrset->rr_last)
  ------------------
  |  Branch (818:6): [True: 1.20M, False: 130k]
  ------------------
  819|  1.20M|			rrset->rr_last->next = rr;
  820|   130k|		else	rrset->rr_first = rr;
  821|  1.33M|		rrset->rr_last = rr;
  822|  1.33M|		rrset->rr_count++;
  823|  1.33M|	}
  824|       |
  825|       |	/* calc decompressed size */
  826|  1.35M|	if(!calc_size(pkt, type, rr, budget, limit)) {
  ------------------
  |  Branch (826:5): [True: 1.19k, False: 1.35M]
  ------------------
  827|  1.19k|		if(*budget > limit) return LDNS_RCODE_SERVFAIL;
  ------------------
  |  Branch (827:6): [True: 9, False: 1.18k]
  ------------------
  828|  1.18k|		return LDNS_RCODE_FORMERR;
  829|  1.19k|	}
  830|  1.35M|	rrset->size += rr->size;
  831|       |
  832|  1.35M|	return 0;
  833|  1.35M|}
msgparse.c:skip_ttl_rdata:
  717|   364k|{
  718|   364k|	uint16_t rdatalen;
  719|   364k|	if(sldns_buffer_remaining(pkt) < 6) /* ttl + rdatalen */
  ------------------
  |  Branch (719:5): [True: 0, False: 364k]
  ------------------
  720|      0|		return 0;
  721|   364k|	sldns_buffer_skip(pkt, 4); /* ttl */
  722|   364k|	rdatalen = sldns_buffer_read_u16(pkt);
  723|   364k|	if(sldns_buffer_remaining(pkt) < rdatalen)
  ------------------
  |  Branch (723:5): [True: 64, False: 364k]
  ------------------
  724|     64|		return 0;
  725|   364k|	sldns_buffer_skip(pkt, (ssize_t)rdatalen);
  726|   364k|	return 1;
  727|   364k|}
msgparse.c:sig_is_double:
  732|   149k|{
  733|   149k|	uint16_t rlen, siglen;
  734|   149k|	size_t pos = sldns_buffer_position(pkt);
  735|   149k|	struct rr_parse* sig;
  736|   149k|	if(sldns_buffer_remaining(pkt) < 6) 
  ------------------
  |  Branch (736:5): [True: 0, False: 149k]
  ------------------
  737|      0|		return 0;
  738|   149k|	sldns_buffer_skip(pkt, 4); /* ttl */
  739|   149k|	rlen = sldns_buffer_read_u16(pkt);
  740|   149k|	if(sldns_buffer_remaining(pkt) < rlen) {
  ------------------
  |  Branch (740:5): [True: 172, False: 149k]
  ------------------
  741|    172|		sldns_buffer_set_position(pkt, pos);
  742|    172|		return 0;
  743|    172|	}
  744|   149k|	sldns_buffer_set_position(pkt, pos);
  745|       |
  746|   149k|	sig = rrset->rrsig_first;
  747|   762k|	while(sig) {
  ------------------
  |  Branch (747:8): [True: 624k, False: 137k]
  ------------------
  748|       |		/* check if rdatalen is same */
  749|   624k|		memmove(&siglen, sig->ttl_data+4, sizeof(siglen));
  750|   624k|		siglen = ntohs(siglen);
  751|       |		/* checks if data in packet is exactly the same, this means
  752|       |		 * also dname in rdata is the same, but rrsig is not allowed
  753|       |		 * to have compressed dnames anyway. If it is compressed anyway
  754|       |		 * it will lead to duplicate rrs for qtype=RRSIG. (or ANY).
  755|       |		 *
  756|       |		 * Cannot use sig->size because size of the other one is not 
  757|       |		 * calculated yet.
  758|       |		 */
  759|   624k|		if(siglen == rlen) {
  ------------------
  |  Branch (759:6): [True: 134k, False: 490k]
  ------------------
  760|   134k|			if(siglen>0 && memcmp(sig->ttl_data+6, ttldata+6, 
  ------------------
  |  Branch (760:7): [True: 134k, False: 0]
  |  Branch (760:19): [True: 11.8k, False: 122k]
  ------------------
  761|   134k|				siglen) == 0) {
  762|       |				/* same! */
  763|  11.8k|				return 1;
  764|  11.8k|			}
  765|   134k|		}
  766|   612k|		sig = sig->next;
  767|   612k|	}
  768|   137k|	return 0;
  769|   149k|}
msgparse.c:calc_size:
  655|  1.35M|{
  656|  1.35M|	const sldns_rr_descriptor* desc;
  657|  1.35M|	uint16_t pkt_len; /* length of rr inside the packet */
  658|  1.35M|	rr->size = sizeof(uint16_t); /* the rdatalen */
  659|  1.35M|	sldns_buffer_skip(pkt, 4); /* skip ttl */
  660|  1.35M|	pkt_len = sldns_buffer_read_u16(pkt);
  661|  1.35M|	if(sldns_buffer_remaining(pkt) < pkt_len)
  ------------------
  |  Branch (661:5): [True: 895, False: 1.35M]
  ------------------
  662|    895|		return 0;
  663|  1.35M|	desc = sldns_rr_descript(type);
  664|  1.35M|	if(pkt_len > 0 && desc && desc->_dname_count > 0) {
  ------------------
  |  Branch (664:5): [True: 567k, False: 785k]
  |  Branch (664:20): [True: 567k, False: 0]
  |  Branch (664:28): [True: 66.8k, False: 500k]
  ------------------
  665|  66.8k|		int count = (int)desc->_dname_count;
  666|  66.8k|		int rdf = 0;
  667|  66.8k|		size_t len;
  668|  66.8k|		size_t oldpos;
  669|       |		/* skip first part. */
  670|   394k|		while(pkt_len > 0 && count) {
  ------------------
  |  Branch (670:9): [True: 341k, False: 53.0k]
  |  Branch (670:24): [True: 328k, False: 13.5k]
  ------------------
  671|   328k|			switch(desc->_wireformat[rdf]) {
  672|  67.4k|			case LDNS_RDF_TYPE_DNAME:
  ------------------
  |  Branch (672:4): [True: 67.4k, False: 260k]
  ------------------
  673|       |				/* decompress every domain name */
  674|  67.4k|				oldpos = sldns_buffer_position(pkt);
  675|  67.4k|				if((len = pkt_dname_len_budget(pkt, budget,
  ------------------
  |  Branch (675:8): [True: 209, False: 67.2k]
  ------------------
  676|  67.4k|					limit)) == 0)
  677|    209|					return 0; /* malformed dname */
  678|  67.2k|				if(sldns_buffer_position(pkt)-oldpos > pkt_len)
  ------------------
  |  Branch (678:8): [True: 23, False: 67.2k]
  ------------------
  679|     23|					return 0; /* dname exceeds rdata */
  680|  67.2k|				pkt_len -= sldns_buffer_position(pkt)-oldpos;
  681|  67.2k|				rr->size += len;
  682|  67.2k|				count--;
  683|  67.2k|				len = 0;
  684|  67.2k|				break;
  685|    576|			case LDNS_RDF_TYPE_STR:
  ------------------
  |  Branch (685:4): [True: 576, False: 327k]
  ------------------
  686|    576|				if(pkt_len < 1) {
  ------------------
  |  Branch (686:8): [True: 0, False: 576]
  ------------------
  687|       |					/* NOTREACHED, due to 'while(>0)' */
  688|      0|					return 0; /* len byte exceeds rdata */
  689|      0|				}
  690|    576|				len = sldns_buffer_current(pkt)[0] + 1;
  691|    576|				break;
  692|   260k|			default:
  ------------------
  |  Branch (692:4): [True: 260k, False: 68.0k]
  ------------------
  693|   260k|				len = get_rdf_size(desc->_wireformat[rdf]);
  694|   328k|			}
  695|   327k|			if(len) {
  ------------------
  |  Branch (695:7): [True: 260k, False: 67.2k]
  ------------------
  696|   260k|				if(pkt_len < len)
  ------------------
  |  Branch (696:8): [True: 37, False: 260k]
  ------------------
  697|     37|					return 0; /* exceeds rdata */
  698|   260k|				pkt_len -= len;
  699|   260k|				sldns_buffer_skip(pkt, (ssize_t)len);
  700|   260k|				rr->size += len;
  701|   260k|			}
  702|   327k|			rdf++;
  703|   327k|		}
  704|       |		/* rdata ended before all _dname_count names were seen */
  705|  66.5k|		if(count != 0)
  ------------------
  |  Branch (705:6): [True: 32, False: 66.5k]
  ------------------
  706|     32|			return 0; /* the rdata is too short. */
  707|  66.5k|	}
  708|       |	/* remaining rdata */
  709|  1.35M|	rr->size += pkt_len;
  710|  1.35M|	sldns_buffer_skip(pkt, (ssize_t)pkt_len);
  711|  1.35M|	return 1;
  712|  1.35M|}

parse_copy_decompress_rrset:
  484|  15.3k|{
  485|  15.3k|	struct packed_rrset_data* data;
  486|  15.3k|	pk->rk.flags = pset->flags;
  487|  15.3k|	pk->rk.dname_len = pset->dname_len;
  488|  15.3k|	if(region)
  ------------------
  |  Branch (488:5): [True: 0, False: 15.3k]
  ------------------
  489|      0|		pk->rk.dname = (uint8_t*)regional_alloc(
  490|      0|			region, pset->dname_len);
  491|  15.3k|	else	pk->rk.dname = 
  492|  15.3k|			(uint8_t*)malloc(pset->dname_len);
  493|  15.3k|	if(!pk->rk.dname)
  ------------------
  |  Branch (493:5): [True: 0, False: 15.3k]
  ------------------
  494|      0|		return 0;
  495|       |	/** copy & decompress dname */
  496|  15.3k|	dname_pkt_copy(pkt, pk->rk.dname, pset->dname);
  497|       |	/** copy over type and class */
  498|  15.3k|	pk->rk.type = htons(pset->type);
  499|  15.3k|	pk->rk.rrset_class = pset->rrset_class;
  500|       |	/** read data part. */
  501|  15.3k|	if(!parse_create_rrset(pkt, pset, &data, region)) {
  ------------------
  |  Branch (501:5): [True: 0, False: 15.3k]
  ------------------
  502|      0|		if(!region) {
  ------------------
  |  Branch (502:6): [True: 0, False: 0]
  ------------------
  503|      0|			free(pk->rk.dname);
  504|      0|			pk->rk.dname = NULL;
  505|      0|		}
  506|      0|		return 0;
  507|      0|	}
  508|  15.3k|	pk->entry.data = (void*)data;
  509|  15.3k|	pk->entry.key = (void*)pk;
  510|  15.3k|	pk->rk.flags |= (data->ttl == 0) ? PACKED_RRSET_UPSTREAM_0TTL : 0;
  ------------------
  |  |   74|    921|#define PACKED_RRSET_UPSTREAM_0TTL 0x20
  ------------------
  |  Branch (510:18): [True: 921, False: 14.4k]
  ------------------
  511|  15.3k|	if( (pk->rk.flags & PACKED_RRSET_UPSTREAM_0TTL) != 0)
  ------------------
  |  |   74|  15.3k|#define PACKED_RRSET_UPSTREAM_0TTL 0x20
  ------------------
  |  Branch (511:6): [True: 921, False: 14.4k]
  ------------------
  512|    921|		pk->entry.hash = rrset_key_hash(&pk->rk);
  513|  14.4k|	else
  514|  14.4k|		pk->entry.hash = pset->hash;
  515|  15.3k|	data->trust = get_rrset_trust(msg, pset);
  516|  15.3k|	return 1;
  517|  15.3k|}
edns_opt_list_append:
 1215|  1.93k|{
 1216|  1.93k|	struct edns_option** prevp;
 1217|  1.93k|	struct edns_option* opt;
 1218|       |
 1219|       |	/* allocate new element */
 1220|  1.93k|	opt = (struct edns_option*)regional_alloc(region, sizeof(*opt));
 1221|  1.93k|	if(!opt)
  ------------------
  |  Branch (1221:5): [True: 0, False: 1.93k]
  ------------------
 1222|      0|		return 0;
 1223|  1.93k|	opt->next = NULL;
 1224|  1.93k|	opt->opt_code = code;
 1225|  1.93k|	opt->opt_len = len;
 1226|  1.93k|	opt->opt_data = NULL;
 1227|  1.93k|	if(len > 0) {
  ------------------
  |  Branch (1227:5): [True: 590, False: 1.34k]
  ------------------
 1228|    590|		opt->opt_data = regional_alloc_init(region, data, len);
 1229|    590|		if(!opt->opt_data)
  ------------------
  |  Branch (1229:6): [True: 0, False: 590]
  ------------------
 1230|      0|			return 0;
 1231|    590|	}
 1232|       |
 1233|       |	/* append at end of list */
 1234|  1.93k|	prevp = list;
 1235|  52.6k|	while(*prevp != NULL) {
  ------------------
  |  Branch (1235:8): [True: 50.6k, False: 1.93k]
  ------------------
 1236|  50.6k|		prevp = &((*prevp)->next);
 1237|  50.6k|	}
 1238|  1.93k|	*prevp = opt;
 1239|  1.93k|	return 1;
 1240|  1.93k|}
msgreply.c:parse_create_rrset:
  416|  15.3k|{
  417|       |	/* allocate */
  418|  15.3k|	size_t s;
  419|  15.3k|	if(pset->rr_count > RR_COUNT_MAX || pset->rrsig_count > RR_COUNT_MAX ||
  ------------------
  |  |   82|  30.7k|#define RR_COUNT_MAX 0xffffff
  ------------------
              	if(pset->rr_count > RR_COUNT_MAX || pset->rrsig_count > RR_COUNT_MAX ||
  ------------------
  |  |   82|  30.7k|#define RR_COUNT_MAX 0xffffff
  ------------------
  |  Branch (419:5): [True: 0, False: 15.3k]
  |  Branch (419:38): [True: 0, False: 15.3k]
  ------------------
  420|  15.3k|		pset->size > RR_COUNT_MAX)
  ------------------
  |  |   82|  15.3k|#define RR_COUNT_MAX 0xffffff
  ------------------
  |  Branch (420:3): [True: 0, False: 15.3k]
  ------------------
  421|      0|		return 0; /* protect against integer overflow */
  422|  15.3k|	s = sizeof(struct packed_rrset_data) + 
  423|  15.3k|		(pset->rr_count + pset->rrsig_count) * 
  424|  15.3k|		(sizeof(size_t)+sizeof(uint8_t*)+sizeof(time_t)) + 
  425|  15.3k|		pset->size;
  426|  15.3k|	if(region)
  ------------------
  |  Branch (426:5): [True: 0, False: 15.3k]
  ------------------
  427|      0|		*data = regional_alloc_zero(region, s);
  428|  15.3k|	else	*data = calloc(1, s);
  429|  15.3k|	if(!*data)
  ------------------
  |  Branch (429:5): [True: 0, False: 15.3k]
  ------------------
  430|      0|		return 0;
  431|       |	/* copy & decompress */
  432|  15.3k|	if(!parse_rr_copy(pkt, pset, *data)) {
  ------------------
  |  Branch (432:5): [True: 0, False: 15.3k]
  ------------------
  433|      0|		if(!region) {
  ------------------
  |  Branch (433:6): [True: 0, False: 0]
  ------------------
  434|      0|			free(*data);
  435|      0|			*data = NULL;
  436|      0|		}
  437|      0|		return 0;
  438|      0|	}
  439|  15.3k|	return 1;
  440|  15.3k|}
msgreply.c:parse_rr_copy:
  373|  15.3k|{
  374|  15.3k|	size_t i;
  375|  15.3k|	struct rr_parse* rr = pset->rr_first;
  376|  15.3k|	uint8_t* nextrdata;
  377|  15.3k|	size_t total = pset->rr_count + pset->rrsig_count;
  378|  15.3k|	data->ttl = MAX_TTL;
  379|  15.3k|	data->count = pset->rr_count;
  380|  15.3k|	data->rrsig_count = pset->rrsig_count;
  381|  15.3k|	data->trust = rrset_trust_none;
  382|  15.3k|	data->security = sec_status_unchecked;
  383|       |	/* layout: struct - rr_len - rr_data - rr_ttl - rdata - rrsig */
  384|  15.3k|	data->rr_len = (size_t*)((uint8_t*)data + 
  385|  15.3k|		sizeof(struct packed_rrset_data));
  386|  15.3k|	data->rr_data = (uint8_t**)&(data->rr_len[total]);
  387|  15.3k|	data->rr_ttl = (time_t*)&(data->rr_data[total]);
  388|  15.3k|	nextrdata = (uint8_t*)&(data->rr_ttl[total]);
  389|   303k|	for(i=0; i<data->count; i++) {
  ------------------
  |  Branch (389:11): [True: 288k, False: 15.3k]
  ------------------
  390|   288k|		data->rr_len[i] = rr->size;
  391|   288k|		data->rr_data[i] = nextrdata;
  392|   288k|		nextrdata += rr->size;
  393|   288k|		if(!rdata_copy(pkt, data, data->rr_data[i], rr, 
  ------------------
  |  Branch (393:6): [True: 0, False: 288k]
  ------------------
  394|   288k|			&data->rr_ttl[i], pset->type, pset->section))
  395|      0|			return 0;
  396|   288k|		rr = rr->next;
  397|   288k|	}
  398|       |	/* if rrsig, its rdata is at nextrdata */
  399|  15.3k|	rr = pset->rrsig_first;
  400|  25.5k|	for(i=data->count; i<total; i++) {
  ------------------
  |  Branch (400:21): [True: 10.1k, False: 15.3k]
  ------------------
  401|  10.1k|		data->rr_len[i] = rr->size;
  402|  10.1k|		data->rr_data[i] = nextrdata;
  403|  10.1k|		nextrdata += rr->size;
  404|  10.1k|		if(!rdata_copy(pkt, data, data->rr_data[i], rr, 
  ------------------
  |  Branch (404:6): [True: 0, False: 10.1k]
  ------------------
  405|  10.1k|			&data->rr_ttl[i], LDNS_RR_TYPE_RRSIG, pset->section))
  406|      0|			return 0;
  407|  10.1k|		rr = rr->next;
  408|  10.1k|	}
  409|  15.3k|	return 1;
  410|  15.3k|}
msgreply.c:rdata_copy:
  249|   298k|{
  250|   298k|	uint16_t pkt_len;
  251|   298k|	size_t tolen;
  252|   298k|	uint32_t ttl;
  253|   298k|	const sldns_rr_descriptor* desc;
  254|       |
  255|   298k|	ttl = sldns_read_uint32(rr->ttl_data);
  256|       |	/* RFC 2181 Section 8. if msb of ttl is set treat as if zero. */
  257|       |	/* RFC 8767 Section 4. values with high-order bit as positive, not 0.
  258|       |+	 *	As such, it will be capped by MAX_TTL below. */
  259|   298k|	if(type == LDNS_RR_TYPE_SOA && section == LDNS_SECTION_AUTHORITY) {
  ------------------
  |  Branch (259:5): [True: 0, False: 298k]
  |  Branch (259:33): [True: 0, False: 0]
  ------------------
  260|       |		/* negative response. see if TTL of SOA record larger than the
  261|       |		 * minimum-ttl in the rdata of the SOA record */
  262|      0|		if(ttl > soa_find_minttl(rr)) ttl = soa_find_minttl(rr);
  ------------------
  |  Branch (262:6): [True: 0, False: 0]
  ------------------
  263|      0|		if(!SERVE_ORIGINAL_TTL) {
  ------------------
  |  Branch (263:6): [True: 0, False: 0]
  ------------------
  264|       |			/* If MIN_NEG_TTL is configured skip setting MIN_TTL */
  265|      0|			if(MIN_NEG_TTL <= 0 && ttl < (uint32_t)MIN_TTL) {
  ------------------
  |  Branch (265:7): [True: 0, False: 0]
  |  Branch (265:27): [True: 0, False: 0]
  ------------------
  266|      0|				ttl = (uint32_t)MIN_TTL;
  267|      0|			}
  268|      0|			if(ttl > (uint32_t)MAX_TTL) ttl = (uint32_t)MAX_TTL;
  ------------------
  |  Branch (268:7): [True: 0, False: 0]
  ------------------
  269|      0|		}
  270|       |		/* MAX_NEG_TTL overrides the min and max ttl of everything
  271|       |		 * else; it is for a more specific record */
  272|      0|		if(ttl > (uint32_t)MAX_NEG_TTL) ttl = (uint32_t)MAX_NEG_TTL;
  ------------------
  |  Branch (272:6): [True: 0, False: 0]
  ------------------
  273|       |		/* MIN_NEG_TTL overrides the min and max ttl of everything
  274|       |		 * else if configured; it is for a more specific record */
  275|      0|		if(MIN_NEG_TTL > 0 && ttl < (uint32_t)MIN_NEG_TTL) {
  ------------------
  |  Branch (275:6): [True: 0, False: 0]
  |  Branch (275:25): [True: 0, False: 0]
  ------------------
  276|      0|			ttl = (uint32_t)MIN_NEG_TTL;
  277|      0|		}
  278|   298k|	} else if(!SERVE_ORIGINAL_TTL) {
  ------------------
  |  Branch (278:12): [True: 298k, False: 0]
  ------------------
  279|   298k|		if(ttl < (uint32_t)MIN_TTL) ttl = (uint32_t)MIN_TTL;
  ------------------
  |  Branch (279:6): [True: 0, False: 298k]
  ------------------
  280|   298k|		if(ttl > (uint32_t)MAX_TTL) ttl = (uint32_t)MAX_TTL;
  ------------------
  |  Branch (280:6): [True: 287k, False: 10.5k]
  ------------------
  281|   298k|	}
  282|   298k|	if((time_t)ttl < data->ttl)
  ------------------
  |  Branch (282:5): [True: 4.04k, False: 294k]
  ------------------
  283|  4.04k|		data->ttl = (time_t)ttl;
  284|       |	/* We have concluded the TTL checks */
  285|   298k|	*rr_ttl = (time_t)ttl;
  286|       |
  287|   298k|	if(rr->outside_packet) {
  ------------------
  |  Branch (287:5): [True: 0, False: 298k]
  ------------------
  288|       |		/* uncompressed already, only needs copy */
  289|      0|		memmove(to, rr->ttl_data+sizeof(uint32_t), rr->size);
  290|      0|		return 1;
  291|      0|	}
  292|       |
  293|   298k|	sldns_buffer_set_position(pkt, (size_t)
  294|   298k|		(rr->ttl_data - sldns_buffer_begin(pkt) + sizeof(uint32_t)));
  295|       |	/* insert decompressed size into rdata len stored in memory */
  296|       |	/* -2 because rdatalen bytes are not included. */
  297|   298k|	tolen = rr->size;
  298|   298k|	if(tolen < 2)
  ------------------
  |  Branch (298:5): [True: 0, False: 298k]
  ------------------
  299|      0|		return 0;
  300|   298k|	pkt_len = htons(rr->size - 2);
  301|   298k|	memmove(to, &pkt_len, sizeof(uint16_t));
  302|   298k|	to += 2;
  303|   298k|	tolen -= 2;
  304|       |	/* read packet rdata len */
  305|   298k|	pkt_len = sldns_buffer_read_u16(pkt);
  306|   298k|	if(sldns_buffer_remaining(pkt) < pkt_len)
  ------------------
  |  Branch (306:5): [True: 0, False: 298k]
  ------------------
  307|      0|		return 0;
  308|   298k|	desc = sldns_rr_descript(type);
  309|   298k|	if(pkt_len > 0 && desc && desc->_dname_count > 0) {
  ------------------
  |  Branch (309:5): [True: 298k, False: 0]
  |  Branch (309:20): [True: 298k, False: 0]
  |  Branch (309:28): [True: 10.1k, False: 288k]
  ------------------
  310|  10.1k|		int count = (int)desc->_dname_count;
  311|  10.1k|		int rdf = 0;
  312|  10.1k|		size_t len, dlen;
  313|  10.1k|		size_t oldpos, newpos;
  314|       |		/* decompress dnames. */
  315|  91.4k|		while(pkt_len > 0 && count) {
  ------------------
  |  Branch (315:9): [True: 82.4k, False: 8.98k]
  |  Branch (315:24): [True: 81.2k, False: 1.18k]
  ------------------
  316|  81.2k|			switch(desc->_wireformat[rdf]) {
  317|  10.1k|			case LDNS_RDF_TYPE_DNAME:
  ------------------
  |  Branch (317:4): [True: 10.1k, False: 71.1k]
  ------------------
  318|  10.1k|				oldpos = sldns_buffer_position(pkt);
  319|  10.1k|				dlen = pkt_dname_len(pkt);
  320|  10.1k|				if(dlen == 0)
  ------------------
  |  Branch (320:8): [True: 0, False: 10.1k]
  ------------------
  321|      0|					return 0; /* malformed */
  322|  10.1k|				if(dlen > tolen)
  ------------------
  |  Branch (322:8): [True: 0, False: 10.1k]
  ------------------
  323|      0|					return 0; /* alloc mismatch */
  324|  10.1k|				newpos = sldns_buffer_position(pkt);
  325|  10.1k|				if(oldpos > newpos)
  ------------------
  |  Branch (325:8): [True: 0, False: 10.1k]
  ------------------
  326|      0|					return 0; /* should have moved forward*/
  327|  10.1k|				sldns_buffer_set_position(pkt, oldpos);
  328|  10.1k|				dname_pkt_copy(pkt, to,
  329|  10.1k|					sldns_buffer_current(pkt));
  330|  10.1k|				sldns_buffer_set_position(pkt, newpos);
  331|  10.1k|				to += dlen;
  332|  10.1k|				tolen -= dlen;
  333|  10.1k|				if(sldns_buffer_position(pkt)-oldpos > pkt_len)
  ------------------
  |  Branch (333:8): [True: 0, False: 10.1k]
  ------------------
  334|      0|					return 0; /* malformed: walks diverged */
  335|  10.1k|				pkt_len -= sldns_buffer_position(pkt)-oldpos;
  336|  10.1k|				count--;
  337|  10.1k|				len = 0;
  338|  10.1k|				break;
  339|      0|			case LDNS_RDF_TYPE_STR:
  ------------------
  |  Branch (339:4): [True: 0, False: 81.2k]
  ------------------
  340|      0|				len = sldns_buffer_current(pkt)[0] + 1;
  341|      0|				break;
  342|  71.1k|			default:
  ------------------
  |  Branch (342:4): [True: 71.1k, False: 10.1k]
  ------------------
  343|  71.1k|				len = get_rdf_size(desc->_wireformat[rdf]);
  344|  71.1k|				break;
  345|  81.2k|			}
  346|  81.2k|			if(len) {
  ------------------
  |  Branch (346:7): [True: 71.1k, False: 10.1k]
  ------------------
  347|  71.1k|				if(len > tolen)
  ------------------
  |  Branch (347:8): [True: 0, False: 71.1k]
  ------------------
  348|      0|					return 0; /* alloc mismatch */
  349|  71.1k|				log_assert(len <= pkt_len);
  350|  71.1k|				memmove(to, sldns_buffer_current(pkt), len);
  351|  71.1k|				to += len;
  352|  71.1k|				tolen -= len;
  353|  71.1k|				sldns_buffer_skip(pkt, (ssize_t)len);
  354|  71.1k|				pkt_len -= len;
  355|  71.1k|			}
  356|  81.2k|			rdf++;
  357|  81.2k|		}
  358|  10.1k|	}
  359|       |	/* copy remaining rdata */
  360|   298k|	if(pkt_len >  0) {
  ------------------
  |  Branch (360:5): [True: 289k, False: 8.98k]
  ------------------
  361|   289k|		if(pkt_len > tolen)
  ------------------
  |  Branch (361:6): [True: 0, False: 289k]
  ------------------
  362|      0|			return 0; /* alloc mismatch */
  363|   289k|		memmove(to, sldns_buffer_current(pkt), pkt_len);
  364|   289k|	}
  365|       |	
  366|   298k|	return 1;
  367|   298k|}
msgreply.c:get_rrset_trust:
  445|  15.3k|{
  446|  15.3k|	uint16_t AA = msg->flags & BIT_AA;
  ------------------
  |  |   70|  15.3k|#define BIT_AA 0x0400
  ------------------
  447|  15.3k|	if(rrset->section == LDNS_SECTION_ANSWER) {
  ------------------
  |  Branch (447:5): [True: 1.21k, False: 14.1k]
  ------------------
  448|  1.21k|		if(AA) {
  ------------------
  |  Branch (448:6): [True: 838, False: 377]
  ------------------
  449|       |			/* RFC2181 says remainder of CNAME chain is nonauth*/
  450|    838|			if(msg->rrset_first && 
  ------------------
  |  Branch (450:7): [True: 838, False: 0]
  ------------------
  451|    838|				msg->rrset_first->section==LDNS_SECTION_ANSWER
  ------------------
  |  Branch (451:5): [True: 838, False: 0]
  ------------------
  452|    838|				&& msg->rrset_first->type==LDNS_RR_TYPE_CNAME){
  ------------------
  |  Branch (452:8): [True: 365, False: 473]
  ------------------
  453|    365|				if(rrset == msg->rrset_first)
  ------------------
  |  Branch (453:8): [True: 0, False: 365]
  ------------------
  454|      0|					return rrset_trust_ans_AA;
  455|    365|				else 	return rrset_trust_ans_noAA;
  456|    365|			}
  457|    473|			if(msg->rrset_first && 
  ------------------
  |  Branch (457:7): [True: 473, False: 0]
  ------------------
  458|    473|				msg->rrset_first->section==LDNS_SECTION_ANSWER
  ------------------
  |  Branch (458:5): [True: 473, False: 0]
  ------------------
  459|    473|				&& msg->rrset_first->type==LDNS_RR_TYPE_DNAME){
  ------------------
  |  Branch (459:8): [True: 211, False: 262]
  ------------------
  460|    211|				if(rrset == msg->rrset_first ||
  ------------------
  |  Branch (460:8): [True: 0, False: 211]
  ------------------
  461|    211|				   rrset == msg->rrset_first->rrset_all_next)
  ------------------
  |  Branch (461:8): [True: 0, False: 211]
  ------------------
  462|      0|					return rrset_trust_ans_AA;
  463|    211|				else 	return rrset_trust_ans_noAA;
  464|    211|			}
  465|    262|			return rrset_trust_ans_AA;
  466|    473|		}
  467|    377|		else	return rrset_trust_ans_noAA;
  468|  14.1k|	} else if(rrset->section == LDNS_SECTION_AUTHORITY) {
  ------------------
  |  Branch (468:12): [True: 5.95k, False: 8.18k]
  ------------------
  469|  5.95k|		if(AA)	return rrset_trust_auth_AA;
  ------------------
  |  Branch (469:6): [True: 2.59k, False: 3.35k]
  ------------------
  470|  3.35k|		else	return rrset_trust_auth_noAA;
  471|  8.18k|	} else {
  472|       |		/* addit section */
  473|  8.18k|		if(AA)	return rrset_trust_add_AA;
  ------------------
  |  Branch (473:6): [True: 7.04k, False: 1.14k]
  ------------------
  474|  1.14k|		else	return rrset_trust_add_noAA;
  475|  8.18k|	}
  476|       |	/* NOTREACHED */
  477|      0|	return rrset_trust_none;
  478|  15.3k|}

ub_rrset_sizefunc:
   71|  15.3k|{
   72|  15.3k|	struct ub_packed_rrset_key* k = (struct ub_packed_rrset_key*)key;
   73|  15.3k|	struct packed_rrset_data* d = (struct packed_rrset_data*)data;
   74|  15.3k|	size_t s = sizeof(struct ub_packed_rrset_key) + k->rk.dname_len;
   75|  15.3k|	s += packed_rrset_sizeof(d) + lock_get_mem(&k->entry.lock);
  ------------------
  |  |   88|  15.3k|#define lock_get_mem(lock) (0) /* nothing */
  ------------------
   76|  15.3k|	return s;
   77|  15.3k|}
packed_rrset_sizeof:
   81|  15.3k|{
   82|  15.3k|	size_t s;
   83|  15.3k|	if(d->rrsig_count > 0) {
  ------------------
  |  Branch (83:5): [True: 192, False: 15.1k]
  ------------------
   84|    192|		s = ((uint8_t*)d->rr_data[d->count+d->rrsig_count-1] - 
   85|    192|			(uint8_t*)d) + d->rr_len[d->count+d->rrsig_count-1];
   86|  15.1k|	} else {
   87|  15.1k|		log_assert(d->count > 0);
   88|  15.1k|		s = ((uint8_t*)d->rr_data[d->count-1] - (uint8_t*)d) + 
   89|  15.1k|			d->rr_len[d->count-1];
   90|  15.1k|	}
   91|  15.3k|	return s;
   92|  15.3k|}
ub_rrset_compare:
   96|    156|{
   97|    156|	struct ub_packed_rrset_key* key1 = (struct ub_packed_rrset_key*)k1;
   98|    156|	struct ub_packed_rrset_key* key2 = (struct ub_packed_rrset_key*)k2;
   99|    156|	int c;
  100|    156|	if(key1 == key2)
  ------------------
  |  Branch (100:5): [True: 0, False: 156]
  ------------------
  101|      0|		return 0;
  102|    156|	if(key1->rk.type != key2->rk.type) {
  ------------------
  |  Branch (102:5): [True: 4, False: 152]
  ------------------
  103|      4|		if(key1->rk.type < key2->rk.type)
  ------------------
  |  Branch (103:6): [True: 2, False: 2]
  ------------------
  104|      2|			return -1;
  105|      2|		return 1;
  106|      4|	}
  107|    152|	if(key1->rk.dname_len != key2->rk.dname_len) {
  ------------------
  |  Branch (107:5): [True: 152, False: 0]
  ------------------
  108|    152|		if(key1->rk.dname_len < key2->rk.dname_len)
  ------------------
  |  Branch (108:6): [True: 80, False: 72]
  ------------------
  109|     80|			return -1;
  110|     72|		return 1;
  111|    152|	}
  112|      0|	if((c=query_dname_compare(key1->rk.dname, key2->rk.dname)) != 0)
  ------------------
  |  Branch (112:5): [True: 0, False: 0]
  ------------------
  113|      0|		return c;
  114|      0|	if(key1->rk.rrset_class != key2->rk.rrset_class) {
  ------------------
  |  Branch (114:5): [True: 0, False: 0]
  ------------------
  115|      0|		if(key1->rk.rrset_class < key2->rk.rrset_class)
  ------------------
  |  Branch (115:6): [True: 0, False: 0]
  ------------------
  116|      0|			return -1;
  117|      0|		return 1;
  118|      0|	}
  119|      0|	if(key1->rk.flags != key2->rk.flags) {
  ------------------
  |  Branch (119:5): [True: 0, False: 0]
  ------------------
  120|      0|		if(key1->rk.flags < key2->rk.flags)
  ------------------
  |  Branch (120:6): [True: 0, False: 0]
  ------------------
  121|      0|			return -1;
  122|      0|		return 1;
  123|      0|	}
  124|      0|	return 0;
  125|      0|}
ub_rrset_key_delete:
  129|  15.3k|{
  130|  15.3k|	struct ub_packed_rrset_key* k = (struct ub_packed_rrset_key*)key;
  131|  15.3k|	struct alloc_cache* a = (struct alloc_cache*)userdata;
  132|  15.3k|	k->id = 0;
  133|  15.3k|	free(k->rk.dname);
  134|       |	k->rk.dname = NULL;
  135|  15.3k|	alloc_special_release(a, k);
  136|  15.3k|}
rrset_data_delete:
  140|  15.3k|{
  141|  15.3k|	struct packed_rrset_data* d = (struct packed_rrset_data*)data;
  142|  15.3k|	free(d);
  143|  15.3k|}
rrset_key_hash:
  164|    921|{
  165|       |	/* type is hashed in host order */
  166|    921|	uint16_t t = ntohs(key->type);
  167|       |	/* Note this MUST be identical to pkt_hash_rrset in msgparse.c */
  168|       |	/* this routine does not have a compressed name */
  169|    921|	hashvalue_type h = 0xab;
  170|    921|	h = dname_query_hash(key->dname, h);
  171|    921|	h = hashlittle(&t, sizeof(t), h);
  172|    921|	h = hashlittle(&key->rrset_class, sizeof(uint16_t), h);
  173|    921|	h = hashlittle(&key->flags, sizeof(uint32_t), h);
  174|    921|	return h;
  175|    921|}
packed_rrset_ttl_add:
  221|  15.3k|{
  222|  15.3k|	size_t i;
  223|  15.3k|	size_t total = data->count + data->rrsig_count;
  224|  15.3k|	data->ttl_add = add;
  225|  15.3k|	data->ttl += add;
  226|   313k|	for(i=0; i<total; i++)
  ------------------
  |  Branch (226:11): [True: 298k, False: 15.3k]
  ------------------
  227|   298k|		data->rr_ttl[i] += add;
  228|  15.3k|}

fptr_whitelist_hash_sizefunc:
  278|  15.3k|{
  279|  15.3k|	if(fptr == &msgreply_sizefunc) return 1;
  ------------------
  |  Branch (279:5): [True: 0, False: 15.3k]
  ------------------
  280|  15.3k|	else if(fptr == &ub_rrset_sizefunc) return 1;
  ------------------
  |  Branch (280:10): [True: 15.3k, False: 0]
  ------------------
  281|      0|	else if(fptr == &infra_sizefunc) return 1;
  ------------------
  |  Branch (281:10): [True: 0, False: 0]
  ------------------
  282|      0|	else if(fptr == &key_entry_sizefunc) return 1;
  ------------------
  |  Branch (282:10): [True: 0, False: 0]
  ------------------
  283|      0|	else if(fptr == &rate_sizefunc) return 1;
  ------------------
  |  Branch (283:10): [True: 0, False: 0]
  ------------------
  284|      0|	else if(fptr == &ip_rate_sizefunc) return 1;
  ------------------
  |  Branch (284:10): [True: 0, False: 0]
  ------------------
  285|      0|	else if(fptr == &test_slabhash_sizefunc) return 1;
  ------------------
  |  Branch (285:10): [True: 0, False: 0]
  ------------------
  286|       |#ifdef CLIENT_SUBNET
  287|       |	else if(fptr == &msg_cache_sizefunc) return 1;
  288|       |#endif
  289|       |#ifdef USE_DNSCRYPT
  290|       |	else if(fptr == &dnsc_shared_secrets_sizefunc) return 1;
  291|       |	else if(fptr == &dnsc_nonces_sizefunc) return 1;
  292|       |#endif
  293|      0|	return 0;
  294|  15.3k|}
fptr_whitelist_hash_compfunc:
  298|  30.7k|{
  299|  30.7k|	if(fptr == &query_info_compare) return 1;
  ------------------
  |  Branch (299:5): [True: 0, False: 30.7k]
  ------------------
  300|  30.7k|	else if(fptr == &ub_rrset_compare) return 1;
  ------------------
  |  Branch (300:10): [True: 30.7k, False: 0]
  ------------------
  301|      0|	else if(fptr == &infra_compfunc) return 1;
  ------------------
  |  Branch (301:10): [True: 0, False: 0]
  ------------------
  302|      0|	else if(fptr == &key_entry_compfunc) return 1;
  ------------------
  |  Branch (302:10): [True: 0, False: 0]
  ------------------
  303|      0|	else if(fptr == &rate_compfunc) return 1;
  ------------------
  |  Branch (303:10): [True: 0, False: 0]
  ------------------
  304|      0|	else if(fptr == &ip_rate_compfunc) return 1;
  ------------------
  |  Branch (304:10): [True: 0, False: 0]
  ------------------
  305|      0|	else if(fptr == &test_slabhash_compfunc) return 1;
  ------------------
  |  Branch (305:10): [True: 0, False: 0]
  ------------------
  306|       |#ifdef USE_DNSCRYPT
  307|       |	else if(fptr == &dnsc_shared_secrets_compfunc) return 1;
  308|       |	else if(fptr == &dnsc_nonces_compfunc) return 1;
  309|       |#endif
  310|      0|	return 0;
  311|  30.7k|}
fptr_whitelist_hash_delkeyfunc:
  315|  15.3k|{
  316|  15.3k|	if(fptr == &query_entry_delete) return 1;
  ------------------
  |  Branch (316:5): [True: 0, False: 15.3k]
  ------------------
  317|  15.3k|	else if(fptr == &ub_rrset_key_delete) return 1;
  ------------------
  |  Branch (317:10): [True: 15.3k, False: 0]
  ------------------
  318|      0|	else if(fptr == &infra_delkeyfunc) return 1;
  ------------------
  |  Branch (318:10): [True: 0, False: 0]
  ------------------
  319|      0|	else if(fptr == &key_entry_delkeyfunc) return 1;
  ------------------
  |  Branch (319:10): [True: 0, False: 0]
  ------------------
  320|      0|	else if(fptr == &rate_delkeyfunc) return 1;
  ------------------
  |  Branch (320:10): [True: 0, False: 0]
  ------------------
  321|      0|	else if(fptr == &ip_rate_delkeyfunc) return 1;
  ------------------
  |  Branch (321:10): [True: 0, False: 0]
  ------------------
  322|      0|	else if(fptr == &test_slabhash_delkey) return 1;
  ------------------
  |  Branch (322:10): [True: 0, False: 0]
  ------------------
  323|       |#ifdef USE_DNSCRYPT
  324|       |	else if(fptr == &dnsc_shared_secrets_delkeyfunc) return 1;
  325|       |	else if(fptr == &dnsc_nonces_delkeyfunc) return 1;
  326|       |#endif
  327|      0|	return 0;
  328|  15.3k|}
fptr_whitelist_hash_deldatafunc:
  332|  15.3k|{
  333|  15.3k|	if(fptr == &reply_info_delete) return 1;
  ------------------
  |  Branch (333:5): [True: 0, False: 15.3k]
  ------------------
  334|  15.3k|	else if(fptr == &rrset_data_delete) return 1;
  ------------------
  |  Branch (334:10): [True: 15.3k, False: 0]
  ------------------
  335|      0|	else if(fptr == &infra_deldatafunc) return 1;
  ------------------
  |  Branch (335:10): [True: 0, False: 0]
  ------------------
  336|      0|	else if(fptr == &key_entry_deldatafunc) return 1;
  ------------------
  |  Branch (336:10): [True: 0, False: 0]
  ------------------
  337|      0|	else if(fptr == &rate_deldatafunc) return 1;
  ------------------
  |  Branch (337:10): [True: 0, False: 0]
  ------------------
  338|      0|	else if(fptr == &test_slabhash_deldata) return 1;
  ------------------
  |  Branch (338:10): [True: 0, False: 0]
  ------------------
  339|       |#ifdef CLIENT_SUBNET
  340|       |	else if(fptr == &subnet_data_delete) return 1;
  341|       |#endif
  342|       |#ifdef USE_DNSCRYPT
  343|       |	else if(fptr == &dnsc_shared_secrets_deldatafunc) return 1;
  344|       |	else if(fptr == &dnsc_nonces_deldatafunc) return 1;
  345|       |#endif
  346|      0|	return 0;
  347|  15.3k|}
fptr_whitelist_hash_markdelfunc:
  351|  15.3k|{
  352|  15.3k|	if(fptr == NULL) return 1;
  ------------------
  |  Branch (352:5): [True: 0, False: 15.3k]
  ------------------
  353|  15.3k|	else if(fptr == &rrset_markdel) return 1;
  ------------------
  |  Branch (353:10): [True: 15.3k, False: 0]
  ------------------
  354|       |#ifdef CLIENT_SUBNET
  355|       |	else if(fptr == &subnet_markdel) return 1;
  356|       |#endif
  357|      0|	return 0;
  358|  15.3k|}

log_init:
  107|  4.66k|{
  108|  4.66k|	FILE *f;
  109|  4.66k|#if !defined(THREADS_DISABLED) && defined(HAVE_PTHREAD)
  110|  4.66k|	(void)pthread_once(&log_lock_once, log_lock_init_once);
  111|       |#else
  112|       |	if(!key_created) {
  113|       |		key_created = 1;
  114|       |		ub_thread_key_create(&logkey, NULL);
  115|       |		lock_basic_init(&log_lock);
  116|       |	}
  117|       |#endif
  118|  4.66k|	lock_basic_lock(&log_lock);
  ------------------
  |  |  103|  4.66k|#define lock_basic_lock(lock) LOCKRET(pthread_mutex_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  4.66k|#define LOCKRET(func) do {\
  |  |  |  |   68|  4.66k|	int lockret_err;		\
  |  |  |  |   69|  4.66k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 4.66k]
  |  |  |  |  ------------------
  |  |  |  |   70|  4.66k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  4.66k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 4.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  119|  4.66k|	if(logfile 
  ------------------
  |  Branch (119:5): [True: 4.66k, False: 1]
  ------------------
  120|      1|#if defined(HAVE_SYSLOG_H) || defined(UB_ON_WINDOWS)
  121|      1|	|| logging_to_syslog
  ------------------
  |  Branch (121:5): [True: 0, False: 1]
  ------------------
  122|  4.66k|#endif
  123|  4.66k|	) {
  124|  4.66k|		lock_basic_unlock(&log_lock); /* verbose() needs the lock */
  ------------------
  |  |  104|  4.66k|#define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  4.66k|#define LOCKRET(func) do {\
  |  |  |  |   68|  4.66k|	int lockret_err;		\
  |  |  |  |   69|  4.66k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 4.66k]
  |  |  |  |  ------------------
  |  |  |  |   70|  4.66k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  4.66k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 4.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  125|  4.66k|		verbose(VERB_QUERY, "switching log to %s", 
  126|  4.66k|			use_syslog?"syslog":(filename&&filename[0]?filename:"stderr"));
  ------------------
  |  Branch (126:4): [True: 0, False: 4.66k]
  |  Branch (126:25): [True: 4.66k, False: 0]
  |  Branch (126:35): [True: 4.66k, False: 0]
  ------------------
  127|  4.66k|		lock_basic_lock(&log_lock);
  ------------------
  |  |  103|  4.66k|#define lock_basic_lock(lock) LOCKRET(pthread_mutex_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  4.66k|#define LOCKRET(func) do {\
  |  |  |  |   68|  4.66k|	int lockret_err;		\
  |  |  |  |   69|  4.66k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 4.66k]
  |  |  |  |  ------------------
  |  |  |  |   70|  4.66k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  4.66k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 4.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|  4.66k|	}
  129|  4.66k|	if(logfile && logfile != stderr) {
  ------------------
  |  Branch (129:5): [True: 4.66k, False: 1]
  |  Branch (129:16): [True: 4.66k, False: 0]
  ------------------
  130|  4.66k|		FILE* cl = logfile;
  131|  4.66k|		logfile = NULL; /* set to NULL before it is closed, so that
  132|       |			other threads have a valid logfile or NULL */
  133|  4.66k|		fclose(cl);
  134|  4.66k|	}
  135|  4.66k|#ifdef HAVE_SYSLOG_H
  136|  4.66k|	if(logging_to_syslog) {
  ------------------
  |  Branch (136:5): [True: 0, False: 4.66k]
  ------------------
  137|      0|		closelog();
  138|      0|		logging_to_syslog = 0;
  139|      0|	}
  140|  4.66k|	if(use_syslog) {
  ------------------
  |  Branch (140:5): [True: 0, False: 4.66k]
  ------------------
  141|       |		/* do not delay opening until first write, because we may
  142|       |		 * chroot and no longer be able to access dev/log and so on */
  143|       |		/* the facility is LOG_DAEMON by default, but
  144|       |		 * --with-syslog-facility=LOCAL[0-7] can override it */
  145|      0|		openlog(ident, LOG_NDELAY, UB_SYSLOG_FACILITY);
  ------------------
  |  | 1020|      0|#define UB_SYSLOG_FACILITY LOG_DAEMON
  ------------------
  146|      0|		logging_to_syslog = 1;
  147|      0|		lock_basic_unlock(&log_lock);
  ------------------
  |  |  104|      0|#define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|      0|		return;
  149|      0|	}
  150|       |#elif defined(UB_ON_WINDOWS)
  151|       |	if(logging_to_syslog) {
  152|       |		logging_to_syslog = 0;
  153|       |	}
  154|       |	if(use_syslog) {
  155|       |		logging_to_syslog = 1;
  156|       |		lock_basic_unlock(&log_lock);
  157|       |		return;
  158|       |	}
  159|       |#endif /* HAVE_SYSLOG_H */
  160|  4.66k|	if(!filename || !filename[0]) {
  ------------------
  |  Branch (160:5): [True: 0, False: 4.66k]
  |  Branch (160:18): [True: 0, False: 4.66k]
  ------------------
  161|      0|		logfile = stderr;
  162|      0|		lock_basic_unlock(&log_lock);
  ------------------
  |  |  104|      0|#define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|      0|		return;
  164|      0|	}
  165|       |	/* open the file for logging */
  166|  4.66k|	if(chrootdir && chrootdir[0] && strncmp(filename, chrootdir,
  ------------------
  |  Branch (166:5): [True: 0, False: 4.66k]
  |  Branch (166:18): [True: 0, False: 0]
  |  Branch (166:34): [True: 0, False: 0]
  ------------------
  167|      0|		strlen(chrootdir)) == 0) 
  168|      0|		filename += strlen(chrootdir);
  169|  4.66k|	f = fopen(filename, "a");
  170|  4.66k|	if(!f) {
  ------------------
  |  Branch (170:5): [True: 0, False: 4.66k]
  ------------------
  171|      0|		lock_basic_unlock(&log_lock);
  ------------------
  |  |  104|      0|#define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  172|      0|		log_err("Could not open logfile %s: %s", filename, 
  173|      0|			strerror(errno));
  174|      0|		return;
  175|      0|	}
  176|  4.66k|#ifndef UB_ON_WINDOWS
  177|       |	/* line buffering does not work on windows */
  178|  4.66k|	setvbuf(f, NULL, (int)_IOLBF, 0);
  179|  4.66k|#endif
  180|  4.66k|	logfile = f;
  181|  4.66k|	lock_basic_unlock(&log_lock);
  ------------------
  |  |  104|  4.66k|#define lock_basic_unlock(lock) LOCKRET(pthread_mutex_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  4.66k|#define LOCKRET(func) do {\
  |  |  |  |   68|  4.66k|	int lockret_err;		\
  |  |  |  |   69|  4.66k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 4.66k]
  |  |  |  |  ------------------
  |  |  |  |   70|  4.66k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  4.66k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 4.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|  4.66k|}
verbose:
  414|  10.4k|{
  415|  10.4k|        va_list args;
  416|  10.4k|	va_start(args, format);
  417|  10.4k|	if(verbosity >= level) {
  ------------------
  |  Branch (417:5): [True: 0, False: 10.4k]
  ------------------
  418|      0|		if(level == VERB_OPS)
  ------------------
  |  Branch (418:6): [True: 0, False: 0]
  ------------------
  419|      0|			log_vmsg(LOG_NOTICE, "notice", format, args);
  420|      0|		else if(level == VERB_DETAIL)
  ------------------
  |  Branch (420:11): [True: 0, False: 0]
  ------------------
  421|      0|			log_vmsg(LOG_INFO, "info", format, args);
  422|      0|		else	log_vmsg(LOG_DEBUG, "debug", format, args);
  423|      0|	}
  424|       |	va_end(args);
  425|  10.4k|}
log.c:log_lock_init_once:
   98|      1|{
   99|      1|	ub_thread_key_create(&logkey, NULL);
  ------------------
  |  |  177|      1|#define ub_thread_key_create(key, f) LOCKRET(pthread_key_create(key, f))
  |  |  ------------------
  |  |  |  |   67|      1|#define LOCKRET(func) do {\
  |  |  |  |   68|      1|	int lockret_err;		\
  |  |  |  |   69|      1|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |   70|      1|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      1| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|      1|	lock_basic_init(&log_lock);
  ------------------
  |  |  101|      1|#define lock_basic_init(lock) LOCKRET(pthread_mutex_init(lock, NULL))
  |  |  ------------------
  |  |  |  |   67|      1|#define LOCKRET(func) do {\
  |  |  |  |   68|      1|	int lockret_err;		\
  |  |  |  |   69|      1|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |   70|      1|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      1| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|      1|	key_created = 1;
  102|      1|}

minievent_init:
   89|  4.66k|{
   90|  4.66k|	struct event_base* base = (struct event_base*)malloc(
   91|  4.66k|		sizeof(struct event_base));
   92|  4.66k|	if(!base)
  ------------------
  |  Branch (92:5): [True: 0, False: 4.66k]
  ------------------
   93|      0|		return NULL;
   94|  4.66k|	memset(base, 0, sizeof(*base));
   95|  4.66k|	base->time_secs = time_secs;
   96|  4.66k|	base->time_tv = time_tv;
   97|  4.66k|	if(settime(base) < 0) {
  ------------------
  |  Branch (97:5): [True: 0, False: 4.66k]
  ------------------
   98|      0|		event_base_free(base);
  ------------------
  |  |   74|      0|#define event_base_free minievent_base_free
  ------------------
   99|      0|		return NULL;
  100|      0|	}
  101|  4.66k|	base->times = rbtree_create(mini_ev_cmp);
  102|  4.66k|	if(!base->times) {
  ------------------
  |  Branch (102:5): [True: 0, False: 4.66k]
  ------------------
  103|      0|		event_base_free(base);
  ------------------
  |  |   74|      0|#define event_base_free minievent_base_free
  ------------------
  104|      0|		return NULL;
  105|      0|	}
  106|  4.66k|	base->capfd = MAX_FDS;
  ------------------
  |  |   97|  4.66k|#define MAX_FDS 1024
  ------------------
  107|  4.66k|#ifdef FD_SETSIZE
  108|  4.66k|	if((int)FD_SETSIZE < base->capfd)
  ------------------
  |  Branch (108:5): [True: 0, False: 4.66k]
  ------------------
  109|      0|		base->capfd = (int)FD_SETSIZE;
  110|  4.66k|#endif
  111|  4.66k|	base->fds = (struct event**)calloc((size_t)base->capfd, 
  112|  4.66k|		sizeof(struct event*));
  113|  4.66k|	if(!base->fds) {
  ------------------
  |  Branch (113:5): [True: 0, False: 4.66k]
  ------------------
  114|      0|		event_base_free(base);
  ------------------
  |  |   74|      0|#define event_base_free minievent_base_free
  ------------------
  115|      0|		return NULL;
  116|      0|	}
  117|  4.66k|	base->signals = (struct event**)calloc(MAX_SIG, sizeof(struct event*));
  ------------------
  |  |   99|  4.66k|#define MAX_SIG 32
  ------------------
  118|  4.66k|	if(!base->signals) {
  ------------------
  |  Branch (118:5): [True: 0, False: 4.66k]
  ------------------
  119|      0|		event_base_free(base);
  ------------------
  |  |   74|      0|#define event_base_free minievent_base_free
  ------------------
  120|      0|		return NULL;
  121|      0|	}
  122|  4.66k|#ifndef S_SPLINT_S
  123|  4.66k|	FD_ZERO(&base->reads);
  ------------------
  |  Branch (123:2): [True: 74.6k, False: 4.66k]
  |  Branch (123:2): [Folded, False: 4.66k]
  ------------------
  124|       |	FD_ZERO(&base->writes);
  ------------------
  |  Branch (124:2): [True: 74.6k, False: 4.66k]
  |  Branch (124:2): [Folded, False: 4.66k]
  ------------------
  125|  4.66k|#endif
  126|  4.66k|	return base;
  127|  4.66k|}
minievent_base_free:
  261|  4.66k|{
  262|  4.66k|	if(!base)
  ------------------
  |  Branch (262:5): [True: 0, False: 4.66k]
  ------------------
  263|      0|		return;
  264|  4.66k|	free(base->times);
  265|  4.66k|	free(base->fds);
  266|  4.66k|	free(base->signals);
  267|  4.66k|	free(base);
  268|  4.66k|}
mini_event.c:settime:
   77|  4.66k|{
   78|  4.66k|	if(gettimeofday(base->time_tv, NULL) < 0) {
  ------------------
  |  Branch (78:5): [True: 0, False: 4.66k]
  ------------------
   79|      0|		return -1;
   80|      0|	}
   81|  4.66k|#ifndef S_SPLINT_S
   82|  4.66k|	*base->time_secs = (time_t)base->time_tv->tv_sec;
   83|  4.66k|#endif
   84|  4.66k|	return 0;
   85|  4.66k|}

errinf_ede:
   85|    337|{
   86|    337|	struct errinf_strlist* p;
   87|    337|	if(!str || (qstate->env->cfg->val_log_level < 2 &&
  ------------------
  |  Branch (87:5): [True: 0, False: 337]
  |  Branch (87:14): [True: 337, False: 0]
  ------------------
   88|    337|		!qstate->env->cfg->log_servfail)) {
  ------------------
  |  Branch (88:3): [True: 337, False: 0]
  ------------------
   89|    337|		return;
   90|    337|	}
   91|      0|	p = (struct errinf_strlist*)regional_alloc(qstate->region, sizeof(*p));
   92|      0|	if(!p) {
  ------------------
  |  Branch (92:5): [True: 0, False: 0]
  ------------------
   93|      0|		log_err("malloc failure in validator-error-info string");
   94|      0|		return;
   95|      0|	}
   96|      0|	p->next = NULL;
   97|      0|	p->str = regional_strdup(qstate->region, str);
   98|      0|	p->reason_bogus = reason_bogus;
   99|      0|	if(!p->str) {
  ------------------
  |  Branch (99:5): [True: 0, False: 0]
  ------------------
  100|      0|		log_err("malloc failure in validator-error-info string");
  101|      0|		return;
  102|      0|	}
  103|       |	/* add at end */
  104|      0|	if(qstate->errinf) {
  ------------------
  |  Branch (104:5): [True: 0, False: 0]
  ------------------
  105|      0|		struct errinf_strlist* q = qstate->errinf;
  106|      0|		while(q->next)
  ------------------
  |  Branch (106:9): [True: 0, False: 0]
  ------------------
  107|      0|			q = q->next;
  108|      0|		q->next = p;
  109|      0|	} else	qstate->errinf = p;
  110|      0|}

log_nametypeclass:
  556|  2.23k|{
  557|  2.23k|	char buf[LDNS_MAX_DOMAINLEN];
  558|  2.23k|	char t[12], c[12];
  559|  2.23k|	const char *ts, *cs; 
  560|  2.23k|	if(verbosity < v)
  ------------------
  |  Branch (560:5): [True: 2.23k, False: 0]
  ------------------
  561|  2.23k|		return;
  562|      0|	dname_str(name, buf);
  563|      0|	if(type == LDNS_RR_TYPE_TSIG) ts = "TSIG";
  ------------------
  |  Branch (563:5): [True: 0, False: 0]
  ------------------
  564|      0|	else if(type == LDNS_RR_TYPE_IXFR) ts = "IXFR";
  ------------------
  |  Branch (564:10): [True: 0, False: 0]
  ------------------
  565|      0|	else if(type == LDNS_RR_TYPE_AXFR) ts = "AXFR";
  ------------------
  |  Branch (565:10): [True: 0, False: 0]
  ------------------
  566|      0|	else if(type == LDNS_RR_TYPE_MAILB) ts = "MAILB";
  ------------------
  |  Branch (566:10): [True: 0, False: 0]
  ------------------
  567|      0|	else if(type == LDNS_RR_TYPE_MAILA) ts = "MAILA";
  ------------------
  |  Branch (567:10): [True: 0, False: 0]
  ------------------
  568|      0|	else if(type == LDNS_RR_TYPE_ANY) ts = "ANY";
  ------------------
  |  Branch (568:10): [True: 0, False: 0]
  ------------------
  569|      0|	else if(sldns_rr_descript(type) && sldns_rr_descript(type)->_name)
  ------------------
  |  Branch (569:10): [True: 0, False: 0]
  |  Branch (569:37): [True: 0, False: 0]
  ------------------
  570|      0|		ts = sldns_rr_descript(type)->_name;
  571|      0|	else {
  572|      0|		snprintf(t, sizeof(t), "TYPE%d", (int)type);
  573|      0|		ts = t;
  574|      0|	}
  575|      0|	if(sldns_lookup_by_id(sldns_rr_classes, (int)dclass) &&
  ------------------
  |  Branch (575:5): [True: 0, False: 0]
  ------------------
  576|      0|		sldns_lookup_by_id(sldns_rr_classes, (int)dclass)->name)
  ------------------
  |  Branch (576:3): [True: 0, False: 0]
  ------------------
  577|      0|		cs = sldns_lookup_by_id(sldns_rr_classes, (int)dclass)->name;
  578|      0|	else {
  579|      0|		snprintf(c, sizeof(c), "CLASS%d", (int)dclass);
  580|      0|		cs = c;
  581|      0|	}
  582|      0|	log_info("%s %s %s %s", str, buf, ts, cs);
  583|      0|}

comm_base_create:
  209|  4.66k|{
  210|  4.66k|	struct comm_base* b = (struct comm_base*)calloc(1,
  211|  4.66k|		sizeof(struct comm_base));
  212|  4.66k|	const char *evnm="event", *evsys="", *evmethod="";
  213|       |
  214|  4.66k|	if(!b)
  ------------------
  |  Branch (214:5): [True: 0, False: 4.66k]
  ------------------
  215|      0|		return NULL;
  216|  4.66k|	b->eb = (struct internal_base*)calloc(1, sizeof(struct internal_base));
  217|  4.66k|	if(!b->eb) {
  ------------------
  |  Branch (217:5): [True: 0, False: 4.66k]
  ------------------
  218|      0|		free(b);
  219|      0|		return NULL;
  220|      0|	}
  221|  4.66k|	b->eb->base = ub_default_event_base(sigs, &b->eb->secs, &b->eb->now);
  222|  4.66k|	if(!b->eb->base) {
  ------------------
  |  Branch (222:5): [True: 0, False: 4.66k]
  ------------------
  223|      0|		free(b->eb);
  224|      0|		free(b);
  225|      0|		return NULL;
  226|      0|	}
  227|  4.66k|	ub_comm_base_now(b);
  228|  4.66k|	ub_get_event_sys(b->eb->base, &evnm, &evsys, &evmethod);
  229|  4.66k|	verbose(VERB_ALGO, "%s %s uses %s method.", evnm, evsys, evmethod);
  230|  4.66k|	return b;
  231|  4.66k|}
comm_base_delete:
  252|  4.66k|{
  253|  4.66k|	if(!b)
  ------------------
  |  Branch (253:5): [True: 0, False: 4.66k]
  ------------------
  254|      0|		return;
  255|  4.66k|	if(b->eb->slow_accept_enabled) {
  ------------------
  |  Branch (255:5): [True: 0, False: 4.66k]
  ------------------
  256|      0|		if(ub_event_del(b->eb->slow_accept) != 0) {
  ------------------
  |  Branch (256:6): [True: 0, False: 0]
  ------------------
  257|      0|			log_err("could not event_del slow_accept");
  258|      0|		}
  259|      0|		ub_event_free(b->eb->slow_accept);
  260|      0|	}
  261|  4.66k|	ub_event_base_free(b->eb->base);
  262|       |	b->eb->base = NULL;
  263|  4.66k|	free(b->eb);
  264|  4.66k|	free(b);
  265|  4.66k|}
comm_base_timept:
  285|  4.66k|{
  286|  4.66k|	*tt = &b->eb->secs;
  287|  4.66k|	*tv = &b->eb->now;
  288|  4.66k|}

rbtree_create:
   79|  4.66k|{
   80|  4.66k|	rbtree_type *rbtree;
   81|       |
   82|       |	/* Allocate memory for it */
   83|  4.66k|	rbtree = (rbtree_type *) malloc(sizeof(rbtree_type));
   84|  4.66k|	if (!rbtree) {
  ------------------
  |  Branch (84:6): [True: 0, False: 4.66k]
  ------------------
   85|      0|		return NULL;
   86|      0|	}
   87|       |
   88|       |	/* Initialize it */
   89|  4.66k|	rbtree_init(rbtree, cmpf);
   90|       |
   91|  4.66k|	return rbtree;
   92|  4.66k|}
rbtree_init:
   96|  4.66k|{
   97|       |	/* Initialize it */
   98|  4.66k|	rbtree->root = RBTREE_NULL;
  ------------------
  |  |   69|  4.66k|#define	RBTREE_NULL &rbtree_null_node
  ------------------
   99|  4.66k|	rbtree->count = 0;
  100|  4.66k|	rbtree->cmp = cmpf;
  101|  4.66k|}

regional_create:
   67|  4.66k|{
   68|  4.66k|	return regional_create_custom(REGIONAL_CHUNK_SIZE);
  ------------------
  |  |   56|  4.66k|#define REGIONAL_CHUNK_SIZE         8192
  ------------------
   69|  4.66k|}
regional_create_custom:
  105|  4.66k|{
  106|  4.66k|	if(size < sizeof(struct regional))
  ------------------
  |  Branch (106:5): [True: 0, False: 4.66k]
  ------------------
  107|      0|		size = sizeof(struct regional);
  108|  4.66k|	return regional_create_custom_large_object(size,
  109|  4.66k|		REGIONAL_LARGE_OBJECT_SIZE);
  ------------------
  |  |   62|  4.66k|#define REGIONAL_LARGE_OBJECT_SIZE  2048
  ------------------
  110|  4.66k|}
regional_free_all:
  120|  4.66k|{
  121|  4.66k|	char* p = r->next, *np;
  122|  11.3k|	while(p) {
  ------------------
  |  Branch (122:8): [True: 6.64k, False: 4.66k]
  ------------------
  123|  6.64k|		np = *(char**)p;
  124|  6.64k|		free(p);
  125|  6.64k|		p = np;
  126|  6.64k|	}
  127|  4.66k|	p = r->large_list;
  128|  4.74k|	while(p) {
  ------------------
  |  Branch (128:8): [True: 83, False: 4.66k]
  ------------------
  129|     83|		np = *(char**)p;
  130|     83|		free(p);
  131|     83|		p = np;
  132|     83|	}
  133|  4.66k|	regional_init(r);
  134|  4.66k|}
regional_destroy:
  138|  4.66k|{
  139|  4.66k|	if(!r) return;
  ------------------
  |  Branch (139:5): [True: 0, False: 4.66k]
  ------------------
  140|  4.66k|	regional_free_all(r);
  141|  4.66k|	free(r);
  142|  4.66k|}
regional_alloc:
  146|  1.56M|{
  147|  1.56M|	size_t a;
  148|  1.56M|	void *s;
  149|  1.56M|	if(
  150|  1.56M|#if SIZEOF_SIZE_T == 8
  151|  1.56M|		(unsigned long long)size >= 0xffffffffffffff00ULL
  ------------------
  |  Branch (151:3): [True: 0, False: 1.56M]
  ------------------
  152|       |#else
  153|       |		(unsigned)size >= (unsigned)0xffffff00UL
  154|       |#endif
  155|  1.56M|		)
  156|      0|		return NULL; /* protect against integer overflow in
  157|       |			malloc and ALIGN_UP */
  158|  1.56M|	a = ALIGN_UP(size, ALIGNMENT);
  ------------------
  |  |   51|  1.56M|#define ALIGN_UP(x, s)     (((x) + s - 1) & (~(s - 1)))
  ------------------
  159|       |	/* large objects */
  160|  1.56M|	if(a > r->large_object_size) {
  ------------------
  |  Branch (160:5): [True: 83, False: 1.56M]
  ------------------
  161|     83|		s = malloc(ALIGNMENT + size);
  ------------------
  |  |   53|     83|#define ALIGNMENT          (sizeof(uint64_t))
  ------------------
  162|     83|		if(!s) return NULL;
  ------------------
  |  Branch (162:6): [True: 0, False: 83]
  ------------------
  163|     83|		r->total_large += ALIGNMENT+size;
  ------------------
  |  |   53|     83|#define ALIGNMENT          (sizeof(uint64_t))
  ------------------
  164|     83|		*(char**)s = r->large_list;
  165|     83|		r->large_list = (char*)s;
  166|     83|		return (char*)s+ALIGNMENT;
  ------------------
  |  |   53|     83|#define ALIGNMENT          (sizeof(uint64_t))
  ------------------
  167|     83|	}
  168|       |	/* create a new chunk */
  169|  1.56M|	if(a > r->available) {
  ------------------
  |  Branch (169:5): [True: 6.64k, False: 1.55M]
  ------------------
  170|  6.64k|		s = malloc(REGIONAL_CHUNK_SIZE);
  ------------------
  |  |   56|  6.64k|#define REGIONAL_CHUNK_SIZE         8192
  ------------------
  171|  6.64k|		if(!s) return NULL;
  ------------------
  |  Branch (171:6): [True: 0, False: 6.64k]
  ------------------
  172|  6.64k|		*(char**)s = r->next;
  173|  6.64k|		r->next = (char*)s;
  174|  6.64k|		r->data = (char*)s + ALIGNMENT;
  ------------------
  |  |   53|  6.64k|#define ALIGNMENT          (sizeof(uint64_t))
  ------------------
  175|  6.64k|		r->available = REGIONAL_CHUNK_SIZE - ALIGNMENT;
  ------------------
  |  |   56|  6.64k|#define REGIONAL_CHUNK_SIZE         8192
  ------------------
              		r->available = REGIONAL_CHUNK_SIZE - ALIGNMENT;
  ------------------
  |  |   53|  6.64k|#define ALIGNMENT          (sizeof(uint64_t))
  ------------------
  176|  6.64k|	}
  177|       |	/* put in this chunk */
  178|  1.56M|	r->available -= a;
  179|  1.56M|	s = r->data;
  180|  1.56M|	r->data += a;
  181|  1.56M|	return s;
  182|  1.56M|}
regional_alloc_init:
  186|    590|{
  187|    590|	void *s = regional_alloc(r, size);
  188|    590|	if(!s) return NULL;
  ------------------
  |  Branch (188:5): [True: 0, False: 590]
  ------------------
  189|    590|	memmove(s, init, size);
  190|    590|	return s;
  191|    590|}
regional.c:regional_create_custom_large_object:
   91|  4.66k|{
   92|  4.66k|	struct regional* r;
   93|  4.66k|	size = ALIGN_UP(size, ALIGNMENT);
  ------------------
  |  |   51|  4.66k|#define ALIGN_UP(x, s)     (((x) + s - 1) & (~(s - 1)))
  ------------------
   94|  4.66k|	r = (struct regional*)malloc(size);
   95|  4.66k|	log_assert(sizeof(struct regional) <= size);
   96|  4.66k|	if(!r) return NULL;
  ------------------
  |  Branch (96:5): [True: 0, False: 4.66k]
  ------------------
   97|  4.66k|	r->first_size = size;
   98|  4.66k|	r->large_object_size = large_object_size;
   99|  4.66k|	regional_init(r);
  100|  4.66k|	return r;
  101|  4.66k|}
regional.c:regional_init:
   74|  9.33k|{
   75|  9.33k|	size_t a = ALIGN_UP(sizeof(struct regional), ALIGNMENT);
  ------------------
  |  |   51|  9.33k|#define ALIGN_UP(x, s)     (((x) + s - 1) & (~(s - 1)))
  ------------------
   76|  9.33k|	r->data = (char*)r + a;
   77|  9.33k|	r->available = r->first_size - a;
   78|  9.33k|	r->next = NULL;
   79|       |	r->large_list = NULL;
   80|  9.33k|	r->total_large = 0;
   81|  9.33k|}

hashlittle:
  357|  4.70M|{
  358|  4.70M|  uint32_t a,b,c;                                          /* internal state */
  359|  4.70M|  union { const void *ptr; size_t i; } u;     /* needed for Mac Powerbook G4 */
  360|       |
  361|       |  /* Set up the internal state */
  362|  4.70M|  a = b = c = raninit + ((uint32_t)length) + initval;
  363|       |
  364|  4.70M|  u.ptr = key;
  365|  4.70M|  if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
  ------------------
  |  |   93|  9.41M|#  define HASH_LITTLE_ENDIAN 1
  |  |  ------------------
  |  |  |  Branch (93:30): [True: 4.70M, Folded]
  |  |  ------------------
  ------------------
  |  Branch (365:29): [True: 3.20M, False: 1.50M]
  ------------------
  366|  3.20M|    const uint32_t *k = (const uint32_t *)key;         /* read 32-bit chunks */
  367|  3.20M|#ifdef ARRAY_CLEAN_ACCESS
  368|  3.20M|    const uint8_t  *k8;
  369|  3.20M|#endif
  370|       |
  371|       |    /*------ all but last block: aligned reads and affect 32 bits of (a,b,c) */
  372|  3.28M|    while (length > 12)
  ------------------
  |  Branch (372:12): [True: 81.2k, False: 3.20M]
  ------------------
  373|  81.2k|    {
  374|  81.2k|      a += k[0];
  375|  81.2k|      b += k[1];
  376|  81.2k|      c += k[2];
  377|  81.2k|      mix(a,b,c);
  ------------------
  |  |  173|  81.2k|#define mix(a,b,c) \
  |  |  174|  81.2k|{ \
  |  |  175|  81.2k|  a -= c;  a ^= rot(c, 4);  c += b; \
  |  |  ------------------
  |  |  |  |  118|  81.2k|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  176|  81.2k|  b -= a;  b ^= rot(a, 6);  a += c; \
  |  |  ------------------
  |  |  |  |  118|  81.2k|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  177|  81.2k|  c -= b;  c ^= rot(b, 8);  b += a; \
  |  |  ------------------
  |  |  |  |  118|  81.2k|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  178|  81.2k|  a -= c;  a ^= rot(c,16);  c += b; \
  |  |  ------------------
  |  |  |  |  118|  81.2k|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  179|  81.2k|  b -= a;  b ^= rot(a,19);  a += c; \
  |  |  ------------------
  |  |  |  |  118|  81.2k|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  180|  81.2k|  c -= b;  c ^= rot(b, 4);  b += a; \
  |  |  ------------------
  |  |  |  |  118|  81.2k|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  181|  81.2k|}
  ------------------
  378|  81.2k|      length -= 12;
  379|  81.2k|      k += 3;
  380|  81.2k|    }
  381|       |
  382|       |    /*----------------------------- handle the last (probably partial) block */
  383|       |    /* 
  384|       |     * "k[2]&0xffffff" actually reads beyond the end of the string, but
  385|       |     * then masks off the part it's not allowed to read.  Because the
  386|       |     * string is aligned, the masked-off tail is in the same word as the
  387|       |     * rest of the string.  Every machine with memory protection I've seen
  388|       |     * does it on word boundaries, so is OK with this.  But VALGRIND will
  389|       |     * still catch it and complain.  The masking trick does make the hash
  390|       |     * noticeably faster for short strings (like English words).
  391|       |     */
  392|       |#ifndef ARRAY_CLEAN_ACCESS
  393|       |
  394|       |    switch(length)
  395|       |    {
  396|       |    case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
  397|       |    case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
  398|       |    case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
  399|       |    case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
  400|       |    case 8 : b+=k[1]; a+=k[0]; break;
  401|       |    case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
  402|       |    case 6 : b+=k[1]&0xffff; a+=k[0]; break;
  403|       |    case 5 : b+=k[1]&0xff; a+=k[0]; break;
  404|       |    case 4 : a+=k[0]; break;
  405|       |    case 3 : a+=k[0]&0xffffff; break;
  406|       |    case 2 : a+=k[0]&0xffff; break;
  407|       |    case 1 : a+=k[0]&0xff; break;
  408|       |    case 0 : return c;              /* zero length strings require no mixing */
  409|       |    }
  410|       |
  411|       |#else /* make valgrind happy */
  412|       |
  413|  3.20M|    k8 = (const uint8_t *)k;
  414|  3.20M|    switch(length)
  ------------------
  |  Branch (414:12): [True: 3.20M, False: 0]
  ------------------
  415|  3.20M|    {
  416|  2.41k|    case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
  ------------------
  |  Branch (416:5): [True: 2.41k, False: 3.19M]
  ------------------
  417|  9.64k|    case 11: c+=((uint32_t)k8[10])<<16;
  ------------------
  |  Branch (417:5): [True: 9.64k, False: 3.19M]
  ------------------
  418|  9.64k|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  9.64k|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  419|       |	/* fallthrough */
  420|  16.7k|    case 10: c+=((uint32_t)k8[9])<<8;
  ------------------
  |  Branch (420:5): [True: 7.12k, False: 3.19M]
  ------------------
  421|  16.7k|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  16.7k|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  422|       |	/* fallthrough */
  423|  25.9k|    case 9 : c+=k8[8];
  ------------------
  |  Branch (423:5): [True: 9.18k, False: 3.19M]
  ------------------
  424|  25.9k|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  25.9k|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  425|       |	/* fallthrough */
  426|  31.2k|    case 8 : b+=k[1]; a+=k[0]; break;
  ------------------
  |  Branch (426:5): [True: 5.34k, False: 3.19M]
  ------------------
  427|  4.68k|    case 7 : b+=((uint32_t)k8[6])<<16;
  ------------------
  |  Branch (427:5): [True: 4.68k, False: 3.19M]
  ------------------
  428|  4.68k|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  4.68k|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  429|       |	/* fallthrough */
  430|  10.9k|    case 6 : b+=((uint32_t)k8[5])<<8;
  ------------------
  |  Branch (430:5): [True: 6.26k, False: 3.19M]
  ------------------
  431|  10.9k|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  10.9k|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  432|       |	/* fallthrough */
  433|  53.6k|    case 5 : b+=k8[4];
  ------------------
  |  Branch (433:5): [True: 42.7k, False: 3.15M]
  ------------------
  434|  53.6k|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  53.6k|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  435|       |	/* fallthrough */
  436|  1.57M|    case 4 : a+=k[0]; break;
  ------------------
  |  Branch (436:5): [True: 1.51M, False: 1.68M]
  ------------------
  437|  26.8k|    case 3 : a+=((uint32_t)k8[2])<<16;
  ------------------
  |  Branch (437:5): [True: 26.8k, False: 3.17M]
  ------------------
  438|  26.8k|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  26.8k|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  439|       |	/* fallthrough */
  440|  1.59M|    case 2 : a+=((uint32_t)k8[1])<<8;
  ------------------
  |  Branch (440:5): [True: 1.56M, False: 1.63M]
  ------------------
  441|  1.59M|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|  1.59M|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  442|       |	/* fallthrough */
  443|  1.59M|    case 1 : a+=k8[0]; break;
  ------------------
  |  Branch (443:5): [True: 1.97k, False: 3.19M]
  ------------------
  444|      0|    case 0 : return c;
  ------------------
  |  Branch (444:5): [True: 0, False: 3.20M]
  ------------------
  445|  3.20M|    }
  446|       |
  447|  3.20M|#endif /* !valgrind */
  448|       |
  449|  3.20M|  } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
  ------------------
  |  |   93|  3.00M|#  define HASH_LITTLE_ENDIAN 1
  |  |  ------------------
  |  |  |  Branch (93:30): [True: 1.50M, Folded]
  |  |  ------------------
  ------------------
  |  Branch (449:36): [True: 1.50M, False: 0]
  ------------------
  450|  1.50M|    const uint16_t *k = (const uint16_t *)key;         /* read 16-bit chunks */
  451|  1.50M|    const uint8_t  *k8;
  452|       |
  453|       |    /*--------------- all but last block: aligned reads and different mixing */
  454|  1.50M|    while (length > 12)
  ------------------
  |  Branch (454:12): [True: 0, False: 1.50M]
  ------------------
  455|      0|    {
  456|      0|      a += k[0] + (((uint32_t)k[1])<<16);
  457|      0|      b += k[2] + (((uint32_t)k[3])<<16);
  458|      0|      c += k[4] + (((uint32_t)k[5])<<16);
  459|      0|      mix(a,b,c);
  ------------------
  |  |  173|      0|#define mix(a,b,c) \
  |  |  174|      0|{ \
  |  |  175|      0|  a -= c;  a ^= rot(c, 4);  c += b; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  176|      0|  b -= a;  b ^= rot(a, 6);  a += c; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  177|      0|  c -= b;  c ^= rot(b, 8);  b += a; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  178|      0|  a -= c;  a ^= rot(c,16);  c += b; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  179|      0|  b -= a;  b ^= rot(a,19);  a += c; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  180|      0|  c -= b;  c ^= rot(b, 4);  b += a; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  181|      0|}
  ------------------
  460|      0|      length -= 12;
  461|      0|      k += 6;
  462|      0|    }
  463|       |
  464|       |    /*----------------------------- handle the last (probably partial) block */
  465|  1.50M|    k8 = (const uint8_t *)k;
  466|  1.50M|    switch(length)
  ------------------
  |  Branch (466:12): [True: 1.50M, False: 0]
  ------------------
  467|  1.50M|    {
  468|      0|    case 12: c+=k[4]+(((uint32_t)k[5])<<16);
  ------------------
  |  Branch (468:5): [True: 0, False: 1.50M]
  ------------------
  469|      0|             b+=k[2]+(((uint32_t)k[3])<<16);
  470|      0|             a+=k[0]+(((uint32_t)k[1])<<16);
  471|      0|             break;
  472|      0|    case 11: c+=((uint32_t)k8[10])<<16;
  ------------------
  |  Branch (472:5): [True: 0, False: 1.50M]
  ------------------
  473|      0|	     ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  474|       |	     /* fallthrough */
  475|      0|    case 10: c+=k[4];
  ------------------
  |  Branch (475:5): [True: 0, False: 1.50M]
  ------------------
  476|      0|             b+=k[2]+(((uint32_t)k[3])<<16);
  477|      0|             a+=k[0]+(((uint32_t)k[1])<<16);
  478|      0|             break;
  479|      0|    case 9 : c+=k8[8];
  ------------------
  |  Branch (479:5): [True: 0, False: 1.50M]
  ------------------
  480|      0|	     ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  481|       |	     /* fallthrough */
  482|      0|    case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
  ------------------
  |  Branch (482:5): [True: 0, False: 1.50M]
  ------------------
  483|      0|             a+=k[0]+(((uint32_t)k[1])<<16);
  484|      0|             break;
  485|      0|    case 7 : b+=((uint32_t)k8[6])<<16;
  ------------------
  |  Branch (485:5): [True: 0, False: 1.50M]
  ------------------
  486|      0|	     ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  487|       |	     /* fallthrough */
  488|      0|    case 6 : b+=k[2];
  ------------------
  |  Branch (488:5): [True: 0, False: 1.50M]
  ------------------
  489|      0|             a+=k[0]+(((uint32_t)k[1])<<16);
  490|      0|             break;
  491|      0|    case 5 : b+=k8[4];
  ------------------
  |  Branch (491:5): [True: 0, False: 1.50M]
  ------------------
  492|      0|	     ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  493|       |	     /* fallthrough */
  494|      0|    case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
  ------------------
  |  Branch (494:5): [True: 0, False: 1.50M]
  ------------------
  495|      0|             break;
  496|      0|    case 3 : a+=((uint32_t)k8[2])<<16;
  ------------------
  |  Branch (496:5): [True: 0, False: 1.50M]
  ------------------
  497|      0|	     ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  498|       |	     /* fallthrough */
  499|  1.50M|    case 2 : a+=k[0];
  ------------------
  |  Branch (499:5): [True: 1.50M, False: 0]
  ------------------
  500|  1.50M|             break;
  501|      0|    case 1 : a+=k8[0];
  ------------------
  |  Branch (501:5): [True: 0, False: 1.50M]
  ------------------
  502|      0|             break;
  503|      0|    case 0 : return c;                     /* zero length requires no mixing */
  ------------------
  |  Branch (503:5): [True: 0, False: 1.50M]
  ------------------
  504|  1.50M|    }
  505|       |
  506|  1.50M|  } else {                        /* need to read the key one byte at a time */
  507|      0|    const uint8_t *k = (const uint8_t *)key;
  508|       |
  509|       |    /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
  510|      0|    while (length > 12)
  ------------------
  |  Branch (510:12): [True: 0, False: 0]
  ------------------
  511|      0|    {
  512|      0|      a += k[0];
  513|      0|      a += ((uint32_t)k[1])<<8;
  514|      0|      a += ((uint32_t)k[2])<<16;
  515|      0|      a += ((uint32_t)k[3])<<24;
  516|      0|      b += k[4];
  517|      0|      b += ((uint32_t)k[5])<<8;
  518|      0|      b += ((uint32_t)k[6])<<16;
  519|      0|      b += ((uint32_t)k[7])<<24;
  520|      0|      c += k[8];
  521|      0|      c += ((uint32_t)k[9])<<8;
  522|      0|      c += ((uint32_t)k[10])<<16;
  523|      0|      c += ((uint32_t)k[11])<<24;
  524|      0|      mix(a,b,c);
  ------------------
  |  |  173|      0|#define mix(a,b,c) \
  |  |  174|      0|{ \
  |  |  175|      0|  a -= c;  a ^= rot(c, 4);  c += b; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  176|      0|  b -= a;  b ^= rot(a, 6);  a += c; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  177|      0|  c -= b;  c ^= rot(b, 8);  b += a; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  178|      0|  a -= c;  a ^= rot(c,16);  c += b; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  179|      0|  b -= a;  b ^= rot(a,19);  a += c; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  180|      0|  c -= b;  c ^= rot(b, 4);  b += a; \
  |  |  ------------------
  |  |  |  |  118|      0|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  181|      0|}
  ------------------
  525|      0|      length -= 12;
  526|      0|      k += 12;
  527|      0|    }
  528|       |
  529|       |    /*-------------------------------- last block: affect all 32 bits of (c) */
  530|      0|    switch(length)                   /* all the case statements fall through */
  ------------------
  |  Branch (530:12): [True: 0, False: 0]
  ------------------
  531|      0|    {
  532|      0|    case 12: c+=((uint32_t)k[11])<<24;
  ------------------
  |  Branch (532:5): [True: 0, False: 0]
  ------------------
  533|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  534|       |	/* fallthrough */
  535|      0|    case 11: c+=((uint32_t)k[10])<<16;
  ------------------
  |  Branch (535:5): [True: 0, False: 0]
  ------------------
  536|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  537|       |	/* fallthrough */
  538|      0|    case 10: c+=((uint32_t)k[9])<<8;
  ------------------
  |  Branch (538:5): [True: 0, False: 0]
  ------------------
  539|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  540|       |	/* fallthrough */
  541|      0|    case 9 : c+=k[8];
  ------------------
  |  Branch (541:5): [True: 0, False: 0]
  ------------------
  542|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  543|       |	/* fallthrough */
  544|      0|    case 8 : b+=((uint32_t)k[7])<<24;
  ------------------
  |  Branch (544:5): [True: 0, False: 0]
  ------------------
  545|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  546|       |	/* fallthrough */
  547|      0|    case 7 : b+=((uint32_t)k[6])<<16;
  ------------------
  |  Branch (547:5): [True: 0, False: 0]
  ------------------
  548|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  549|       |	/* fallthrough */
  550|      0|    case 6 : b+=((uint32_t)k[5])<<8;
  ------------------
  |  Branch (550:5): [True: 0, False: 0]
  ------------------
  551|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  552|       |	/* fallthrough */
  553|      0|    case 5 : b+=k[4];
  ------------------
  |  Branch (553:5): [True: 0, False: 0]
  ------------------
  554|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  555|       |	/* fallthrough */
  556|      0|    case 4 : a+=((uint32_t)k[3])<<24;
  ------------------
  |  Branch (556:5): [True: 0, False: 0]
  ------------------
  557|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  558|       |	/* fallthrough */
  559|      0|    case 3 : a+=((uint32_t)k[2])<<16;
  ------------------
  |  Branch (559:5): [True: 0, False: 0]
  ------------------
  560|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  561|       |	/* fallthrough */
  562|      0|    case 2 : a+=((uint32_t)k[1])<<8;
  ------------------
  |  Branch (562:5): [True: 0, False: 0]
  ------------------
  563|      0|	ATTR_FALLTHROUGH
  ------------------
  |  |    5|      0|#define ATTR_FALLTHROUGH __attribute__((fallthrough));
  ------------------
  564|       |	/* fallthrough */
  565|      0|    case 1 : a+=k[0];
  ------------------
  |  Branch (565:5): [True: 0, False: 0]
  ------------------
  566|      0|             break;
  567|      0|    case 0 : return c;
  ------------------
  |  Branch (567:5): [True: 0, False: 0]
  ------------------
  568|      0|    }
  569|      0|  }
  570|       |
  571|  4.70M|  final(a,b,c);
  ------------------
  |  |  208|  4.70M|#define final(a,b,c) \
  |  |  209|  4.70M|{ \
  |  |  210|  4.70M|  c ^= b; c -= rot(b,14); \
  |  |  ------------------
  |  |  |  |  118|  4.70M|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  211|  4.70M|  a ^= c; a -= rot(c,11); \
  |  |  ------------------
  |  |  |  |  118|  4.70M|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  212|  4.70M|  b ^= a; b -= rot(a,25); \
  |  |  ------------------
  |  |  |  |  118|  4.70M|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  213|  4.70M|  c ^= b; c -= rot(b,16); \
  |  |  ------------------
  |  |  |  |  118|  4.70M|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  214|  4.70M|  a ^= c; a -= rot(c,4);  \
  |  |  ------------------
  |  |  |  |  118|  4.70M|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  215|  4.70M|  b ^= a; b -= rot(a,14); \
  |  |  ------------------
  |  |  |  |  118|  4.70M|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  216|  4.70M|  c ^= b; c -= rot(b,24); \
  |  |  ------------------
  |  |  |  |  118|  4.70M|#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
  |  |  ------------------
  |  |  217|  4.70M|}
  ------------------
  572|  4.70M|  return c;
  573|  4.70M|}

bin_init:
   49|  18.6k|{
   50|  18.6k|	size_t i;
   51|       |#ifdef THREADS_DISABLED
   52|       |	(void)array;
   53|       |#endif
   54|  19.1M|	for(i=0; i<size; i++) {
  ------------------
  |  Branch (54:11): [True: 19.1M, False: 18.6k]
  ------------------
   55|  19.1M|		lock_quick_init(&array[i].lock);
  ------------------
  |  |  144|  19.1M|#define lock_quick_init(lock) LOCKRET(pthread_spin_init(lock, PTHREAD_PROCESS_PRIVATE))
  |  |  ------------------
  |  |  |  |   67|  19.1M|#define LOCKRET(func) do {\
  |  |  |  |   68|  19.1M|	int lockret_err;		\
  |  |  |  |   69|  19.1M|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 19.1M]
  |  |  |  |  ------------------
  |  |  |  |   70|  19.1M|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  19.1M| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 19.1M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|  19.1M|		lock_protect(&array[i].lock, &array[i], 
   57|  19.1M|			sizeof(struct lruhash_bin));
   58|  19.1M|	}
   59|  18.6k|}
lruhash_create:
   66|  18.6k|{
   67|  18.6k|	struct lruhash* table = (struct lruhash*)calloc(1, 
   68|  18.6k|		sizeof(struct lruhash));
   69|  18.6k|	if(!table)
  ------------------
  |  Branch (69:5): [True: 0, False: 18.6k]
  ------------------
   70|      0|		return NULL;
   71|  18.6k|	lock_quick_init(&table->lock);
  ------------------
  |  |  144|  18.6k|#define lock_quick_init(lock) LOCKRET(pthread_spin_init(lock, PTHREAD_PROCESS_PRIVATE))
  |  |  ------------------
  |  |  |  |   67|  18.6k|#define LOCKRET(func) do {\
  |  |  |  |   68|  18.6k|	int lockret_err;		\
  |  |  |  |   69|  18.6k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 18.6k]
  |  |  |  |  ------------------
  |  |  |  |   70|  18.6k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  18.6k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 18.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   72|  18.6k|	table->sizefunc = sizefunc;
   73|  18.6k|	table->compfunc = compfunc;
   74|  18.6k|	table->delkeyfunc = delkeyfunc;
   75|  18.6k|	table->deldatafunc = deldatafunc;
   76|  18.6k|	table->cb_arg = arg;
   77|  18.6k|	table->size = start_size;
   78|  18.6k|	table->size_mask = (int)(start_size-1);
   79|  18.6k|	table->lru_start = NULL;
   80|  18.6k|	table->lru_end = NULL;
   81|  18.6k|	table->num = 0;
   82|  18.6k|	table->space_used = 0;
   83|  18.6k|	table->space_max = maxmem;
   84|  18.6k|	table->max_collisions = 0;
   85|  18.6k|	table->array = calloc(table->size, sizeof(struct lruhash_bin));
   86|  18.6k|	if(!table->array) {
  ------------------
  |  Branch (86:5): [True: 0, False: 18.6k]
  ------------------
   87|      0|		lock_quick_destroy(&table->lock);
  ------------------
  |  |  145|      0|#define lock_quick_destroy(lock) LOCKRET(pthread_spin_destroy(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   88|      0|		free(table);
   89|      0|		return NULL;
   90|      0|	}
   91|  18.6k|	bin_init(table->array, table->size);
   92|  18.6k|	lock_protect(&table->lock, table, sizeof(*table));
   93|  18.6k|	lock_protect(&table->lock, table->array, 
   94|  18.6k|		table->size*sizeof(struct lruhash_bin));
   95|  18.6k|	return table;
   96|  18.6k|}
bin_delete:
  100|  19.1M|{
  101|  19.1M|	struct lruhash_entry* p, *np;
  102|  19.1M|	void *d;
  103|  19.1M|	if(!bin)
  ------------------
  |  Branch (103:5): [True: 0, False: 19.1M]
  ------------------
  104|      0|		return;
  105|  19.1M|	lock_quick_destroy(&bin->lock);
  ------------------
  |  |  145|  19.1M|#define lock_quick_destroy(lock) LOCKRET(pthread_spin_destroy(lock))
  |  |  ------------------
  |  |  |  |   67|  19.1M|#define LOCKRET(func) do {\
  |  |  |  |   68|  19.1M|	int lockret_err;		\
  |  |  |  |   69|  19.1M|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 19.1M]
  |  |  |  |  ------------------
  |  |  |  |   70|  19.1M|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  19.1M| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 19.1M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|  19.1M|	p = bin->overflow_list;
  107|  19.1M|	bin->overflow_list = NULL;
  108|  19.1M|	while(p) {
  ------------------
  |  Branch (108:8): [True: 15.3k, False: 19.1M]
  ------------------
  109|  15.3k|		np = p->overflow_next;
  110|  15.3k|		d = p->data;
  111|  15.3k|		(*table->delkeyfunc)(p->key, table->cb_arg);
  112|  15.3k|		(*table->deldatafunc)(d, table->cb_arg);
  113|  15.3k|		p = np;
  114|  15.3k|	}
  115|  19.1M|}
lruhash_delete:
  155|  18.6k|{
  156|  18.6k|	size_t i;
  157|  18.6k|	if(!table)
  ------------------
  |  Branch (157:5): [True: 0, False: 18.6k]
  ------------------
  158|      0|		return;
  159|       |	/* delete lock on hashtable to force check its OK */
  160|  18.6k|	lock_quick_destroy(&table->lock);
  ------------------
  |  |  145|  18.6k|#define lock_quick_destroy(lock) LOCKRET(pthread_spin_destroy(lock))
  |  |  ------------------
  |  |  |  |   67|  18.6k|#define LOCKRET(func) do {\
  |  |  |  |   68|  18.6k|	int lockret_err;		\
  |  |  |  |   69|  18.6k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 18.6k]
  |  |  |  |  ------------------
  |  |  |  |   70|  18.6k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  18.6k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 18.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|  19.1M|	for(i=0; i<table->size; i++)
  ------------------
  |  Branch (161:11): [True: 19.1M, False: 18.6k]
  ------------------
  162|  19.1M|		bin_delete(table, &table->array[i]);
  163|  18.6k|	free(table->array);
  164|  18.6k|	free(table);
  165|  18.6k|}
bin_find_entry:
  221|  30.7k|{
  222|  30.7k|	size_t c = 0;
  223|  30.7k|	struct lruhash_entry* p = bin->overflow_list;
  224|  33.3k|	while(p) {
  ------------------
  |  Branch (224:8): [True: 2.60k, False: 30.7k]
  ------------------
  225|  2.60k|		if(p->hash == hash && table->compfunc(p->key, key) == 0)
  ------------------
  |  Branch (225:6): [True: 156, False: 2.45k]
  |  Branch (225:25): [True: 0, False: 156]
  ------------------
  226|      0|			break;
  227|  2.60k|		c++;
  228|  2.60k|		p = p->overflow_next;
  229|  2.60k|	}
  230|  30.7k|	if (collisions != NULL)
  ------------------
  |  Branch (230:6): [True: 15.3k, False: 15.3k]
  ------------------
  231|  15.3k|		*collisions = c;
  232|  30.7k|	return p;
  233|  30.7k|}
lru_front:
  272|  15.3k|{
  273|  15.3k|	entry->lru_prev = NULL;
  274|  15.3k|	entry->lru_next = table->lru_start;
  275|  15.3k|	if(!table->lru_start)
  ------------------
  |  Branch (275:5): [True: 1.14k, False: 14.2k]
  ------------------
  276|  1.14k|		table->lru_end = entry;
  277|  14.2k|	else	table->lru_start->lru_prev = entry;
  278|  15.3k|	table->lru_start = entry;
  279|  15.3k|}
lruhash_insert:
  307|  15.3k|{
  308|  15.3k|	struct lruhash_bin* bin;
  309|  15.3k|	struct lruhash_entry* found, *reclaimlist=NULL;
  310|  15.3k|	size_t need_size;
  311|  15.3k|	size_t collisions;
  312|  15.3k|	fptr_ok(fptr_whitelist_hash_sizefunc(table->sizefunc));
  ------------------
  |  |   71|  15.3k|	do { if(!(x)) \
  |  |  ------------------
  |  |  |  Branch (71:10): [True: 0, False: 15.3k]
  |  |  ------------------
  |  |   72|  15.3k|		fatal_exit("%s:%d: %s: pointer whitelist %s failed", \
  |  |   73|      0|		__FILE__, __LINE__, __func__, #x); \
  |  |   74|  15.3k|	} while(0);
  |  |  ------------------
  |  |  |  Branch (74:10): [Folded, False: 15.3k]
  |  |  ------------------
  ------------------
  313|  15.3k|	fptr_ok(fptr_whitelist_hash_delkeyfunc(table->delkeyfunc));
  ------------------
  |  |   71|  15.3k|	do { if(!(x)) \
  |  |  ------------------
  |  |  |  Branch (71:10): [True: 0, False: 15.3k]
  |  |  ------------------
  |  |   72|  15.3k|		fatal_exit("%s:%d: %s: pointer whitelist %s failed", \
  |  |   73|      0|		__FILE__, __LINE__, __func__, #x); \
  |  |   74|  15.3k|	} while(0);
  |  |  ------------------
  |  |  |  Branch (74:10): [Folded, False: 15.3k]
  |  |  ------------------
  ------------------
  314|  15.3k|	fptr_ok(fptr_whitelist_hash_deldatafunc(table->deldatafunc));
  ------------------
  |  |   71|  15.3k|	do { if(!(x)) \
  |  |  ------------------
  |  |  |  Branch (71:10): [True: 0, False: 15.3k]
  |  |  ------------------
  |  |   72|  15.3k|		fatal_exit("%s:%d: %s: pointer whitelist %s failed", \
  |  |   73|      0|		__FILE__, __LINE__, __func__, #x); \
  |  |   74|  15.3k|	} while(0);
  |  |  ------------------
  |  |  |  Branch (74:10): [Folded, False: 15.3k]
  |  |  ------------------
  ------------------
  315|  15.3k|	fptr_ok(fptr_whitelist_hash_compfunc(table->compfunc));
  ------------------
  |  |   71|  15.3k|	do { if(!(x)) \
  |  |  ------------------
  |  |  |  Branch (71:10): [True: 0, False: 15.3k]
  |  |  ------------------
  |  |   72|  15.3k|		fatal_exit("%s:%d: %s: pointer whitelist %s failed", \
  |  |   73|      0|		__FILE__, __LINE__, __func__, #x); \
  |  |   74|  15.3k|	} while(0);
  |  |  ------------------
  |  |  |  Branch (74:10): [Folded, False: 15.3k]
  |  |  ------------------
  ------------------
  316|  15.3k|	fptr_ok(fptr_whitelist_hash_markdelfunc(table->markdelfunc));
  ------------------
  |  |   71|  15.3k|	do { if(!(x)) \
  |  |  ------------------
  |  |  |  Branch (71:10): [True: 0, False: 15.3k]
  |  |  ------------------
  |  |   72|  15.3k|		fatal_exit("%s:%d: %s: pointer whitelist %s failed", \
  |  |   73|      0|		__FILE__, __LINE__, __func__, #x); \
  |  |   74|  15.3k|	} while(0);
  |  |  ------------------
  |  |  |  Branch (74:10): [Folded, False: 15.3k]
  |  |  ------------------
  ------------------
  317|  15.3k|	need_size = table->sizefunc(entry->key, data);
  318|  15.3k|	if(cb_arg == NULL) cb_arg = table->cb_arg;
  ------------------
  |  Branch (318:5): [True: 0, False: 15.3k]
  ------------------
  319|       |
  320|       |	/* find bin */
  321|  15.3k|	lock_quick_lock(&table->lock);
  ------------------
  |  |  146|  15.3k|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  322|  15.3k|	bin = &table->array[hash & table->size_mask];
  323|  15.3k|	lock_quick_lock(&bin->lock);
  ------------------
  |  |  146|  15.3k|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  324|       |
  325|       |	/* see if entry exists already */
  326|  15.3k|	if(!(found=bin_find_entry(table, bin, hash, entry->key, &collisions))) {
  ------------------
  |  Branch (326:5): [True: 15.3k, False: 0]
  ------------------
  327|       |		/* if not: add to bin */
  328|  15.3k|		entry->overflow_next = bin->overflow_list;
  329|  15.3k|		bin->overflow_list = entry;
  330|  15.3k|		lru_front(table, entry);
  331|  15.3k|		table->num++;
  332|  15.3k|		if (table->max_collisions < collisions)
  ------------------
  |  Branch (332:7): [True: 492, False: 14.8k]
  ------------------
  333|    492|			table->max_collisions = collisions;
  334|  15.3k|		table->space_used += need_size;
  335|  15.3k|	} else {
  336|       |		/* if so: update data - needs a writelock */
  337|      0|		table->space_used += need_size -
  338|      0|			(*table->sizefunc)(found->key, found->data);
  339|      0|		(*table->delkeyfunc)(entry->key, cb_arg);
  340|      0|		lru_touch(table, found);
  341|      0|		lock_rw_wrlock(&found->lock);
  ------------------
  |  |  121|      0|#define lock_rw_wrlock(lock) LOCKRET(pthread_rwlock_wrlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  342|      0|		(*table->deldatafunc)(found->data, cb_arg);
  343|      0|		found->data = data;
  344|      0|		lock_rw_unlock(&found->lock);
  ------------------
  |  |  122|      0|#define lock_rw_unlock(lock) LOCKRET(pthread_rwlock_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  345|      0|	}
  346|  15.3k|	lock_quick_unlock(&bin->lock);
  ------------------
  |  |  147|  15.3k|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|  15.3k|	if(table->space_used > table->space_max)
  ------------------
  |  Branch (347:5): [True: 0, False: 15.3k]
  ------------------
  348|      0|		reclaim_space(table, &reclaimlist);
  349|  15.3k|	if(table->num >= table->size)
  ------------------
  |  Branch (349:5): [True: 0, False: 15.3k]
  ------------------
  350|      0|		table_grow(table);
  351|  15.3k|	lock_quick_unlock(&table->lock);
  ------------------
  |  |  147|  15.3k|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  352|       |
  353|       |	/* finish reclaim if any (outside of critical region) */
  354|  15.3k|	while(reclaimlist) {
  ------------------
  |  Branch (354:8): [True: 0, False: 15.3k]
  ------------------
  355|      0|		struct lruhash_entry* n = reclaimlist->overflow_next;
  356|      0|		void* d = reclaimlist->data;
  357|      0|		(*table->delkeyfunc)(reclaimlist->key, cb_arg);
  358|      0|		(*table->deldatafunc)(d, cb_arg);
  359|      0|		reclaimlist = n;
  360|      0|	}
  361|  15.3k|}
lruhash_lookup:
  365|  15.3k|{
  366|  15.3k|	struct lruhash_entry* entry;
  367|  15.3k|	struct lruhash_bin* bin;
  368|  15.3k|	fptr_ok(fptr_whitelist_hash_compfunc(table->compfunc));
  ------------------
  |  |   71|  15.3k|	do { if(!(x)) \
  |  |  ------------------
  |  |  |  Branch (71:10): [True: 0, False: 15.3k]
  |  |  ------------------
  |  |   72|  15.3k|		fatal_exit("%s:%d: %s: pointer whitelist %s failed", \
  |  |   73|      0|		__FILE__, __LINE__, __func__, #x); \
  |  |   74|  15.3k|	} while(0);
  |  |  ------------------
  |  |  |  Branch (74:10): [Folded, False: 15.3k]
  |  |  ------------------
  ------------------
  369|       |
  370|  15.3k|	lock_quick_lock(&table->lock);
  ------------------
  |  |  146|  15.3k|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|  15.3k|	bin = &table->array[hash & table->size_mask];
  372|  15.3k|	lock_quick_lock(&bin->lock);
  ------------------
  |  |  146|  15.3k|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|  15.3k|	if((entry=bin_find_entry(table, bin, hash, key, NULL)))
  ------------------
  |  Branch (373:5): [True: 0, False: 15.3k]
  ------------------
  374|      0|		lru_touch(table, entry);
  375|  15.3k|	lock_quick_unlock(&table->lock);
  ------------------
  |  |  147|  15.3k|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|       |
  377|  15.3k|	if(entry) {
  ------------------
  |  Branch (377:5): [True: 0, False: 15.3k]
  ------------------
  378|      0|		if(wr)	{ lock_rw_wrlock(&entry->lock); }
  ------------------
  |  |  121|      0|#define lock_rw_wrlock(lock) LOCKRET(pthread_rwlock_wrlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (378:6): [True: 0, False: 0]
  ------------------
  379|      0|		else	{ lock_rw_rdlock(&entry->lock); }
  ------------------
  |  |  120|      0|#define lock_rw_rdlock(lock) LOCKRET(pthread_rwlock_rdlock(lock))
  |  |  ------------------
  |  |  |  |   67|      0|#define LOCKRET(func) do {\
  |  |  |  |   68|      0|	int lockret_err;		\
  |  |  |  |   69|      0|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |   70|      0|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|      0| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  380|      0|	}
  381|  15.3k|	lock_quick_unlock(&bin->lock);
  ------------------
  |  |  147|  15.3k|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  15.3k|#define LOCKRET(func) do {\
  |  |  |  |   68|  15.3k|	int lockret_err;		\
  |  |  |  |   69|  15.3k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 15.3k]
  |  |  |  |  ------------------
  |  |  |  |   70|  15.3k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  15.3k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 15.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|  15.3k|	return entry;
  383|  15.3k|}
lruhash_setmarkdel:
  525|  18.6k|{
  526|  18.6k|	lock_quick_lock(&table->lock);
  ------------------
  |  |  146|  18.6k|#define lock_quick_lock(lock) LOCKRET(pthread_spin_lock(lock))
  |  |  ------------------
  |  |  |  |   67|  18.6k|#define LOCKRET(func) do {\
  |  |  |  |   68|  18.6k|	int lockret_err;		\
  |  |  |  |   69|  18.6k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 18.6k]
  |  |  |  |  ------------------
  |  |  |  |   70|  18.6k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  18.6k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 18.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  527|  18.6k|	table->markdelfunc = md;
  528|  18.6k|	lock_quick_unlock(&table->lock);
  ------------------
  |  |  147|  18.6k|#define lock_quick_unlock(lock) LOCKRET(pthread_spin_unlock(lock))
  |  |  ------------------
  |  |  |  |   67|  18.6k|#define LOCKRET(func) do {\
  |  |  |  |   68|  18.6k|	int lockret_err;		\
  |  |  |  |   69|  18.6k|	if( (lockret_err=(func)) != 0)		\
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (69:6): [True: 0, False: 18.6k]
  |  |  |  |  ------------------
  |  |  |  |   70|  18.6k|		log_err("%s at %d could not " #func ": %s", \
  |  |  |  |   71|      0|		__FILE__, __LINE__, strerror(lockret_err));	\
  |  |  |  |   72|  18.6k| 	} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (72:11): [Folded, False: 18.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  529|  18.6k|}

slabhash_create:
   52|  4.66k|{
   53|  4.66k|	size_t i;
   54|  4.66k|	struct slabhash* sl = (struct slabhash*)calloc(1, 
   55|  4.66k|		sizeof(struct slabhash));
   56|  4.66k|	if(!sl) return NULL;
  ------------------
  |  Branch (56:5): [True: 0, False: 4.66k]
  ------------------
   57|  4.66k|	sl->size = numtables;
   58|  4.66k|	log_assert(sl->size > 0);
   59|  4.66k|	sl->array = (struct lruhash**)calloc(sl->size, sizeof(struct lruhash*));
   60|  4.66k|	if(!sl->array) {
  ------------------
  |  Branch (60:5): [True: 0, False: 4.66k]
  ------------------
   61|      0|		free(sl);
   62|      0|		return NULL;
   63|      0|	}
   64|  4.66k|	sl->mask = (uint32_t)(sl->size - 1);
   65|  4.66k|	if(sl->mask == 0) {
  ------------------
  |  Branch (65:5): [True: 0, False: 4.66k]
  ------------------
   66|      0|		sl->shift = 0;
   67|  4.66k|	} else {
   68|  4.66k|		log_assert( (sl->size & sl->mask) == 0 
   69|  4.66k|			/* size must be power of 2 */ );
   70|  4.66k|		sl->shift = 0;
   71|   144k|		while(!(sl->mask & 0x80000000)) {
  ------------------
  |  Branch (71:9): [True: 139k, False: 4.66k]
  ------------------
   72|   139k|			sl->mask <<= 1;
   73|   139k|			sl->shift ++;
   74|   139k|		}
   75|  4.66k|	}
   76|  23.3k|	for(i=0; i<sl->size; i++) {
  ------------------
  |  Branch (76:11): [True: 18.6k, False: 4.66k]
  ------------------
   77|  18.6k|		sl->array[i] = lruhash_create(start_size, maxmem / sl->size,
   78|  18.6k|			sizefunc, compfunc, delkeyfunc, deldatafunc, arg);
   79|  18.6k|		if(!sl->array[i]) {
  ------------------
  |  Branch (79:6): [True: 0, False: 18.6k]
  ------------------
   80|      0|			slabhash_delete(sl);
   81|      0|			return NULL;
   82|      0|		}
   83|  18.6k|	}
   84|  4.66k|	return sl;
   85|  4.66k|}
slabhash_delete:
   88|  4.66k|{
   89|  4.66k|	if(!sl)
  ------------------
  |  Branch (89:5): [True: 0, False: 4.66k]
  ------------------
   90|      0|		return;
   91|  4.66k|	if(sl->array) {
  ------------------
  |  Branch (91:5): [True: 4.66k, False: 0]
  ------------------
   92|  4.66k|		size_t i;
   93|  23.3k|		for(i=0; i<sl->size; i++)
  ------------------
  |  Branch (93:12): [True: 18.6k, False: 4.66k]
  ------------------
   94|  18.6k|			lruhash_delete(sl->array[i]);
   95|  4.66k|		free(sl->array);
   96|  4.66k|	}
   97|  4.66k|	free(sl);
   98|  4.66k|}
slabhash_insert:
  118|  15.3k|{
  119|  15.3k|	lruhash_insert(sl->array[slab_idx(sl, hash)], hash, entry, data, arg);
  120|  15.3k|}
slabhash_lookup:
  124|  15.3k|{
  125|  15.3k|	return lruhash_lookup(sl->array[slab_idx(sl, hash)], hash, key, wr);
  126|  15.3k|}
slabhash_setmarkdel:
  226|  4.66k|{
  227|  4.66k|	size_t i;
  228|  23.3k|	for(i=0; i<sl->size; i++) {
  ------------------
  |  Branch (228:11): [True: 18.6k, False: 4.66k]
  ------------------
  229|  18.6k|		lruhash_setmarkdel(sl->array[i], md);
  230|  18.6k|	}
  231|  4.66k|}
slabhash.c:slab_idx:
  112|  30.7k|{
  113|  30.7k|	return ((hash & sl->mask) >> sl->shift);
  114|  30.7k|}

ub_get_event_sys:
  228|  4.66k|{
  229|       |#ifdef USE_WINSOCK
  230|       |	(void)base;
  231|       |	*n = "event";
  232|       |	*s = "winsock";
  233|       |	*m = "WSAWaitForMultipleEvents";
  234|       |#elif defined(USE_MINI_EVENT)
  235|       |	(void)base;
  236|  4.66k|	*n = "mini-event";
  237|  4.66k|	*s = "internal";
  238|  4.66k|	*m = "select";
  239|       |#else
  240|       |	struct event_base* b = AS_EVENT_BASE(base);
  241|       |	*s = event_get_version();
  242|       |#  if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)
  243|       |	*n = "libev";
  244|       |	if (!b)
  245|       |		b = (struct event_base*)ev_default_loop(EVFLAG_AUTO);
  246|       |#    ifdef EV_FEATURE_BACKENDS
  247|       |	*m = ub_ev_backend2str(ev_backend((struct ev_loop*)b));
  248|       |#    else
  249|       |	*m = "not obtainable";
  250|       |#    endif
  251|       |#  elif defined(HAVE_EVENT_BASE_GET_METHOD)
  252|       |	*n = "libevent";
  253|       |	if (!b)
  254|       |		b = event_base_new();
  255|       |	*m = event_base_get_method(b);
  256|       |#  else
  257|       |	*n = "unknown";
  258|       |	*m = "not obtainable";
  259|       |	(void)b;
  260|       |#  endif
  261|       |#  ifdef HAVE_EVENT_BASE_FREE
  262|       |	if (b && b != AS_EVENT_BASE(base))
  263|       |		event_base_free(b);
  264|       |#  endif
  265|       |#endif
  266|  4.66k|}
ub_default_event_base:
  270|  4.66k|{
  271|  4.66k|	void* base;
  272|       |
  273|  4.66k|	(void)base;
  274|  4.66k|#ifdef USE_MINI_EVENT
  275|  4.66k|	(void)sigs;
  276|       |	/* use mini event time-sharing feature */
  277|  4.66k|	base = event_init(time_secs, time_tv);
  ------------------
  |  |   69|  4.66k|#define event_init minievent_init
  ------------------
  278|       |#else
  279|       |	(void)time_secs;
  280|       |	(void)time_tv;
  281|       |#  if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)
  282|       |	/* libev */
  283|       |	if(sigs)
  284|       |		base = ev_default_loop(EVFLAG_AUTO);
  285|       |	else
  286|       |		base = ev_loop_new(EVFLAG_AUTO);
  287|       |#  else
  288|       |	(void)sigs;
  289|       |#    ifdef HAVE_EVENT_BASE_NEW
  290|       |	base = event_base_new();
  291|       |#    else
  292|       |	base = event_init();
  293|       |#    endif
  294|       |#  endif
  295|       |#endif
  296|  4.66k|	return (struct ub_event_base*)base;
  297|  4.66k|}
ub_event_base_free:
  323|  4.66k|{
  324|  4.66k|#ifdef USE_MINI_EVENT
  325|  4.66k|	event_base_free(AS_EVENT_BASE(base));
  ------------------
  |  |   74|  4.66k|#define event_base_free minievent_base_free
  ------------------
              	event_base_free(AS_EVENT_BASE(base));
  ------------------
  |  |  200|  4.66k|#define AS_EVENT_BASE(x) ((struct event_base*)x)
  ------------------
  326|       |#elif defined(HAVE_EVENT_BASE_FREE) && defined(HAVE_EVENT_BASE_ONCE)
  327|       |	/* only libevent 1.2+ has it, but in 1.2 it is broken - 
  328|       |	   assertion fails on signal handling ev that is not deleted
  329|       | 	   in libevent 1.3c (event_base_once appears) this is fixed. */
  330|       |	event_base_free(AS_EVENT_BASE(base));
  331|       |#else
  332|       |	(void)base;
  333|       |#endif /* HAVE_EVENT_BASE_FREE and HAVE_EVENT_BASE_ONCE */
  334|  4.66k|}
ub_comm_base_now:
  508|  4.66k|{
  509|  4.66k|#ifdef USE_MINI_EVENT
  510|       |/** minievent updates the time when it blocks. */
  511|  4.66k|	(void)cb; /* nothing to do */
  512|       |#else /* !USE_MINI_EVENT */
  513|       |/** fillup the time values in the event base */
  514|       |	time_t *tt;
  515|       |	struct timeval *tv;
  516|       |	comm_base_timept(cb, &tt, &tv);
  517|       |	if(gettimeofday(tv, NULL) < 0) {
  518|       |		log_err("gettimeofday: %s", strerror(errno));
  519|       |	}
  520|       |#ifndef S_SPLINT_S
  521|       |	*tt = tv->tv_sec;
  522|       |#endif
  523|       |#endif /* USE_MINI_EVENT */
  524|  4.66k|}

