Skip to content

Commit 1e3db54

Browse files
committed
Misc warning fixes
1 parent 8c61f6e commit 1e3db54

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/base58.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ int wally_base58_to_bytes(const char *str_in, uint32_t flags,
258258
unsigned char *bytes_out, size_t len,
259259
size_t *written)
260260
{
261+
size_t offset;
262+
uint32_t checksum;
261263
int ret;
262264

263265
if (written)
@@ -281,8 +283,8 @@ int wally_base58_to_bytes(const char *str_in, uint32_t flags,
281283
return WALLY_EINVAL; /* Input not long enough to contain a checksum */
282284
}
283285

284-
size_t offset = *written - BASE58_CHECKSUM_LEN;
285-
uint32_t checksum = base58_get_checksum(bytes_out, offset);
286+
offset = *written - BASE58_CHECKSUM_LEN;
287+
checksum = base58_get_checksum(bytes_out, offset);
286288

287289
if (memcmp(bytes_out + offset, &checksum, sizeof(checksum))) {
288290
wally_clear(bytes_out, len);

src/ctest/test_bech32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
static const char *invalid = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg";
99

10-
static bool check_segwit_to_bytes()
10+
static bool check_segwit_to_bytes(void)
1111
{
1212
unsigned char *mem = calloc(90, sizeof(unsigned char));
1313
size_t written;

src/transaction.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,9 @@ static int tx_add_elements_raw_input(
12481248
};
12491249
bool is_coinbase;
12501250
int ret;
1251+
#ifndef BUILD_ELEMENTS
1252+
(void)pegin_witness;
1253+
#endif
12511254

12521255
if (flags)
12531256
return WALLY_EINVAL; /* TODO: Allow creation of p2pkh/p2sh using flags */
@@ -1763,7 +1766,7 @@ static inline int tx_to_bip143_bytes(const struct wally_tx *tx,
17631766
{
17641767
unsigned char buff[TX_STACK_SIZE / 2], *buff_p = buff;
17651768
size_t i, inputs_size, outputs_size, issuances_size = 0, buff_len = sizeof(buff);
1766-
uint64_t is_elements = 0;
1769+
size_t is_elements = 0;
17671770
const bool anyonecanpay = opts->sighash & WALLY_SIGHASH_ANYONECANPAY;
17681771
const bool sh_none = (opts->sighash & SIGHASH_MASK) == WALLY_SIGHASH_NONE;
17691772
const bool sh_single = (opts->sighash & SIGHASH_MASK) == WALLY_SIGHASH_SINGLE;
@@ -2500,7 +2503,7 @@ static int tx_from_bytes(const unsigned char *bytes, size_t bytes_len,
25002503
p += sizeof(uint32_t);
25012504
for (i = 0; i < num_inputs; ++i) {
25022505
const unsigned char *issuance_amount_rangeproof, *inflation_keys_rangeproof;
2503-
size_t issuance_amount_rangeproof_len, inflation_keys_rangeproof_len, offset;
2506+
uint64_t issuance_amount_rangeproof_len, inflation_keys_rangeproof_len, offset;
25042507
proof_from_bytes(issuance_amount_rangeproof, &issuance_amount_rangeproof_len);
25052508
proof_from_bytes(inflation_keys_rangeproof, &inflation_keys_rangeproof_len);
25062509
ret = tx_elements_input_issuance_proof_init(result->inputs + i,
@@ -2522,7 +2525,7 @@ static int tx_from_bytes(const unsigned char *bytes, size_t bytes_len,
25222525

25232526
for (i = 0; i < num_outputs; ++i) {
25242527
const unsigned char *surjectionproof, *rangeproof;
2525-
size_t surjectionproof_len, rangeproof_len;
2528+
uint64_t surjectionproof_len, rangeproof_len;
25262529
proof_from_bytes(surjectionproof, &surjectionproof_len);
25272530
proof_from_bytes(rangeproof, &rangeproof_len);
25282531
ret = tx_elements_output_proof_init(result->outputs + i,
@@ -2625,7 +2628,7 @@ static int tx_get_signature_hash(const struct wally_tx *tx,
26252628
{
26262629
unsigned char buff[TX_STACK_SIZE], *buff_p = buff;
26272630
size_t n, n2;
2628-
uint64_t is_elements = 0;
2631+
size_t is_elements = 0;
26292632
int ret;
26302633
const struct tx_serialize_opts opts = {
26312634
sighash, tx_sighash, index, script, script_len, satoshi,

0 commit comments

Comments
 (0)