Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clang-tidy findings #33

Merged
merged 4 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added libmdnsd/.1035.c.swp
Binary file not shown.
14 changes: 7 additions & 7 deletions libmdnsd/1035.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void long2net(unsigned long int l, unsigned char **bufp)
*bufp += 4;
}

static unsigned short int _ldecomp(char *ptr)
static unsigned short int _ldecomp(const char *ptr)
{
unsigned short int i;

Expand Down Expand Up @@ -152,7 +152,7 @@ static int _label(struct message *m, unsigned char **bufp, char **namep)
}

/* Internal label matching */
static int _lmatch(struct message *m, char *l1, char *l2)
static int _lmatch(const struct message *m, const char *l1, const char *l2)
{
int len;

Expand Down Expand Up @@ -187,7 +187,7 @@ static int _lmatch(struct message *m, char *l1, char *l2)
}

/* Nasty, convert host into label using compression */
static int _host(struct message *m, unsigned char **bufp, char *name)
static int _host(struct message *m, unsigned char **bufp, const char *name)
{
char label[256], *l;
int len = 0, x = 1, y = 0, last = 0;
Expand Down Expand Up @@ -329,8 +329,8 @@ static int _rrparse(struct message *m, struct resource *rr, int count, unsigned
#define my(x,y) \
while (m->_len & 7) \
m->_len++; \
x = (void *)(m->_packet + m->_len); \
m->_len += y;
(x) = (void *)(m->_packet + m->_len); \
m->_len += (y);

int message_parse(struct message *m, unsigned char *packet)
{
Expand Down 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
4 changes: 2 additions & 2 deletions libmdnsd/sdtxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ static int _sd2txt_len(const char *key, char *val)
return ret;
}

static void _sd2txt_count(xht_t *h, const char *key, void *val, void *arg)
static void _sd2txt_count(xht_t *__attribute__((unused)) h, const char *key, void *val, void *arg)
{
int *count = (int *)arg;

*count += _sd2txt_len(key, (char *)val) + 1;
}

static void _sd2txt_write(xht_t *h, const char *key, void *val, void *arg)
static void _sd2txt_write(xht_t *__attribute__((unused)) h, const char *key, void *val, void *arg)
{
unsigned char **txtp = (unsigned char **)arg;
char *cval = (char *)val;
Expand Down
2 changes: 1 addition & 1 deletion src/mdnsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

/* From The Practice of Programming, by Kernighan and Pike */
#ifndef NELEMS
#define NELEMS(array) (sizeof(array) / sizeof(array[0]))
#define NELEMS(array) (sizeof(array) / sizeof((array)[0]))
#endif

void mdnsd_conflict(char *name, int type, void *arg);
Expand Down