Fix -Wsign-compare warnings: make loop counters unsigned

This commit is contained in:
Andrew Bettison 2013-12-10 16:21:23 +10:30
parent f79e6f703a
commit 5d741361ea
16 changed files with 93 additions and 92 deletions

10
cli.c
View File

@ -44,7 +44,7 @@ int cli_usage_args(const int argc, const char *const *args, const struct cli_sch
unsigned cmd;
int matched_any = 0;
for (cmd = 0; commands[cmd].function; ++cmd) {
unsigned opt;
int opt;
const char *word;
int matched = 1;
for (opt = 0; matched && opt < argc && (word = commands[cmd].words[opt]); ++opt)
@ -99,7 +99,7 @@ int cli_parse(const int argc, const char *const *args, const struct cli_schema *
cmdpa.labelc = 0;
cmdpa.varargi = -1;
const char *pattern = NULL;
unsigned arg = 0;
int arg = 0;
unsigned opt = 0;
while ((pattern = commands[cmd].words[opt])) {
//DEBUGF("cmd=%d opt=%d pattern='%s' args[arg=%d]='%s'", cmd, opt, pattern, arg, arg < argc ? args[arg] : "");
@ -167,7 +167,7 @@ int cli_parse(const int argc, const char *const *args, const struct cli_schema *
pattern += 1;
patlen -= 2;
}
unsigned oarg = arg;
int oarg = arg;
const char *text = NULL;
const char *label = NULL;
unsigned labellen = 0;
@ -277,7 +277,7 @@ void _debug_cli_parsed(struct __sourceloc __whence, const struct cli_parsed *par
{
DEBUG_argv("command", parsed->argc, parsed->args);
strbuf b = strbuf_alloca(1024);
int i;
unsigned i;
for (i = 0; i < parsed->labelc; ++i) {
const struct labelv *lab = &parsed->labelv[i];
strbuf_sprintf(b, " %s=%s", alloca_toprint(-1, lab->label, lab->len), alloca_str_toprint(lab->text));
@ -300,7 +300,7 @@ int _cli_arg(struct __sourceloc __whence, const struct cli_parsed *parsed, char
int labellen = strlen(label);
if (dst)
*dst = defaultvalue;
int i;
unsigned i;
for (i = 0; i < parsed->labelc; ++i) {
if (parsed->labelv[i].len == labellen && strncasecmp(label, parsed->labelv[i].label, labellen) == 0) {
const char *value = parsed->labelv[i].text;

View File

@ -519,7 +519,7 @@ int app_echo(const struct cli_parsed *parsed, struct cli_context *context)
if (config.debug.verbose)
DEBUG_cli_parsed(parsed);
int escapes = !cli_arg(parsed, "-e", NULL, NULL, NULL);
int i;
unsigned i;
for (i = parsed->varargi; i < parsed->argc; ++i) {
const char *arg = parsed->args[i];
if (config.debug.verbose)
@ -1257,8 +1257,8 @@ int app_config_set(const struct cli_parsed *parsed, struct cli_context *UNUSED(c
// </kludge>
const char *var[parsed->argc - 1];
const char *val[parsed->argc - 1];
int nvar = 0;
int i;
unsigned nvar = 0;
unsigned i;
for (i = 1; i < parsed->argc; ++i) {
const char *arg = parsed->args[i];
int iv;
@ -2087,7 +2087,7 @@ int app_keyring_list(const struct cli_parsed *parsed, struct cli_context *contex
static void cli_output_identity(struct cli_context *context, const keyring_identity *id)
{
int i;
unsigned i;
for (i=0;i<id->keypair_count;i++){
keypair *kp=id->keypairs[i];
switch(kp->type){
@ -2433,7 +2433,7 @@ int app_id_self(const struct cli_parsed *parsed, struct cli_context *context)
overlay_mdp_client_close(mdp_sockfd);
return WHY("MDP Server returned something other than an address list");
}
int i;
unsigned i;
for(i=0;i<a.addrlist.frame_sid_count;i++) {
count++;
cli_printf(context, "%s", alloca_tohex_sid_t(a.addrlist.sids[i]));

View File

@ -119,7 +119,7 @@ static int cf_om_make_child(struct cf_om_node **const parentp, const char *const
if (!*parentp && (*parentp = emalloc_zero(sizeof **parentp)) == NULL)
return -1;
size_t keylen = keyend - key;
int i = 0;
unsigned i = 0;
struct cf_om_node *child;
if ((*parentp)->nodc) {
// Binary search for matching child.
@ -132,9 +132,9 @@ static int cf_om_make_child(struct cf_om_node **const parentp, const char *const
c = strncmp(key, child->key, keylen);
if (c == 0 && child->key[keylen])
c = -1;
//DEBUGF(" m=%d n=%d i=%d child->key=%s c=%d", m, n, i, alloca_str_toprint(child->key), c);
//DEBUGF(" m=%u n=%u i=%u child->key=%s c=%d", m, n, i, alloca_str_toprint(child->key), c);
if (c == 0) {
//DEBUGF(" found i=%d", i);
//DEBUGF(" found i=%u", i);
return i;
}
if (c > 0)
@ -144,7 +144,6 @@ static int cf_om_make_child(struct cf_om_node **const parentp, const char *const
} while (m <= n);
}
// At this point, i is the index where a new child should be inserted.
assert(i >= 0);
assert(i <= (*parentp)->nodc);
if ((child = emalloc_zero(sizeof *child)) == NULL)
return -1;
@ -156,11 +155,11 @@ static int cf_om_make_child(struct cf_om_node **const parentp, const char *const
++(*parentp)->nodc;
if ((*parentp)->nodc > NELS((*parentp)->nodv))
*parentp = realloc(*parentp, sizeof(**parentp) + sizeof((*parentp)->nodv[0]) * ((*parentp)->nodc - NELS((*parentp)->nodv)));
int j;
unsigned j;
for (j = (*parentp)->nodc - 1; j > i; --j)
(*parentp)->nodv[j] = (*parentp)->nodv[j-1];
(*parentp)->nodv[i] = child;
//DEBUGF(" insert i=%d", i);
//DEBUGF(" insert i=%u", i);
return i;
}
@ -184,7 +183,7 @@ int cf_om_get_child(const struct cf_om_node *parent, const char *key, const char
if (keyend == NULL)
keyend = key + strlen(key);
// TODO: use binary search, since child nodes are already sorted by key
int i;
unsigned i;
for (i = 0; i < parent->nodc; ++i)
if (memcmp(parent->nodv[i]->key, key, keyend - key) == 0 && parent->nodv[i]->key[keyend - key] == '\0')
return i;
@ -318,7 +317,7 @@ void cf_om_dump_node(const struct cf_om_node *node, int indent)
alloca_str_toprint(node->key),
alloca_str_toprint(node->text)
);
int i;
unsigned i;
for (i = 0; i < node->nodc; ++i)
cf_om_dump_node(node->nodv[i], indent + 1);
}
@ -445,7 +444,7 @@ int cf_om_iter_next(struct cf_om_iterator *it)
return 0;
while (1) {
const struct cf_om_node *parent = it->stack[it->sp].node;
int i = it->stack[it->sp].index++;
unsigned i = it->stack[it->sp].index++;
if (i < parent->nodc) {
it->node = parent->nodv[i];
if (it->node == NULL)
@ -487,7 +486,7 @@ void _cf_warn_nodev(struct __sourceloc __whence, const struct cf_om_node *node,
void _cf_warn_childrenv(struct __sourceloc __whence, const struct cf_om_node *parent, const char *fmt, va_list ap)
{
int i;
unsigned i;
for (i = 0; i < parent->nodc; ++i) {
_cf_warn_nodev(__whence, parent->nodv[i], NULL, fmt, ap);
_cf_warn_childrenv(__whence, parent->nodv[i], fmt, ap);
@ -549,7 +548,7 @@ void _cf_warn_unsupported_node(struct __sourceloc __whence, const struct cf_om_n
void _cf_warn_unsupported_children(struct __sourceloc __whence, const struct cf_om_node *parent)
{
int i;
unsigned i;
for (i = 0; i < parent->nodc; ++i) {
if (parent->nodv[i]->text)
_cf_warn_unsupported_node(__whence, parent->nodv[i]);
@ -572,7 +571,7 @@ strbuf strbuf_cf_flags(strbuf sb, int flags)
{ CFINVALID, "CFINVALID" },
{ CFUNSUPPORTED, "CFUNSUPPORTED" },
};
int i;
unsigned i;
for (i = 0; i < NELS(flagdefs); ++i) {
if (flags & flagdefs[i].flag) {
if (strbuf_len(sb) != n)
@ -624,7 +623,7 @@ strbuf strbuf_cf_flag_reason(strbuf sb, int flags)
{ CFSUB(CFINVALID), "contains invalid element" },
{ CFSUB(CFUNSUPPORTED), "contains unsupported element" },
};
int i;
unsigned i;
for (i = 0; i < NELS(flagdefs); ++i) {
if (flags & flagdefs[i].flag) {
if (strbuf_len(sb) != n)

View File

@ -213,7 +213,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
__ITEM(__element, (0 __flags)|__TEXT|__CHILDREN, cf_opt_##__repr(&strct->__element, child))
#define END_STRUCT \
{ \
int i; \
unsigned i; \
for (i = 0; i < node->nodc; ++i) { \
if (node->nodv[i]->text && !(used[i] & __TEXT)) { \
cf_warn_unsupported_node(node->nodv[i]); \
@ -247,7 +247,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
int (*keycmp)(const void *, const void *) = NULL; \
int (*validator)(const struct cf_om_node *, struct config_##__name *, int) = (NULL, ##__validator); \
int result = CFOK; \
int i, n; \
unsigned i, n; \
for (n = 0, i = 0; i < node->nodc && n < NELS(array->av); ++i) { \
const struct cf_om_node *child = node->nodv[i]; \
int ret = CFEMPTY;
@ -260,7 +260,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
ret &= CF__FLAGS; \
result |= CFSUB(ret); \
if (ret == CFOK && (flags & __NO_DUPLICATES)) { \
int j; \
unsigned j; \
for (j = 0; j < n; ++j) { \
if (__cmpfunc __cmpfuncargs == 0) { \
cf_warn_duplicate_node(child, NULL); \
@ -365,7 +365,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
int config_##__name##__get(const struct config_##__name *array,
#define KEY_ATOM(__type, __keyrepr) \
const __type *key) { \
int i; \
unsigned i; \
for (i = 0; i < array->ac; ++i) \
if ((cf_cmp_##__keyrepr(key, &array->av[i].key)) == 0) \
return i; \
@ -373,7 +373,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
}
#define KEY_STRING(__strsize, __keyrepr) \
const char *key) { \
int i; \
unsigned i; \
for (i = 0; i < array->ac; ++i) \
if ((cf_cmp_##__keyrepr(&key[0], &array->av[i].key[0])) == 0) \
return i; \
@ -418,7 +418,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define __ADD_CHILD(nodep, __elementstr) \
if ((i = cf_om_add_child(nodep, __elementstr)) == -1) \
return -1; \
childp = &(*nodep)->nodv[i];
childp = &(*nodep)->nodv[(unsigned)i];
#define __ATOM(nodep, __text) \
if (((*nodep)->text = str_edup(__text)) == NULL) \
return -1;
@ -562,11 +562,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
else { \
const char *funcname = NULL;
#define __FMT_NODE_END \
cf_om_remove_null_child(parentp, n); \
cf_om_remove_null_child(parentp, (unsigned) n); \
if (ret != CFOK) \
WARNF("%s() returned %s", funcname, strbuf_str(strbuf_cf_flags(strbuf_alloca(300), ret))); \
if (n < (*parentp)->nodc && cf_om_remove_empty_child(parentp, n)) { \
WHYF("%s() returned empty node at n=%d", funcname, n); \
if ((unsigned)n < (*parentp)->nodc && cf_om_remove_empty_child(parentp, (unsigned) n)) { \
WHYF("%s() returned empty node at n=%u", funcname, (unsigned) n); \
ret = CFERROR; \
} \
} \
@ -577,7 +577,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define NODE(__type, __element, __default, __repr, __flags, __comment) \
{ \
__FMT_NODE_START(__element) \
ret = cf_fmt_##__repr(&(*parentp)->nodv[n], &strct->__element); \
ret = cf_fmt_##__repr(&(*parentp)->nodv[(unsigned)n], &strct->__element); \
funcname = "cf_fmt_" #__repr; \
__FMT_NODE_END \
}
@ -587,10 +587,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
if (#__dfllabel[0]) { \
struct config_##__structname dfl; \
cf_dfl_config_##__structname##_cf_##__dfllabel(&dfl); \
ret = cf_xfmt_config_##__structname(&(*parentp)->nodv[n], &strct->__element, &dfl); \
ret = cf_xfmt_config_##__structname(&(*parentp)->nodv[(unsigned)n], &strct->__element, &dfl); \
funcname = "cf_xfmt_config_" #__structname; \
} else { \
ret = cf_fmt_config_##__structname(&(*parentp)->nodv[n], &strct->__element); \
ret = cf_fmt_config_##__structname(&(*parentp)->nodv[(unsigned)n], &strct->__element); \
funcname = "cf_fmt_config_" #__structname; \
} \
__FMT_NODE_END \
@ -598,7 +598,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define NODE_STRUCT(__structname, __element, __repr, __flags, __dfllabel...) \
{ \
__FMT_NODE_START(__element) \
ret = cf_fmt_##__repr(&(*parentp)->nodv[n], &strct->__element); \
ret = cf_fmt_##__repr(&(*parentp)->nodv[(unsigned)n], &strct->__element); \
funcname = "cf_fmt_" #__repr; \
__FMT_NODE_END \
}
@ -625,7 +625,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
} \
int cf_fmt_config_##__name(struct cf_om_node **parentp, const struct config_##__name *array) { \
int result = CFOK; \
int i; \
unsigned i; \
for (i = 0; i < array->ac; ++i) {
#define __ARRAY_KEY(__keyfunc, __keyexpr) \
const char *key = NULL; \
@ -647,15 +647,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
} \
if (ret == CFOK) {
#define __ARRAY_VALUE(__valuefunc) \
cf_om_remove_null_child(parentp, n); \
cf_om_remove_null_child(parentp, (unsigned)n); \
if (ret != CFOK) \
WARNF(#__valuefunc "() returned %s", strbuf_str(strbuf_cf_flags(strbuf_alloca(300), ret))); \
if (n < (*parentp)->nodc && cf_om_remove_empty_child(parentp, n)) { \
WHYF(#__valuefunc "() returned empty node at n=%d", n); \
if ((unsigned)n < (*parentp)->nodc && cf_om_remove_empty_child(parentp, (unsigned)n)) { \
WHYF(#__valuefunc "() returned empty node at n=%u", (unsigned)n); \
ret = CFERROR; \
}
#define __ARRAY_TEXT(__valuefunc, __eltexpr) \
ret = __valuefunc(&(*parentp)->nodv[n]->text, __eltexpr); \
ret = __valuefunc(&(*parentp)->nodv[(unsigned)n]->text, __eltexpr); \
__ARRAY_VALUE(__valuefunc)
#define END_ARRAY(__size) \
} \
@ -677,19 +677,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define VALUE_STRING(__strsize, __eltrepr) \
__ARRAY_TEXT(cf_fmt_##__eltrepr, &array->av[i].value[0])
#define VALUE_NODE(__type, __eltrepr) \
ret = cf_fmt_##__eltrepr(&(*parentp)->nodv[n], &array->av[i].value); \
ret = cf_fmt_##__eltrepr(&(*parentp)->nodv[(unsigned)n], &array->av[i].value); \
__ARRAY_VALUE(cf_fmt_##__eltrepr)
#define VALUE_SUB_STRUCT(__structname, __dfllabel...) \
if (#__dfllabel[0]) { \
struct config_##__structname dfl; \
cf_dfl_config_##__structname##_cf_##__dfllabel(&dfl); \
ret = cf_xfmt_config_##__structname(&(*parentp)->nodv[n], &array->av[i].value, &dfl); \
ret = cf_xfmt_config_##__structname(&(*parentp)->nodv[(unsigned)n], &array->av[i].value, &dfl); \
} else { \
ret = cf_fmt_config_##__structname(&(*parentp)->nodv[n], &array->av[i].value); \
ret = cf_fmt_config_##__structname(&(*parentp)->nodv[(unsigned)n], &array->av[i].value); \
} \
__ARRAY_VALUE(cf_fmt_config_##__structname)
#define VALUE_NODE_STRUCT(__structname, __eltrepr) \
ret = cf_fmt_##__eltrepr(&(*parentp)->nodv[n], &array->av[i].value); \
ret = cf_fmt_##__eltrepr(&(*parentp)->nodv[(unsigned)n], &array->av[i].value); \
__ARRAY_VALUE(cf_fmt_##__eltrepr)
#include "conf_schema.h"
#undef STRUCT
@ -758,7 +758,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define ARRAY(__name, __flags, __validator...) \
int cf_cmp_config_##__name(const struct config_##__name *a, const struct config_##__name *b) { \
int c; \
int i; \
unsigned i; \
for (i = 0; i < a->ac && i < b->ac; ++i) {
#define KEY_ATOM(__type, __keyrepr) \
if ((c = cf_cmp_##__keyrepr(&a->av[i].key, &b->av[i].key))) \

View File

@ -504,7 +504,7 @@ int cf_cmp_ushort_nonzero(const unsigned short *a, const unsigned short *b)
int vld_argv(const struct cf_om_node *parent, struct config_argv *array, int result)
{
unsigned short last_key = 0;
int i;
unsigned i;
if (array->ac) {
unsigned short last_key = array->av[0].key;
for (i = 1; i < array->ac; ++i) {

View File

@ -213,7 +213,7 @@ dna_helper_start()
// Construct argv[] for execv() and log messages.
const char *argv[config.dna.helper.argv.ac + 2];
argv[0] = config.dna.helper.executable;
int i;
unsigned i;
for (i = 0; i < config.dna.helper.argv.ac; ++i)
argv[i + 1] = config.dna.helper.argv.av[i].value;
argv[i + 1] = NULL;

View File

@ -1170,7 +1170,7 @@ static int keyring_decrypt_pkr(keyring_file *k, unsigned cn, const char *pin, in
goto kdp_safeexit;
}
// Add any unlocked subscribers to our memory table, flagged as local SIDs.
int i=0;
unsigned i;
for (i=0;i<id->keypair_count;i++){
if (id->keypairs[i]->type == KEYTYPE_CRYPTOBOX) {
add_subscriber(id, i);
@ -1446,7 +1446,7 @@ int keyring_set_did(keyring_identity *id, const char *did, const char *name)
if (!name) name="Mr. Smith";
/* Find where to put it */
int i;
unsigned i;
for(i=0;i<id->keypair_count;i++)
if (id->keypairs[i]->type==KEYTYPE_DID) {
if (config.debug.keyring)
@ -1529,8 +1529,8 @@ int keyring_pack_tag(unsigned char *packed, size_t *packed_len, const char *name
int keyring_set_public_tag(keyring_identity *id, const char *name, const unsigned char *value, size_t length)
{
int i;
for(i=0;i<id->keypair_count;i++){
unsigned i;
for (i=0;i<id->keypair_count;i++){
const char *tag_name;
const unsigned char *tag_value;
size_t tag_length;
@ -1600,7 +1600,7 @@ int keyring_find_public_tag_value(const keyring_file *k, int *cn, int *in, int *
int keyring_identity_find_keytype(const keyring_file *k, int cn, int in, int keytype)
{
int kp;
unsigned kp;
for (kp = 0; kp < k->contexts[cn]->identities[in]->keypair_count; ++kp)
if (k->contexts[cn]->identities[in]->keypairs[kp]->type == keytype)
return kp;
@ -1951,7 +1951,7 @@ int keyring_find_sid(const keyring_file *k, int *cn, int *in, int *kp, const sid
void keyring_identity_extract(const keyring_identity *id, const sid_t **sidp, const char **didp, const char **namep)
{
int todo = (sidp ? 1 : 0) | (didp ? 2 : 0) | (namep ? 4 : 0);
int kpn;
unsigned kpn;
for (kpn = 0; todo && kpn < id->keypair_count; ++kpn) {
keypair *kp = id->keypairs[kpn];
switch (kp->type) {
@ -2075,7 +2075,7 @@ struct nm_record {
unsigned char nm_bytes[crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES];
};
int nm_slots_used=0;
unsigned nm_slots_used=0;
/* 512 x 96 bytes = 48KB, not too big */
#define NM_CACHE_SLOTS 512
struct nm_record nm_cache[NM_CACHE_SLOTS];
@ -2087,9 +2087,8 @@ unsigned char *keyring_get_nm_bytes(const sid_t *known_sidp, const sid_t *unknow
if (!unknown_sidp) { RETURNNULL(WHYNULL("unknown pub key is null")); }
if (!keyring) { RETURNNULL(WHYNULL("keyring is null")); }
int i;
/* See if we have it cached already */
unsigned i;
for(i=0;i<nm_slots_used;i++)
{
if (cmp_sid_t(&nm_cache[i].known_key, known_sidp) != 0) continue;

View File

@ -405,7 +405,7 @@ static int monitor_set(const struct cli_parsed *parsed, struct cli_context *cont
c->flags|=MONITOR_VOMP;
// store the list of supported codecs against the monitor connection,
// since we need to forget about them when the client disappears.
int i;
unsigned i;
for (i = 2; i < parsed->argc; ++i) {
int codec = atoi(parsed->args[i]);
if (codec>=0 && codec <=255)
@ -547,7 +547,7 @@ static int monitor_call_dtmf(const struct cli_parsed *parsed, struct cli_context
return monitor_write_error(c,"Invalid call token");
const char *digits = parsed->args[2];
int i;
unsigned i;
for(i=0;i<strlen(digits);i++) {
int digit=vomp_parse_dtmf_digit(digits[i]);
if (digit<0)

View File

@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif
int overlay_ready=0;
int overlay_interface_count=0;
unsigned overlay_interface_count=0;
overlay_interface overlay_interfaces[OVERLAY_MAX_INTERFACES];
int overlay_last_interface_number=-1;
@ -934,11 +934,11 @@ overlay_interface_register(char *name,
// Find the matching non-dummy interface rule.
const struct config_network_interface *ifconfig = NULL;
int i;
unsigned i;
for (i = 0; i < config.interfaces.ac; ++i, ifconfig = NULL) {
ifconfig = &config.interfaces.av[i].value;
if (ifconfig->socket_type==SOCK_DGRAM) {
int j;
unsigned j;
for (j = 0; j < ifconfig->match.patc; ++j){
if (fnmatch(ifconfig->match.patv[j], name, 0) == 0)
break;
@ -1011,7 +1011,7 @@ overlay_interface_register(char *name,
void overlay_interface_discover(struct sched_ent *alarm)
{
/* Mark all UP interfaces as DETECTING, so we can tell which interfaces are new, and which are dead */
int i;
unsigned i;
for (i = 0; i < overlay_interface_count; i++)
if (overlay_interfaces[i].state==INTERFACE_STATE_UP)
overlay_interfaces[i].state=INTERFACE_STATE_DETECTING;
@ -1027,7 +1027,7 @@ void overlay_interface_discover(struct sched_ent *alarm)
detect_real_interfaces = 1;
continue;
}
int j;
unsigned j;
for (j = 0; j < overlay_interface_count; j++){
if (overlay_interfaces[j].socket_type == ifconfig->socket_type &&
strcasecmp(overlay_interfaces[j].name, ifconfig->file) == 0 &&

View File

@ -527,7 +527,7 @@ int app_rhizome_direct_sync(const struct cli_parsed *parsed, struct cli_context
return -1;
} else {
const struct config_rhizome_peer *peers[config.rhizome.direct.peer.ac];
int i;
unsigned i;
for (i = 0; i < config.rhizome.direct.peer.ac; ++i)
peers[i] = &config.rhizome.direct.peer.av[i].value;
return rhizome_sync_with_peers(mode, config.rhizome.direct.peer.ac, peers);

View File

@ -151,10 +151,11 @@ static const char * fetch_state(int state)
}
}
static uint64_t rhizome_active_fetch_bytes_received(int q)
static uint64_t rhizome_active_fetch_bytes_received(unsigned q)
{
if (q<0 || q>=NQUEUES) return -1;
if (rhizome_fetch_queues[q].active.state==RHIZOME_FETCH_FREE) return -1;
assert(q < NQUEUES);
if (rhizome_fetch_queues[q].active.state == RHIZOME_FETCH_FREE)
return 0;
return rhizome_fetch_queues[q].active.write_state.file_offset;
}
@ -180,13 +181,13 @@ static uint64_t rhizome_fetch_queue_bytes()
void rhizome_fetch_log_short_status()
{
int i,active=0;
unsigned active = 0;
unsigned i;
for(i=0;i<NQUEUES;i++)
if (rhizome_fetch_queues[i].active.state!=RHIZOME_FETCH_FREE)
active++;
if (!active)
return;
INFOF("Rhizome transfer progress: %"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64" (remaining %"PRIu64")",
rhizome_active_fetch_bytes_received(0),
rhizome_active_fetch_bytes_received(1),
@ -244,7 +245,7 @@ static struct profile_total fetch_stats = { .name="rhizome_fetch_poll" };
*/
static struct rhizome_fetch_queue *rhizome_find_queue(unsigned char log_size)
{
int i;
unsigned i;
for (i = 0; i < NQUEUES; ++i) {
struct rhizome_fetch_queue *q = &rhizome_fetch_queues[i];
if (log_size < q->log_size_threshold)
@ -261,8 +262,8 @@ static struct rhizome_fetch_queue *rhizome_find_queue(unsigned char log_size)
*/
static struct rhizome_fetch_slot *rhizome_find_fetch_slot(uint64_t size)
{
int i;
unsigned char log_size = log2ll(size);
unsigned i;
for (i = 0; i < NQUEUES; ++i) {
struct rhizome_fetch_queue *q = &rhizome_fetch_queues[i];
if (log_size < q->log_size_threshold && q->active.state == RHIZOME_FETCH_FREE)
@ -275,7 +276,7 @@ static struct rhizome_fetch_slot *rhizome_find_fetch_slot(uint64_t size)
// find the first matching active slot for this bundle
static struct rhizome_fetch_slot *fetch_search_slot(const unsigned char *id, int prefix_length)
{
int i;
unsigned i;
for (i = 0; i < NQUEUES; ++i) {
struct rhizome_fetch_queue *q = &rhizome_fetch_queues[i];
@ -383,7 +384,7 @@ static void candidate_unqueue(struct rhizome_fetch_candidate *c)
*/
int rhizome_any_fetch_active()
{
int i;
unsigned i;
for (i = 0; i < NQUEUES; ++i)
if (rhizome_fetch_queues[i].active.state != RHIZOME_FETCH_FREE)
return 1;
@ -396,7 +397,7 @@ int rhizome_any_fetch_active()
*/
int rhizome_any_fetch_queued()
{
int i;
unsigned i;
for (i = 0; i < NQUEUES; ++i)
if (rhizome_fetch_queues[i].candidate_queue[0].manifest)
return 1;
@ -708,7 +709,7 @@ rhizome_fetch(struct rhizome_fetch_slot *slot, rhizome_manifest *m, const struct
}
}
}
int i;
unsigned i;
for (i = 0; i < NQUEUES; ++i) {
struct rhizome_fetch_slot *as = &rhizome_fetch_queues[i].active;
const rhizome_manifest *am = as->manifest;
@ -828,7 +829,7 @@ static void rhizome_start_next_queued_fetches(struct sched_ent *alarm)
{
IN();
assert(alarm == &sched_activate);
int i;
unsigned i;
for (i = 0; i < NQUEUES; ++i)
rhizome_start_next_queued_fetch(&rhizome_fetch_queues[i].active);
OUT();
@ -839,7 +840,7 @@ int rhizome_fetch_has_queue_space(unsigned char log2_size){
struct rhizome_fetch_queue *q = rhizome_find_queue(log2_size);
if (q){
// is there an empty candidate?
unsigned j=0;
unsigned j;
for (j=0;j < q->candidate_queue_size;j++)
if (!q->candidate_queue[j].manifest)
return 1;

View File

@ -460,7 +460,7 @@ void rhizome_sync_status_html(struct strbuf *b, struct subscriber *subscriber);
int rhizome_cache_count();
int overlay_add_local_identity(unsigned char *s);
extern int overlay_interface_count;
extern unsigned overlay_interface_count;
extern int overlay_local_identity_count;
extern unsigned char *overlay_local_identities[OVERLAY_MAX_LOCAL_IDENTITIES];

View File

@ -111,7 +111,7 @@ static int serval_packetvisualise_renderaddress(XPRINTF xpf, const unsigned char
xprintf(xpf,"<illegal address token 0x%02x>",len);
return -1;
}
int i;
unsigned i;
for (i=0;i<len;i++)
xprintf(xpf,"%02X",packet[(*ofs)++]);
if (len<32) xprintf(xpf,"*");
@ -360,9 +360,10 @@ int serval_packetvisualise_xpf(XPRINTF xpf, const char *message, const unsigned
static void _dump(XPRINTF xpf, const unsigned char *data, size_t len, size_t ofs, const char *prefix)
{
int i, j;
unsigned i;
for (i = ofs & 0xFFFFFFF0; i < len; i += 16) {
xprintf(xpf, "%s%04x:", prefix, i);
unsigned j;
for (j = 0; j < 16; ++j)
if (i + j >= ofs && i + j < len)
xprintf(xpf," %02x", data[i+j]);

View File

@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define EXEC_NARGS 20
char *exec_args[EXEC_NARGS + 1];
int exec_argc = 0;
unsigned exec_argc = 0;
int servalShutdown = 0;
@ -74,7 +74,7 @@ int server_pid()
void server_save_argv(int argc, const char *const *argv)
{
/* Save our argv[] to use for relaunching */
for (exec_argc = 0; exec_argc < argc && exec_argc < EXEC_NARGS; ++exec_argc)
for (exec_argc = 0; exec_argc < (unsigned)argc && exec_argc < EXEC_NARGS; ++exec_argc)
exec_args[exec_argc] = strdup(argv[exec_argc]);
exec_args[exec_argc] = NULL;
}
@ -392,7 +392,7 @@ void crash_handler(int signal)
BACKTRACE;
if (config.server.respawn_on_crash) {
int i;
unsigned i;
for(i=0;i<overlay_interface_count;i++)
if (overlay_interfaces[i].alarm.poll.fd>-1)
close(overlay_interfaces[i].alarm.poll.fd);

15
vomp.c
View File

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <assert.h>
#include "serval.h"
#include "str.h"
#include "conf.h"
@ -184,7 +185,7 @@ struct vomp_call_state {
This is partly to deal with denial of service attacks that might occur by causing
the ejection of newly allocated session numbers before the caller has had a chance
to progress the call to a further state. */
int vomp_call_count=0;
unsigned vomp_call_count=0;
// TODO allocate call structures dynamically
struct vomp_call_state vomp_call_states[VOMP_MAX_CALLS];
struct profile_total vomp_stats;
@ -331,7 +332,7 @@ int is_codec_set(int codec, unsigned char *flags){
struct vomp_call_state *vomp_find_call_by_session(int session_token)
{
int i;
unsigned i;
for(i=0;i<vomp_call_count;i++)
if (session_token==vomp_call_states[i].local.session)
return &vomp_call_states[i];
@ -347,7 +348,7 @@ static int vomp_generate_session_id()
return WHY("Insufficient entropy");
session_id&=VOMP_SESSION_MASK;
if (config.debug.vomp) DEBUGF("session=0x%08x",session_id);
int i;
unsigned i;
/* reject duplicate call session numbers */
for(i=0;i<vomp_call_count;i++)
if (session_id==vomp_call_states[i].local.session
@ -399,11 +400,10 @@ static struct vomp_call_state *vomp_find_or_create_call(struct subscriber *remot
int sender_state,
int recvr_state)
{
int i;
struct vomp_call_state *call;
if (config.debug.vomp)
DEBUGF("%d calls already in progress.",vomp_call_count);
DEBUGF("%u calls already in progress.",vomp_call_count);
unsigned i;
for(i=0;i<vomp_call_count;i++)
{
call = &vomp_call_states[i];
@ -774,11 +774,12 @@ static int vomp_call_destroy(struct vomp_call_state *call)
DEBUGF("Destroying call %06x:%06x [%s,%s]", call->local.session, call->remote.session, call->local.did,call->remote.did);
/* now release the call structure */
int i = (call - vomp_call_states);
unsigned i = (call - vomp_call_states);
unschedule(&call->alarm);
call->local.session=0;
call->remote.session=0;
assert(vomp_call_count > 0);
vomp_call_count--;
if (i!=vomp_call_count){
unschedule(&vomp_call_states[vomp_call_count].alarm);

View File

@ -267,8 +267,8 @@ static int console_audio(const struct cli_parsed *parsed, struct cli_context *UN
}else{
static char buf[256];
static struct strbuf str_buf = STRUCT_STRBUF_EMPTY;
int i;
strbuf_init(&str_buf, buf, sizeof(buf));
unsigned i;
for (i = 0; i < parsed->argc; ++i) {
if (i)
strbuf_putc(&str_buf, ' ');