1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-keygen synced 2026-07-04 12:03:41 +02:00

Merge branch 'compiler-warnings' into develop

This commit is contained in:
Henrik Hautakoski 2020-01-29 10:50:37 +01:00
parent 2b20f8aaf4
commit 2d1696a0e4
7 changed files with 24 additions and 16 deletions

View file

@ -39,6 +39,10 @@ set( CMAKE_CXX_STANDARD 11 )
set( CMAKE_CXX_STANDARD_REQUIRED ON ) set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF ) set( CMAKE_CXX_EXTENSIONS OFF )
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wconversion -Wno-sign-conversion -Wextra" )
endif()
# Libraries # Libraries
find_package(OpenSSL 1.1 REQUIRED) find_package(OpenSSL 1.1 REQUIRED)

View file

@ -24,6 +24,7 @@
* *
* Based on code from https://github.com/bitcoin/bitcoin/blob/f1e2f2a85962c1664e4e55471061af0eaa798d40/src/base58.cpp * Based on code from https://github.com/bitcoin/bitcoin/blob/f1e2f2a85962c1664e4e55471061af0eaa798d40/src/base58.cpp
*/ */
#include <cstddef>
#include <cassert> #include <cassert>
#include "base58.h" #include "base58.h"
@ -39,7 +40,7 @@ std::string base58_encode(const unsigned char* pbegin, const unsigned char* pend
zeroes++; zeroes++;
} }
// Allocate enough space in big-endian base58 representation. // Allocate enough space in big-endian base58 representation.
int size = (pend - pbegin) * 138 / 100 + 1; // log(256) / log(58), rounded up. std::size_t size = (pend - pbegin) * 138 / 100 + 1; // log(256) / log(58), rounded up.
std::vector<unsigned char> b58(size); std::vector<unsigned char> b58(size);
// Process the bytes. // Process the bytes.
while (pbegin != pend) { while (pbegin != pend) {
@ -48,7 +49,7 @@ std::string base58_encode(const unsigned char* pbegin, const unsigned char* pend
// Apply "b58 = b58 * 256 + ch". // Apply "b58 = b58 * 256 + ch".
for (std::vector<unsigned char>::reverse_iterator it = b58.rbegin(); (carry != 0 || i < length) && (it != b58.rend()); it++, i++) { for (std::vector<unsigned char>::reverse_iterator it = b58.rbegin(); (carry != 0 || i < length) && (it != b58.rend()); it++, i++) {
carry += 256 * (*it); carry += 256 * (*it);
*it = carry % 58; *it = static_cast<unsigned char>(carry % 58);
carry /= 58; carry /= 58;
} }

View file

@ -26,13 +26,13 @@
#include <cstring> #include <cstring>
#include "checksum.h" #include "checksum.h"
inline void sha256d(const unsigned char *data, unsigned int len, unsigned char *out) { inline void sha256d(const unsigned char *data, std::size_t len, unsigned char *out) {
SHA256(data, len, out); SHA256(data, len, out);
SHA256(out, 32, out); SHA256(out, 32, out);
} }
#define checksum_impl(name, func) \ #define checksum_impl(name, func) \
checksum_t checksum_##name(const unsigned char *data, unsigned int len) { \ checksum_t checksum_##name(const unsigned char *data, std::size_t len) { \
\ \
checksum_t crc; \ checksum_t crc; \
unsigned char hash[32]; \ unsigned char hash[32]; \

View file

@ -24,12 +24,13 @@
#ifndef CHECKSUM_H #ifndef CHECKSUM_H
#define CHECKSUM_H #define CHECKSUM_H
#include <cstddef>
#include <array> #include <array>
typedef std::array<unsigned char, 4> checksum_t; typedef std::array<unsigned char, 4> checksum_t;
checksum_t checksum_sha256d(const unsigned char *data, unsigned int len); checksum_t checksum_sha256d(const unsigned char *data, std::size_t len);
checksum_t checksum_ripemd160(const unsigned char *data, unsigned int len); checksum_t checksum_ripemd160(const unsigned char *data, std::size_t len);
#endif /* CHECKSUM_H */ #endif /* CHECKSUM_H */

View file

@ -1,4 +1,5 @@
#include <cstddef>
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <vector> #include <vector>
@ -7,10 +8,10 @@
#include "key_search.h" #include "key_search.h"
// Max keys to search for, // Max keys to search for,
unsigned int g_max; std::size_t g_max;
// How many keys we have found so far. // How many keys we have found so far.
unsigned int g_count; std::size_t g_count;
// Mutex guard for g_count. // Mutex guard for g_count.
std::mutex g_count_mtx; std::mutex g_count_mtx;
@ -60,7 +61,7 @@ void KeySearch::_search_mt(size_t n)
g_count = 0; g_count = 0;
// Launch them. // Launch them.
for(int i = 0; i < t.size(); i++) { for(std::size_t i = 0; i < t.size(); i++) {
t[i] = std::thread(_thr_proc, m_words); t[i] = std::thread(_thr_proc, m_words);
} }
@ -68,7 +69,7 @@ void KeySearch::_search_mt(size_t n)
_thr_proc(m_words); _thr_proc(m_words);
// Wait for all threads to compelete. // Wait for all threads to compelete.
for(int i = 0; i < t.size(); i++) { for(std::size_t i = 0; i < t.size(); i++) {
t[i].join(); t[i].join();
} }
} }

View file

@ -46,7 +46,7 @@ void cmd_search(int argc, char **argv) {
if (option_l33t) { if (option_l33t) {
strlist_t tmp = strsplitwords(input); strlist_t tmp = strsplitwords(input);
for(int i = 0; i < tmp.size(); i++) { for(std::size_t i = 0; i < tmp.size(); i++) {
ks.addList(l33twords(tmp[i])); ks.addList(l33twords(tmp[i]));
} }
} else { } else {

View file

@ -21,8 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include <algorithm> #include <cstddef>
#include <cctype> #include <cctype>
#include <algorithm>
#include "string.h" #include "string.h"
strlist_t strsplitwords(const std::string& str, const std::string& delim) { strlist_t strsplitwords(const std::string& str, const std::string& delim) {
@ -108,20 +109,20 @@ static bool is_l33t(char ch, char& r) {
// '1', '2', '3', '4', '5', '6', '7', '8', '9' // '1', '2', '3', '4', '5', '6', '7', '8', '9'
static char alphabet[9] = { 'l', 'z', 'e', 'a', 's', 'G', 't', 'B', 'g' }; static char alphabet[9] = { 'l', 'z', 'e', 'a', 's', 'G', 't', 'B', 'g' };
for(int i = 0; i < sizeof(alphabet) / sizeof(char); i++) { for(std::size_t i = 0; i < sizeof(alphabet) / sizeof(char); i++) {
if (ch == alphabet[i]) { if (ch == alphabet[i]) {
r = '1' + i; r = static_cast<char>('1' + i);
return true; return true;
} }
} }
return false; return false;
} }
static void _l33t(strlist_t& list, const std::string& a, int pos) { static void _l33t(strlist_t& list, const std::string& a, std::size_t pos) {
// Find the next character to be replaced. // Find the next character to be replaced.
for(int i = pos; i < a.length(); i++) { for(std::size_t i = pos; i < a.length(); i++) {
char ch; char ch;
if (is_l33t(a[i], ch)) { if (is_l33t(a[i], ch)) {