From: Simon Budig Date: Thu, 22 Jan 2009 23:01:19 +0000 (+0100) Subject: fix warnings and a crasher in mdnsd.c X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;ds=sidebyside;h=79a9bc5a324653b0d0ef2616cb099a47ca3444d8;p=mdnsd.git fix warnings and a crasher in mdnsd.c --- diff --git a/mdnsd.c b/mdnsd.c index 2efc0a7..68e69cd 100644 --- a/mdnsd.c +++ b/mdnsd.c @@ -1,5 +1,7 @@ -#include "mdnsd.h" #include +#include +#include +#include "mdnsd.h" // size of query/publish hashes #define SPRIME 108 @@ -198,7 +200,7 @@ void _q_reset(mdnsd d, struct query *q) struct cached *cur = 0; q->nexttry = 0; q->tries = 0; - while(cur = _c_next(d,cur,q->name,q->type)) + while((cur = _c_next(d,cur,q->name,q->type))) if(q->nexttry == 0 || cur->rr.ttl - 7 < q->nexttry) q->nexttry = cur->rr.ttl - 7; if(q->nexttry != 0 && q->nexttry < d->checkqlist) d->checkqlist = q->nexttry; } @@ -208,7 +210,7 @@ void _q_done(mdnsd d, struct query *q) struct cached *c = 0; struct query *cur; int i = _namehash(q->name) % LPRIME; - while(c = _c_next(d,c,q->name,q->type)) c->q = 0; + while((c = _c_next(d,c,q->name,q->type))) c->q = 0; if(d->qlist == q) d->qlist = q->list; else { for(cur=d->qlist;cur->list != q;cur = cur->list); @@ -288,18 +290,18 @@ void _cache(mdnsd d, struct resource *r) if(r->class == 32768 + d->class) { // cache flush - while(c = _c_next(d,c,r->name,r->type)) c->rr.ttl = 0; + while((c = _c_next(d,c,r->name,r->type))) c->rr.ttl = 0; _c_expire(d,&d->cache[i]); } - + if(r->ttl == 0) { // process deletes - while(c = _c_next(d,c,r->name,r->type)) + while((c = _c_next(d,c,r->name,r->type))) if(_a_match(r,&c->rr)) { c->rr.ttl = 0; - _c_expire(d,&d->cache[i]); } + _c_expire(d,&d->cache[i]); return; } @@ -330,7 +332,7 @@ void _cache(mdnsd d, struct resource *r) } c->next = d->cache[i]; d->cache[i] = c; - if(c->q = _q_next(d, 0, r->name, r->type)) + if((c->q = _q_next(d, 0, r->name, r->type))) _q_answer(d,c); } @@ -344,7 +346,7 @@ void _a_copy(struct message *m, mdnsda a) int _r_out(mdnsd d, struct message *m, mdnsdr *list) { // copy a published record into an outgoing message - mdnsdr r, next; + mdnsdr r; int ret = 0; while((r = *list) != 0 && message_packet_len(m) + _rr_len(&r->rr) < d->frame) { @@ -363,7 +365,6 @@ int _r_out(mdnsd d, struct message *m, mdnsdr *list) mdnsd mdnsd_new(int class, int frame) { - int i; mdnsd d; d = (mdnsd)malloc(sizeof(struct mdnsd_struct)); bzero(d,sizeof(struct mdnsd_struct)); @@ -401,7 +402,6 @@ void mdnsd_flush(mdnsd d) void mdnsd_free(mdnsd d) { - int i; // loop through all hashes, free everything // free answers if any free(d); @@ -467,7 +467,7 @@ int mdnsd_out(mdnsd d, struct message *m, unsigned long int *ip, unsigned short *ip = inet_addr("224.0.0.251"); m->header.qr = 1; m->header.aa = 1; - + if(d->uanswers) { // send out individual unicast answers struct unicast *u = d->uanswers; @@ -612,7 +612,6 @@ int mdnsd_out(mdnsd d, struct message *m, unsigned long int *ip, unsigned short struct timeval *mdnsd_sleep(mdnsd d) { int sec, usec; - mdnsdr r; d->sleep.tv_sec = d->sleep.tv_usec = 0; #define RET while(d->sleep.tv_usec > 1000000) {d->sleep.tv_sec++;d->sleep.tv_usec -= 1000000;} return &d->sleep; @@ -620,7 +619,7 @@ struct timeval *mdnsd_sleep(mdnsd d) if(d->uanswers || d->a_now) return &d->sleep; gettimeofday(&d->now,0); - + if(d->a_pause) { // then check for paused answers if((usec = _tvdiff(d->now,d->pause)) > 0) d->sleep.tv_usec = usec; @@ -665,7 +664,7 @@ void mdnsd_query(mdnsd d, char *host, int type, int (*answer)(mdnsda a, void *ar q->next = d->queries[i]; q->list = d->qlist; d->qlist = d->queries[i] = q; - while(cur = _c_next(d,cur,q->name,q->type)) + while((cur = _c_next(d,cur,q->name,q->type))) cur->q = q; // any cached entries should be associated _q_reset(d,q); q->nexttry = d->checkqlist = d->now.tv_sec; // new questin, immediately send out