From 5abba74d84f1729497d604c695dee7b59e4a5df5 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Thu, 16 Feb 2017 09:59:48 +0100 Subject: [PATCH] yet another bitwise pickyness + hey that's a foreach --- examples/msg/dht-kademlia/node.c | 4 ++-- src/xbt/log.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/msg/dht-kademlia/node.c b/examples/msg/dht-kademlia/node.c index e854b52732..c0741d681c 100644 --- a/examples/msg/dht-kademlia/node.c +++ b/examples/msg/dht-kademlia/node.c @@ -116,13 +116,13 @@ unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix) if (prefix == 0) { return 0; } else { - return (1 << ((unsigned int)(prefix - 1))) ^ id; + return (1U << ((unsigned int)(prefix - 1))) ^ id; } } /** @brief Returns the prefix of an identifier. * The prefix is the id of the bucket in which the remote identifier xor our identifier should be stored. - * @param id : bigunsigned int id to test + * @param id : big unsigned int id to test * @param nb_bits : key size */ unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits) diff --git a/src/xbt/log.c b/src/xbt/log.c index 2d694dbcd0..4b359d9cd5 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -294,9 +294,9 @@ void xbt_log_init(int *argc, char **argv) xbt_log_control_set(opt); XBT_DEBUG("Did apply '%s' as log setting", opt); } else if (!strcmp(argv[i], "--help-logs")) { - help_requested |= 1; + help_requested |= 1U; } else if (!strcmp(argv[i], "--help-log-categories")) { - help_requested |= 2; + help_requested |= 2U; } else { argv[j++] = argv[i]; } @@ -481,7 +481,8 @@ int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority xbt_log_parent_set(category, category->parent); if (XBT_LOG_ISENABLED(log, xbt_log_priority_debug)) { - char *buf, *res = NULL; + char *buf; + char *res = NULL; xbt_log_category_t cpp = category->parent->firstChild; while (cpp) { if (res) { @@ -893,10 +894,9 @@ static void xbt_log_help_categories_rec(xbt_log_category_t category, const char xbt_dynar_sort(dynar, xbt_log_cat_cmp); - for (i = 0; i < xbt_dynar_length(dynar); i++) { + xbt_dynar_foreach(dynar, i, cat){ if (i == xbt_dynar_length(dynar) - 1 && category->parent) *strrchr(child_prefix, '|') = ' '; - cat = xbt_dynar_get_as(dynar, i, xbt_log_category_t); printf("%s%s: %s\n", this_prefix, cat->name, cat->description); xbt_log_help_categories_rec(cat->firstChild, child_prefix); } -- 2.20.1