From: Wouter Wijngaards Date: Wed, 14 Feb 2007 10:10:43 +0000 (+0000) Subject: Reviewing and porting. X-Git-Tag: release-0.0~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5fec5aa08b8c815f56e7267d020becb152275fa;p=thirdparty%2Funbound.git Reviewing and porting. git-svn-id: file:///svn/unbound/trunk@97 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/Makefile.in b/Makefile.in index 95718a1e5..9aa890f1f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -112,7 +112,7 @@ ifdef doxygen endif # Automatic dependencies. -$(BUILD)%.d: $(srcdir)/%.c +$(BUILD)%.d: $(srcdir)/%.c testcode/ldns-testpkts.c $(INFO) Depend $< @if test ! -d $(dir $@); then $(INSTALL) -d $(patsubst %/,%,$(dir $@)); fi $Q$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $(CFLAGS) $< \ diff --git a/doc/Changelog b/doc/Changelog index 37983ee8b..e47f22a7d 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,11 @@ - Included configure.ac changes from ldns. - detect (some) headers before the standards check. - do not use isblank to test c99, since its not available on solaris9. + - review of testcode. + * entries in a RANGE are no longer reversed. + * print name of file with replay entry parse errors. + - port to OSX: cast to int for some prints of sizet. + - Makefile copies ldnstestpkts.c before doing dependencies on it. 13 February 2007: Wouter - work on fake events, first fwd replay works. diff --git a/testcode/replay.c b/testcode/replay.c index 4fe76698d..216e1400f 100644 --- a/testcode/replay.c +++ b/testcode/replay.c @@ -52,7 +52,8 @@ * @param keyword: string. * @return: true if found, false if not. */ -static int parse_keyword(char** line, char* keyword) +static int +parse_keyword(char** line, char* keyword) { size_t len = (size_t)strlen(keyword); if(strncmp(*line, keyword, len) == 0) { @@ -88,6 +89,7 @@ replay_range_delete(struct replay_range* rng) * Read a range from file. * @param remain: Rest of line (after RANGE keyword). * @param in: file to read from. + * @param name: name to print in errors. * @param lineno: incremented as lines are read. * @param line: line buffer. * @param ttl: for readentry @@ -96,14 +98,14 @@ replay_range_delete(struct replay_range* rng) * @return: range object to add to list, or NULL on error. */ static struct replay_range* -replay_range_read(char* remain, FILE* in, int* lineno, char* line, - uint16_t* ttl, ldns_rdf** or, ldns_rdf** prev) +replay_range_read(char* remain, FILE* in, const char* name, int* lineno, + char* line, uint16_t* ttl, ldns_rdf** or, ldns_rdf** prev) { struct replay_range* rng = (struct replay_range*)malloc( sizeof(struct replay_range)); off_t pos; char *parse; - struct entry* entry; + struct entry* entry, *last = NULL; if(!rng) return NULL; memset(rng, 0, sizeof(*rng)); @@ -128,11 +130,14 @@ replay_range_read(char* remain, FILE* in, int* lineno, char* line, /* set position before line; read entry */ (*lineno)--; fseeko(in, pos, SEEK_SET); - entry = read_entry(in, "datafile", lineno, ttl, or, prev); + entry = read_entry(in, name, lineno, ttl, or, prev); if(!entry) fatal_exit("%d: bad entry", *lineno); - entry->next = rng->match; - rng->match = entry; + entry->next = NULL; + if(last) + last->next = entry; + else rng->match = entry; + last = entry; pos = ftello(in); } @@ -144,6 +149,7 @@ replay_range_read(char* remain, FILE* in, int* lineno, char* line, * Read a replay moment 'STEP' from file. * @param remain: Rest of line (after STEP keyword). * @param in: file to read from. + * @param name: name to print in errors. * @param lineno: incremented as lines are read. * @param ttl: for readentry * @param or: for readentry @@ -151,7 +157,7 @@ replay_range_read(char* remain, FILE* in, int* lineno, char* line, * @return: range object to add to list, or NULL on error. */ static struct replay_moment* -replay_moment_read(char* remain, FILE* in, int* lineno, +replay_moment_read(char* remain, FILE* in, const char* name, int* lineno, uint16_t* ttl, ldns_rdf** or, ldns_rdf** prev) { struct replay_moment* mom = (struct replay_moment*)malloc( @@ -162,7 +168,7 @@ replay_moment_read(char* remain, FILE* in, int* lineno, return NULL; memset(mom, 0, sizeof(*mom)); if(sscanf(remain, " %d%n", &mom->time_step, &skip) != 1) { - log_err("%d: cannot read value: %s", *lineno, remain); + log_err("%d: cannot read number: %s", *lineno, remain); free(mom); return NULL; } @@ -194,7 +200,7 @@ replay_moment_read(char* remain, FILE* in, int* lineno, } if(readentry) { - mom->match = read_entry(in, "datafile", lineno, ttl, or, prev); + mom->match = read_entry(in, name, lineno, ttl, or, prev); if(!mom->match) { free(mom); return NULL; @@ -228,7 +234,7 @@ make_scenario(char* line) } struct replay_scenario* -replay_scenario_read(FILE* in) +replay_scenario_read(FILE* in, const char* name) { char line[MAX_LINE_LEN]; char *parse; @@ -257,15 +263,15 @@ replay_scenario_read(FILE* in) if(!scen) fatal_exit("%d: expected SCENARIO", lineno); if(parse_keyword(&parse, "RANGE_BEGIN")) { - struct replay_range* newr = replay_range_read( - parse, in, &lineno, line, &ttl, &or, &prev); + struct replay_range* newr = replay_range_read(parse, + in, name, &lineno, line, &ttl, &or, &prev); if(!newr) fatal_exit("%d: bad range", lineno); newr->next_range = scen->range_list; scen->range_list = newr; } else if(parse_keyword(&parse, "STEP")) { - struct replay_moment* mom = replay_moment_read( - parse, in, &lineno, &ttl, &or, &prev); + struct replay_moment* mom = replay_moment_read(parse, + in, name, &lineno, &ttl, &or, &prev); if(!mom) fatal_exit("%d: bad moment", lineno); if(scen->mom_last) diff --git a/testcode/replay.h b/testcode/replay.h index c605a8da3..51fd71717 100644 --- a/testcode/replay.h +++ b/testcode/replay.h @@ -262,9 +262,10 @@ struct replay_answer { /** * Read a replay scenario from the file. * @param in: file to read from. + * @param name: name to print in errors. * @return: Scenario. NULL if no scenario read. */ -struct replay_scenario* replay_scenario_read(FILE* in); +struct replay_scenario* replay_scenario_read(FILE* in, const char* name); /** * Delete scenario. diff --git a/testcode/testbound.c b/testcode/testbound.c index c700a51b5..0f5b9f629 100644 --- a/testcode/testbound.c +++ b/testcode/testbound.c @@ -130,7 +130,7 @@ setup_playback(const char* filename) perror(filename); exit(1); } - scen = replay_scenario_read(in); + scen = replay_scenario_read(in, filename); fclose(in); if(!scen) fatal_exit("Could not read: %s", filename); diff --git a/util/net_help.c b/util/net_help.c index f5e065e95..ef2ee72ac 100644 --- a/util/net_help.c +++ b/util/net_help.c @@ -34,7 +34,7 @@ */ /** * \file - * Implementation of log.h. + * Implementation of net_help.h. */ #include "config.h" diff --git a/util/netevent.c b/util/netevent.c index cc4f2d5f3..7002e65c2 100644 --- a/util/netevent.c +++ b/util/netevent.c @@ -207,7 +207,7 @@ comm_point_send_udp_msg(struct comm_point *c, ldns_buffer* packet, return 0; } else if((size_t)sent != ldns_buffer_remaining(packet)) { log_err("sent %d in place of %d bytes", - sent, (int)ldns_buffer_remaining(packet)); + (int)sent, (int)ldns_buffer_remaining(packet)); return 0; } return 1; @@ -383,7 +383,7 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c) return 0; } log_info("Reading tcp query of length %d", - ldns_buffer_limit(c->buffer)); + (int)ldns_buffer_limit(c->buffer)); } r = read(fd, ldns_buffer_current(c->buffer),