Skip to content

Commit

Permalink
Fix compile errors on Ubuntu (#1698)
Browse files Browse the repository at this point in the history
* Fix compile errors on Ubuntu

* Remove cxx flag -std=libc++ which causes compile error with clang11

* Fix TWStoredKey.removeAccountForCoin

The first arg of TWStoredKeyCreate() should be TWString instead
of a char*

* Change coverage.stats to 94.6

Co-authored-by: Peng Huang <penghuang@chromium.org>
  • Loading branch information
phuang and phuang committed Oct 13, 2021
1 parent bbf9dfc commit 33ed1ac
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(GNUInstallDirs)
set(TW_CXX_WARNINGS "-Wshorten-64-to-32")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ ${TW_CXX_WARNINGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TW_CXX_WARNINGS}")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
Expand Down
2 changes: 1 addition & 1 deletion coverage.stats
Original file line number Diff line number Diff line change
@@ -1 +1 @@
94.7
94.6
4 changes: 2 additions & 2 deletions src/Base58.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Data Base58::decode(const char* begin, const char* end) const {
auto it = begin;

// Skip leading spaces.
it = std::find_if_not(it, end, std::isspace);
it = std::find_if_not(it, end, [](char c) { return std::isspace(c);});

// Skip and count leading zeros.
std::size_t zeroes = 0;
Expand Down Expand Up @@ -119,7 +119,7 @@ Data Base58::decode(const char* begin, const char* end) const {
}

// Skip trailing spaces.
it = std::find_if_not(it, end, std::isspace);
it = std::find_if_not(it, end, [](char c) { return std::isspace(c);});
if (it != end) {
// Extra charaters at the end
return {};
Expand Down
1 change: 1 addition & 0 deletions src/BinaryCoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "BinaryCoding.h"

#include <cassert>
#include <tuple>

namespace TW {

Expand Down
3 changes: 2 additions & 1 deletion src/BinaryCoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

#include <cstddef>
#include <cstdint>
#include <vector>
#include <string>
#include <tuple>
#include <vector>

namespace TW {

Expand Down
1 change: 1 addition & 0 deletions src/Cbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "Data.h"

#include <stdexcept>
#include <string>
#include <memory>

Expand Down
2 changes: 2 additions & 0 deletions src/Encrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Data.h"
#include <TrezorCrypto/aes.h>
#include <cassert>
#include <cstring>
#include <stdexcept>

namespace TW::Encrypt {

Expand Down
2 changes: 2 additions & 0 deletions src/Filecoin/Address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "Address.h"

#include <cstring>

#include "../Base32.h"
#include "../Data.h"

Expand Down
1 change: 1 addition & 0 deletions src/HDWallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <TrezorCrypto/curves.h>

#include <array>
#include <cstring>

using namespace TW;

Expand Down
1 change: 1 addition & 0 deletions src/Mnemonic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <TrezorCrypto/bip39_english.h>
#include <TrezorCrypto/bip39.h>

#include <algorithm>
#include <string>
#include <vector>
#include <cassert>
Expand Down
1 change: 1 addition & 0 deletions src/NEO/ReadData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "../Data.h"
#include "ReadData.h"
#include <stdexcept>


TW::Data TW::readBytes(const TW::Data& from, int max, int initial_pos) {
Expand Down
3 changes: 2 additions & 1 deletion src/NEO/ReadData.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include <cctype>
#include <limits>

#include "../Data.h"
#include "../BinaryCoding.h"
Expand All @@ -16,7 +17,7 @@ namespace TW {
Data readBytes(const Data& from, int max, int initial_pos = 0);
Data readVarBytes(const Data& from, int initial_pos = 0, uint32_t* dataRead = nullptr);

template<class T> T readVar(const TW::Data& from, int initial_pos = 0, const T& max = INT_MAX);
template<class T> T readVar(const TW::Data& from, int initial_pos = 0, const T& max = std::numeric_limits<int>::max());
template<> int64_t readVar(const TW::Data& from, int initial_pos, const int64_t& max);
template<> uint64_t readVar(const TW::Data& from, int initial_pos, const uint64_t& max);

Expand Down
1 change: 1 addition & 0 deletions src/Waves/Address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <HexCoding.h>
#include <cassert>
#include <cstring>
#include <stdexcept>

using namespace TW;
Expand Down
3 changes: 2 additions & 1 deletion tests/interface/TWStoredKeyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ TEST(TWStoredKey, removeAccountForCoin) {
const auto passwordString = WRAPS(TWStringCreateWithUTF8Bytes("password"));
const auto password = WRAPD(TWDataCreateWithBytes(reinterpret_cast<const uint8_t *>(TWStringUTF8Bytes(passwordString.get())), TWStringSize(passwordString.get())));

auto key = WRAP(TWStoredKey, TWStoredKeyCreate("Test KeyStore", password.get()));
const auto name = WRAPS(TWStringCreateWithUTF8Bytes("Test KeyStore"));
auto key = WRAP(TWStoredKey, TWStoredKeyCreate(name.get(), password.get()));
auto wallet = WRAP(TWHDWallet, TWStoredKeyWallet(key.get(), password.get()));

ASSERT_NE(WRAP(TWAccount, TWStoredKeyAccountForCoin(key.get(), TWCoinTypeEthereum, wallet.get())).get(), nullptr);
Expand Down
3 changes: 2 additions & 1 deletion walletconsole/lib/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

#pragma once

#include <string>
#include <iostream>
#include <string>
#include <vector>

namespace TW::WalletConsole {

Expand Down

0 comments on commit 33ed1ac

Please sign in to comment.