Commit 01d1ecd0 authored by Daniel Salzman's avatar Daniel Salzman

fix some unused variables and comparison of different types III

parent 43102cc2
......@@ -83,7 +83,7 @@ static int acl_compare(void *k1, void *k2)
*/
while (chunk > 0) {
uint32_t mask = 0xffffffff;
if (chunk > sizeof(mask) << 3) {
if ((size_t)chunk > sizeof(mask) << 3) {
chunk -= sizeof(mask) << 3;
} else {
mask = acl_fill_mask32(chunk);
......
......@@ -308,7 +308,7 @@ static int conf_process(conf_t *conf)
/* Copy origin and remove bad characters. */
memcpy(dpos, zone->name, zname_len + 1);
for (int i = 0; i < zname_len; ++i) {
for (size_t i = 0; i < zname_len; ++i) {
if (dpos[i] == '/') dpos[i] = '_';
}
......@@ -334,7 +334,7 @@ static int conf_process(conf_t *conf)
const char *dbext = "diff.db";
memcpy(dpos, zone->name, zname_len + 1);
for (int i = 0; i < zname_len; ++i) {
for (size_t i = 0; i < zname_len; ++i) {
if (dpos[i] == '/') dpos[i] = '_';
}
memcpy(dpos + zname_len, dbext, strlen(dbext) + 1);
......
......@@ -98,7 +98,7 @@ static char *path_relative_to(const char *filename, const char *reference)
int w;
w = snprintf(result, result_len, "%.*s/%s", path_len, reference, filename);
assert(w + 1 == result_len);
assert(w + 1 == (int)result_len);
return result;
}
......
......@@ -134,7 +134,7 @@ int proc_update_privileges(int uid, int gid)
{
#ifdef HAVE_SETGROUPS
/* Drop supplementary groups. */
if (uid != getuid() || gid != getgid()) {
if ((uid_t)uid != getuid() || (gid_t)gid != getgid()) {
if (setgroups(0, NULL) < 0) {
log_server_warning("Failed to drop supplementary groups"
" for uid '%d' (%s).\n",
......@@ -144,14 +144,14 @@ int proc_update_privileges(int uid, int gid)
#endif
/* Watch uid/gid. */
if (gid != getgid()) {
if ((gid_t)gid != getgid()) {
log_server_info("Changing group id to '%d'.\n", gid);
if (setregid(gid, gid) < 0) {
log_server_error("Failed to change gid to '%d'.\n",
gid);
}
}
if (uid != getuid()) {
if ((uid_t)uid != getuid()) {
log_server_info("Changing user id to '%d'.\n", uid);
if (setreuid(uid, uid) < 0) {
log_server_error("Failed to change uid to '%d'.\n",
......
......@@ -167,6 +167,7 @@ static int remote_zone_flush(server_t *s, const knot_zone_t *z)
*/
static int remote_c_reload(server_t *s, remote_cmdargs_t* a)
{
UNUSED(a);
return server_reload(s, conf()->filename);
}
......@@ -178,6 +179,8 @@ static int remote_c_reload(server_t *s, remote_cmdargs_t* a)
*/
static int remote_c_status(server_t *s, remote_cmdargs_t* a)
{
UNUSED(s);
UNUSED(a);
/*! \todo #2035 Add some TXT RRs with stats. */
dbg_server("remote: %s\n", __func__);
return KNOT_EOK;
......@@ -248,14 +251,15 @@ static int remote_c_zonestatus(server_t *s, remote_cmdargs_t* a)
/* Workaround, some platforms ignore 'size' with snprintf() */
char buf[256];
int n = snprintf(buf, sizeof(buf), "%s\ttype=%s | serial=%u | %s %s\n",
int n = snprintf(buf, sizeof(buf),
"%s\ttype=%s | serial=%u | %s %s\n",
zd->conf->name,
zd->xfr_in.has_master ? "slave" : "master",
serial,
state ? state : "",
when ? when : "");
free(when);
if (n > rb) {
if (n < 0 || (size_t)n > rb) {
*dst = '\0';
ret = KNOT_ESPACE;
break;
......
......@@ -851,7 +851,7 @@ unsigned dt_get_id(dthread_t *thread)
}
dt_unit_t *unit = thread->unit;
for(unsigned tid = 0; tid < unit->size; ++tid) {
for(int tid = 0; tid < unit->size; ++tid) {
if (thread == unit->threads[tid]) {
return tid;
}
......
......@@ -570,7 +570,7 @@ int server_conf_hook(const struct conf_t *conf, void *data)
if (tu_size < 1) {
tu_size = dt_optimal_size();
}
if (tu_size != server->tu_size) {
if ((unsigned)tu_size != server->tu_size) {
/* Free old handlers */
if (server->tu_size > 0) {
for (unsigned i = 0; i < IO_COUNT; ++i) {
......@@ -605,7 +605,7 @@ int server_conf_hook(const struct conf_t *conf, void *data)
}
}
if (server->rrl) {
if (rrl_rate(server->rrl) != conf->rrl) {
if (rrl_rate(server->rrl) != (uint32_t)conf->rrl) {
rrl_setrate(server->rrl, conf->rrl);
log_server_info("Rate limiting set to %u responses/sec.\n",
conf->rrl);
......
......@@ -150,11 +150,10 @@ static int find_rrset_for_rrsig_in_node(knot_zone_contents_t *zone,
}
static knot_node_t *create_node(knot_zone_contents_t *zone,
knot_rrset_t *current_rrset,
int (*node_add_func)(knot_zone_contents_t *zone, knot_node_t *node,
int create_parents, uint8_t),
knot_node_t *(*node_get_func)(const knot_zone_contents_t *zone,
const knot_dname_t *owner))
knot_rrset_t *current_rrset,
int (*node_add_func)(knot_zone_contents_t *zone,
knot_node_t *node,
int create_parents, uint8_t))
{
dbg_zp_verb("zp: create_node: Creating node using RRSet: %p.\n",
current_rrset);
......@@ -453,8 +452,9 @@ static void process_rr(const scanner_t *scanner)
if (parser->last_node == NULL) {
/* Still NULL, node has to be created. */
if ((parser->last_node = create_node(contents,
current_rrset, node_add_func,
node_get_func)) == NULL) {
current_rrset,
node_add_func))
== NULL) {
knot_rrset_free(&tmp_rrsig);
dbg_zp("zp: process_rr: Cannot "
"create new node.\n");
......@@ -507,8 +507,7 @@ static void process_rr(const scanner_t *scanner)
}
if ((node = create_node(contents, current_rrset,
node_add_func,
node_get_func)) == NULL) {
node_add_func)) == NULL) {
dbg_zp("zp: process_rr: Cannot "
"create new node.\n");
/*!< \todo consider a new error */
......
......@@ -63,7 +63,7 @@ int knot_edns_new_from_wire(knot_opt_rr_t *opt_rr, const uint8_t *wire,
return KNOT_EINVAL;
}
if (max_size < KNOT_EDNS_MIN_SIZE) {
if ((int)max_size < KNOT_EDNS_MIN_SIZE) {
dbg_edns("Not enough data to parse OPT RR header.\n");
return KNOT_EFEWDATA;
}
......@@ -355,9 +355,9 @@ short knot_edns_to_wire(const knot_opt_rr_t *opt_rr, uint8_t *wire,
return KNOT_EINVAL;
}
assert(KNOT_EDNS_MIN_SIZE <= max_size);
assert(KNOT_EDNS_MIN_SIZE <= (int)max_size);
if (max_size < opt_rr->size) {
if ((int)max_size < opt_rr->size) {
dbg_edns("Not enough place for OPT RR wire format.\n");
return KNOT_ESPACE;
}
......
......@@ -85,7 +85,7 @@ static uint8_t *knot_nsec3_to_lowercase(const uint8_t *data, size_t size)
uint8_t *out = (uint8_t *)malloc(size);
CHECK_ALLOC_LOG(out, NULL);
for (int i = 0; i < size; ++i) {
for (size_t i = 0; i < size; ++i) {
out[i] = knot_tolower(data[i]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment