Skip to content

Commit

Permalink
Remove dead store, redundant cast, and possible NULL dereference
Browse files Browse the repository at this point in the history
Found during static analysis with clang-tidy-9.
  • Loading branch information
Wolfram Rösler committed May 8, 2020
1 parent d0f7287 commit 37c6cee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libmdnsd/1035.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ void message_rdata_srv(struct message *m, unsigned short int priority, unsigned

void message_rdata_raw(struct message *m, unsigned char *rdata, unsigned short int rdlength)
{
if (((unsigned char *)m->_buf - m->_packet) + rdlength > 4096)
if ((m->_buf - m->_packet) + rdlength > 4096)
rdlength = 0;
short2net(rdlength, &(m->_buf));
memcpy(m->_buf, rdata, rdlength);
Expand Down Expand Up @@ -516,5 +516,5 @@ int message_packet_len(struct message *m)
if (m->_buf == 0)
return 12;

return (unsigned char *)m->_buf - m->_packet;
return m->_buf - m->_packet;
}
4 changes: 2 additions & 2 deletions libmdnsd/mdnsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ int mdnsd_out(mdns_daemon_t *d, struct message *m, struct in_addr *ip, unsigned

if (d->probing == r)
d->probing = r->list;
else
else if (last)
last->list = r->list;

r->list = 0;
Expand All @@ -1014,7 +1014,7 @@ int mdnsd_out(mdns_daemon_t *d, struct message *m, struct in_addr *ip, unsigned
}

/* Scan probe list again to append our to-be answers */
for (r = d->probing; r != 0; last = r, r = r->list) {
for (r = d->probing; r != 0; r = r->list) {
r->unique++;

INFO("Send Answer in Probe: Name: %s, Type: %d", r->rr.name, r->rr.type);
Expand Down

0 comments on commit 37c6cee

Please sign in to comment.