Skip to content

Commit 8798d78

Browse files
authored
Merge pull request #41 from gorazdko/resolve_warnings
fix compiler warnings
2 parents e9ef016 + e038a51 commit 8798d78

File tree

7 files changed

+105
-31
lines changed

7 files changed

+105
-31
lines changed

seedtool/seed.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class SLIP39ShareSeq {
7171
static bool verify_share_checksum(uint16_t const * share);
7272

7373
static SLIP39ShareSeq * from_seed(Seed const * seed,
74-
size_t thresh,
75-
size_t nshares,
74+
uint8_t thresh,
75+
uint8_t nshares,
7676
void(*randgen)(uint8_t *, size_t));
7777

7878
// Read-only, don't free returned value.

seedtool/seed.ino

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Seed::Seed(uint8_t const * i_data, size_t len) {
3535

3636
void Seed::log() const {
3737
serial_printf("seed: ");
38-
for (int ii = 0; ii < sizeof(data); ++ii)
39-
serial_printf("%02x", (int) data[ii]);
38+
for (size_t ii = 0; ii < sizeof(data); ++ii)
39+
serial_printf("%02x", data[ii]);
4040
serial_printf("\n");
4141
}
4242

@@ -65,10 +65,10 @@ bool SLIP39ShareSeq::verify_share_checksum(uint16_t const * share) {
6565
}
6666

6767
SLIP39ShareSeq * SLIP39ShareSeq::from_seed(Seed const * seed,
68-
size_t thresh,
69-
size_t nshares,
68+
uint8_t thresh,
69+
uint8_t nshares,
7070
void(*randgen)(uint8_t *, size_t)) {
71-
char * password = "";
71+
const char * password = "";
7272
uint8_t group_threshold = 1;
7373
uint8_t group_count = 1;
7474
group_descriptor group = { thresh, nshares, NULL };
@@ -91,7 +91,7 @@ SLIP39ShareSeq * SLIP39ShareSeq::from_seed(Seed const * seed,
9191
shares_buffer,
9292
shares_buffer_size,
9393
randgen);
94-
serial_assert(rv == nshares);
94+
serial_assert(rv == (int)nshares);
9595
serial_assert(words_in_each_share == WORDS_PER_SHARE);
9696

9797
SLIP39ShareSeq * slip39 = new SLIP39ShareSeq();
@@ -101,7 +101,7 @@ SLIP39ShareSeq * SLIP39ShareSeq::from_seed(Seed const * seed,
101101
}
102102

103103
char const * SLIP39ShareSeq::error_msg(int errval) {
104-
char buffer[1024];
104+
static char buffer[1024];
105105
switch (errval) {
106106
// max message size 18 chars |----------------|
107107
case ERROR_INVALID_SHARD_SET: return "Invalid shard set";
@@ -169,7 +169,7 @@ char const * SLIP39ShareSeq::get_share_word(size_t sndx, size_t wndx) const {
169169

170170
Seed * SLIP39ShareSeq::restore_seed() const {
171171
uint8_t seed_data[Seed::SIZE];
172-
char * password = "";
172+
const char * password = "";
173173
last_rv = slip39_combine(const_cast<const uint16_t **>(shares),
174174
WORDS_PER_SHARE,
175175
nshares,

seedtool/selftest.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ uint16_t ref_bip39_words_bad_checksum[BIP39Seq::WORD_COUNT] =
3030
0x0494, 0x0039, 0x050d, 0x04f1
3131
};
3232

33-
char* ref_bip39_mnemonics[BIP39Seq::WORD_COUNT] =
33+
const char* ref_bip39_mnemonics[BIP39Seq::WORD_COUNT] =
3434
{
3535
"mirror", "reject", "rookie", "talk",
3636
"pudding", "throw", "happy", "era",
@@ -39,7 +39,7 @@ char* ref_bip39_mnemonics[BIP39Seq::WORD_COUNT] =
3939

4040
size_t const ref_slip39_thresh = 2;
4141
size_t const ref_slip39_nshares = 3;
42-
char* ref_slip39_shares[ref_slip39_nshares] =
42+
const char* ref_slip39_shares[ref_slip39_nshares] =
4343
{
4444
"check academic academic acid counter "
4545
"both course legs visitor squeeze "
@@ -77,7 +77,7 @@ uint16_t ref_slip39_words[ref_slip39_nshares][SLIP39ShareSeq::WORDS_PER_SHARE] =
7777

7878
// These shares are *also* generated from seed="123456", but they use
7979
// a different random seed so they are not compatible with the others.
80-
char* ref_slip39_shares_alt[ref_slip39_nshares] =
80+
const char* ref_slip39_shares_alt[ref_slip39_nshares] =
8181
{
8282
"deny category academic acid buyer "
8383
"miracle game discuss hobo decision "
@@ -125,13 +125,13 @@ uint16_t ref_slip39_share_bad_checksum[SLIP39ShareSeq::WORDS_PER_SHARE] =
125125
// Clearly not random. Only use for tests.
126126
void fake_random(uint8_t *buf, size_t count) {
127127
uint8_t b = 0;
128-
for(int i = 0; i < count; i++) {
128+
for(size_t i = 0; i < count; i++) {
129129
buf[i] = b;
130130
b = b + 17;
131131
}
132132
}
133133

134-
bool test_failed(char *format, ...) {
134+
bool test_failed(const char *format, ...) {
135135
char buff[8192];
136136
va_list args;
137137
va_start(args, format);
@@ -470,5 +470,5 @@ String selftest_testname(size_t ndx) {
470470
bool selftest_testrun(size_t ndx) {
471471
using namespace selftest_internal;
472472
serial_assert(ndx < g_numtests);
473-
g_selftests[ndx].testfun();
473+
return g_selftests[ndx].testfun();
474474
}

seedtool/userinterface.ino

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void full_window_clear() {
5959
while (g_display.nextPage());
6060
}
6161

62-
void display_printf(char *format, ...) {
62+
void display_printf(const char *format, ...) {
6363
char buff[1024];
6464
va_list args;
6565
va_start(args, format);
@@ -129,7 +129,7 @@ void self_test() {
129129
size_t numtests = selftest_numtests();
130130
// Loop, once for each test. Need an extra trip at the end in
131131
// case we failed the last test.
132-
for (int ndx = 0; ndx < numtests+1; ++ndx) {
132+
for (size_t ndx = 0; ndx < numtests+1; ++ndx) {
133133

134134
// If any key is pressed, skip remaining self test.
135135
if (g_keypad.getKey() != NO_KEY)
@@ -718,7 +718,7 @@ void display_slip39() {
718718
yy = Y_MAX - (H_FSB9) + 2;
719719
g_display.setFont(&FreeSansBold9pt7b);
720720
g_display.setCursor(xx, yy);
721-
if (sharendx < (g_slip39_generate->numshares()-1))
721+
if (sharendx < (int)(g_slip39_generate->numshares()-1))
722722
g_display.println("1,7-Up,Down #-Next");
723723
else
724724
g_display.println("1,7-Up,Down #-Done");
@@ -746,7 +746,7 @@ void display_slip39() {
746746
}
747747
break;
748748
case '#': // next / done
749-
if (sharendx < (g_slip39_generate->numshares()-1)) {
749+
if (sharendx < (int)(g_slip39_generate->numshares()-1)) {
750750
++sharendx;
751751
scroll = 0;
752752
} else {
@@ -829,7 +829,7 @@ struct WordListState {
829829
}
830830

831831
void cursor_right() {
832-
if (pos < strlen(refword(wordndx[selected])) - 1)
832+
if (pos < (int)strlen(refword(wordndx[selected])) - 1)
833833
++pos;
834834
}
835835

@@ -1035,7 +1035,7 @@ void restore_bip39() {
10351035
case '#': // done
10361036
{
10371037
uint16_t bip39_words[BIP39Seq::WORD_COUNT];
1038-
for (int ii = 0; ii < BIP39Seq::WORD_COUNT; ++ii)
1038+
for (size_t ii = 0; ii < BIP39Seq::WORD_COUNT; ++ii)
10391039
bip39_words[ii] = state.wordndx[ii];
10401040
BIP39Seq * bip39 = BIP39Seq::from_words(bip39_words);
10411041
Seed * seed = bip39->restore_seed();
@@ -1090,7 +1090,7 @@ void restore_slip39() {
10901090
// Adjust the scroll to center the selection.
10911091
if (selected < 2)
10921092
scroll = 0;
1093-
else if (selected > g_slip39_restore->numshares())
1093+
else if (selected > (int)g_slip39_restore->numshares())
10941094
scroll = g_slip39_restore->numshares() + 2 - disprows;
10951095
else
10961096
scroll = selected - 2;
@@ -1117,9 +1117,9 @@ void restore_slip39() {
11171117
for (int rr = 0; rr < disprows; ++rr) {
11181118
int sharendx = scroll + rr;
11191119
char buffer[32];
1120-
if (sharendx < g_slip39_restore->numshares()) {
1120+
if (sharendx < (int)g_slip39_restore->numshares()) {
11211121
sprintf(buffer, "Share %d", sharendx+1);
1122-
} else if (sharendx == g_slip39_restore->numshares()) {
1122+
} else if (sharendx == (int)g_slip39_restore->numshares()) {
11231123
sprintf(buffer, "Add Share");
11241124
} else {
11251125
sprintf(buffer, "Restore");
@@ -1162,19 +1162,19 @@ void restore_slip39() {
11621162
selected -= 1;
11631163
break;
11641164
case '7':
1165-
if (selected < g_slip39_restore->numshares() + 1 + showrestore - 1)
1165+
if (selected < (int)g_slip39_restore->numshares() + 1 + showrestore - 1)
11661166
selected += 1;
11671167
break;
11681168
case '*':
11691169
g_uistate = SEEDLESS_MENU;
11701170
return;
11711171
case '#':
1172-
if (selected < g_slip39_restore->numshares()) {
1172+
if (selected < (int)g_slip39_restore->numshares()) {
11731173
// Edit existing share
11741174
g_restore_slip39_selected = selected;
11751175
g_uistate = ENTER_SHARE;
11761176
return;
1177-
} else if (selected == g_slip39_restore->numshares()) {
1177+
} else if (selected == (int)g_slip39_restore->numshares()) {
11781178
// Add new (zeroed) share
11791179
uint16_t share[SLIP39ShareSeq::WORDS_PER_SHARE] =
11801180
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1190,7 +1190,7 @@ void restore_slip39() {
11901190
// happening ..
11911191
full_window_clear();
11921192

1193-
for (int ii = 0; ii < g_slip39_restore->numshares(); ++ii) {
1193+
for (size_t ii = 0; ii < g_slip39_restore->numshares(); ++ii) {
11941194
char * strings =
11951195
g_slip39_restore->get_share_strings(ii);
11961196
serial_printf("%d %s\n", ii+1, strings);

seedtool/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#ifndef _UTIL_H
44
#define _UTIL_H
55

6-
void serial_printf(char *format, ...);
6+
void serial_printf(const char *format, ...);
77

88
#define serial_assert(_exp) \
99
do { \

seedtool/util.ino

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

33
#include "util.h"
44

5-
void serial_printf(char *format, ...) {
5+
void serial_printf(const char *format, ...) {
66
char buff[1024];
77
va_list args;
88
va_start(args, format);
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
-----BEGIN PGP SIGNED MESSAGE-----
2+
Hash: SHA512
3+
4+
# Contributor License Agreement
5+
6+
Version 1.0
7+
8+
Name: Gorazd Kovacic
9+
10+
11+
12+
Legal Jurisdiction: Wyoming, United States of America
13+
14+
Project: https://github.com/BlockchainCommons/bc-lethekit
15+
16+
Date: 06-11-2020
17+
18+
## Purpose
19+
20+
This agreement gives Blockchain Commons, LLC the permission it needs in order to accept my contributions into its open software project and to manage the intellectual property in that project over time.
21+
22+
## License
23+
24+
I hereby license Blockchain Commons, LLC to:
25+
26+
1. do anything with my contributions that would otherwise infringe my copyright in them
27+
28+
2. do anything with my contributions that would otherwise infringe patents that I can or become able to license
29+
30+
3. sublicense these rights to others on any terms they like
31+
32+
## Reliability
33+
34+
I understand that Blockchain Commons will rely on this license. I may not revoke this license.
35+
36+
## Awareness
37+
38+
I promise that I am familiar with legal rules, like ["work made for hire" rules](http://worksmadeforhire.com), that can give employers and clients ownership of intellectual property in work that I do. I am also aware that legal agreements I might sign, like confidential information and invention assignment agreements, will usually give ownership of intellectual property in my work to employers, clients, and companies that I found. If someone else owns intellectual property in my work, I need their permission to license it.
39+
40+
## Copyright Guarantee
41+
42+
I promise not to offer contributions to the project that contain copyrighted work that I do not have legally binding permission to contribute under these terms. When I offer a contribution with permission, I promise to document in the contribution who owns copyright in what work, and how they gave permission to contribute it. If I later become aware that one of my contributions may have copyrighted work of others that I did not have permission to contribute, I will notify Blockchain Commons, in confidence, immediately.
43+
44+
## Patent Guarantee
45+
46+
I promise not to offer contributions to the project that I know infringe patents of others that I do not have permission to contribute under these terms.
47+
48+
## Open Source Guarantee
49+
50+
I promise not to offer contributions that contain or depend on the work of others, unless that work is available under a license that [Blue Oak Council rates bronze or better](https://blueoakconcil.org/list), such as the MIT License, two- or three-clause BSD License, the Apache License Version 2.0, or the Blue Oak Model License 1.0.0. When I offer a contribution containing or depending on others' work, I promise to document in the contribution who licenses that work, along with copies of their license terms.
51+
52+
## Disclaimers
53+
54+
***As far as the law allows, my contributions come as is, without any warranty or condition. Other than under [Copyright Guarantee](#copyright-guarantee), [Patent Guarantee](#patent-guarantee), or [Open Source Guarantee](#open-source-guarantee), I will not be liable to anyone for any damages related to my contributions or this contributor license agreement, under any kind of legal claim.***
55+
56+
- ---
57+
58+
To sign this Contributor License Agreement, fill in `$name`, `$email`, and `$date` above. Then sign using GPG using the following command `gpg --armor --clearsign --output ./signed-cla/CLA.YOURGITHUBNAME.YOURGPGFINGERPRINT.asc CLA.md`, then either submit your signed Contributor License Agreement to this repo as a GPG signed Pull Request or email it to [[email protected]](mailto:[email protected]).
59+
-----BEGIN PGP SIGNATURE-----
60+
61+
iQIzBAEBCgAdFiEEQfDqFpmnTB4vpBtTjPlrw/+du84FAl7iodMACgkQjPlrw/+d
62+
u85mpA/+MJS6QwdawdJrB81iqCXj1DoANFDKuxb8BYfIW37AjODFDygs8+50LH+5
63+
q8rRVmHZCfE6yBNzSItB37FcKGK9tDSLtAXTCFwEK/0+AuLUhvlrdBRtZBdP+gjd
64+
uk5SW0iW2F5hxXQp962VzMGoxUf8U0dqI/9r0IFHWL2yaCdEI6mkS8yiZJxjU8le
65+
BfRvTvYRMXo4ggtffI7cT4iJ7auzatcXeGb7R00ye6UDUw1GNGg+I3a1JHH+I6GQ
66+
EaNasbBSsFAn6cprQetGOFVXe85dqznyeayjGIOYZuOcMT2y5FUk+czm/5F62fEh
67+
fs/29b2bHN6jX9MiF1mgwEjvGNi3a+Xgl4iXsrUa7TvuK3ZOtWaWp8i5VOwUlfZL
68+
d5HZZbCYNInU3Q5bSjl3TeJdiZ+I19NpzFOotLb4VMp945DPno0e1sfkbzMXT9EJ
69+
Sv3mf7d22/FbEOvfnkMicdGtCje/n/HBYhcb4FkUOkGvtWlU+Ny0jZ25usprpS4E
70+
iJ7YAreuOCDMciPPnd/swqmNe2QOUgVm0EeVFaa4bUtENFaOjbHD7P42q7sdAZgJ
71+
s3IaRVn61e0tSL0lX53mxZJxL93tVx1jBgqG9hWQ8Gl2mHEMN1s7aTZ4pUb7FOi0
72+
E6UGDewJH147NmvOQ6vKpa/o58+/JgXhIG2wyuEKH0tFfUMP22Y=
73+
=8uJl
74+
-----END PGP SIGNATURE-----

0 commit comments

Comments
 (0)