Remove general shadowed variables.

We shadow local variables in several places: generally, these changes
make the code clearer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-07-25 16:30:09 +09:30
committed by neil saitug
parent 6a7d40f51a
commit 6fe570820e
25 changed files with 92 additions and 99 deletions

View File

@@ -54,7 +54,6 @@ int main(int argc, char *argv[])
const char *method;
struct bolt11 *b11;
struct bolt11_field *extra;
size_t i;
char *fail, *description = NULL;
common_setup(argv[0]);
@@ -120,7 +119,7 @@ int main(int argc, char *argv[])
}
printf("\n");
}
for (i = 0; i < tal_count(b11->fallbacks); i++) {
for (size_t i = 0; i < tal_count(b11->fallbacks); i++) {
struct bitcoin_address pkh;
struct ripemd160 sh;
struct sha256 wsh;
@@ -148,7 +147,7 @@ int main(int argc, char *argv[])
}
}
for (i = 0; i < tal_count(b11->routes); i++) {
for (size_t i = 0; i < tal_count(b11->routes); i++) {
printf("route: (node/chanid/fee/expirydelta) ");
for (size_t n = 0; n < tal_count(b11->routes[i]); n++) {
printf(" %s/%s/%u/%u/%u",
@@ -169,6 +168,7 @@ int main(int argc, char *argv[])
list_for_each(&b11->extra_fields, extra, list) {
char *data = tal_arr(ctx, char, tal_count(extra->data)+1);
size_t i;
for (i = 0; i < tal_count(extra->data); i++)
data[i] = bech32_charset[extra->data[i]];

View File

@@ -105,8 +105,8 @@ int main(int argc, char *argv[])
}
m = tal_dup_arr(f, u8, f + off, be16_to_cpu(len), 0);
if (printtlv) {
size_t len = tal_bytelen(m);
ok &= printtlv("", &m, &len);
size_t mlen = tal_bytelen(m);
ok &= printtlv("", &m, &mlen);
} else {
ok &= printwire(m);
}

View File

@@ -170,7 +170,6 @@ static struct io_plan *handshake_success(struct io_conn *conn,
struct oneshot *timer,
char **args)
{
u8 *msg;
int peer_fd = io_conn_fd(conn);
struct pollfd pollfd[2];
@@ -179,6 +178,7 @@ static struct io_plan *handshake_success(struct io_conn *conn,
OPTIONAL_FEATURE(OPT_INITIAL_ROUTING_SYNC));
if (!no_init) {
u8 *msg;
struct tlv_init_tlvs *tlvs = NULL;
if (explicit_network) {
tlvs = tlv_init_tlvs_new(NULL);

View File

@@ -103,10 +103,9 @@ int main(int argc, char *argv[])
for (n = gossmap_first_node(map);
n;
n = gossmap_next_node(map, n)) {
struct node_id srcid, dstid;
struct node_id srcid;
gossmap_node_get_id(map, n, &srcid);
gossmap_node_get_id(map, dst, &dstid);
printf("# %s->%s\n",
type_to_string(tmpctx, struct node_id, &srcid),
type_to_string(tmpctx, struct node_id, &dstid));