diff options
author | Bram Bonné <brambonne@google.com> | 2020-10-20 16:40:52 +0200 |
---|---|---|
committer | Bram Bonné <brambonne@google.com> | 2020-10-21 11:59:10 +0200 |
commit | f04333a4b1f00ad29bc6828854ed17c34e78901b (patch) | |
tree | 78b1e8469b084dc55846ba8f23260bb04b5c0428 /src/cppbor_parse.cpp | |
parent | f3ebf71e14186be9b881bc1d111ebab3b0b93f06 (diff) | |
download | libcppbor-f04333a4b1f00ad29bc6828854ed17c34e78901b.tar.gz |
Add Trusty support to libcppbor.
Add a rules.mk file to libcppbor to allow Trusty to depend on it.
Additionally, remove dependency on the Android logging framework when
running in the Trusty environment, and remove dependencies on
stringstream to improve portability.
Bug: 171373138
Test: trusty/vendor/google/aosp/scripts/build.py
generic-arm64-test-debug
Test: m -j
Change-Id: I7a01db28e6bf448886f4a7a1a4dea02d569493c9
Diffstat (limited to 'src/cppbor_parse.cpp')
-rw-r--r-- | src/cppbor_parse.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/cppbor_parse.cpp b/src/cppbor_parse.cpp index 6da0036..5cffe15 100644 --- a/src/cppbor_parse.cpp +++ b/src/cppbor_parse.cpp @@ -16,11 +16,14 @@ #include "cppbor_parse.h" -#include <sstream> #include <stack> -#define LOG_TAG "CppBor" -#include <android-base/logging.h> +#ifndef __TRUSTY__ + #include <android-base/logging.h> + #define LOG_TAG "CppBor" +#else + #define CHECK(x) (void)(x) +#endif namespace cppbor { @@ -28,10 +31,10 @@ namespace { std::string insufficientLengthString(size_t bytesNeeded, size_t bytesAvail, const std::string& type) { - std::stringstream errStream; - errStream << "Need " << bytesNeeded << " byte(s) for " << type << ", have " << bytesAvail - << "."; - return errStream.str(); + char buf[1024]; + snprintf(buf, sizeof(buf), "Need %zu byte(s) for %s, have %zu", + bytesNeeded, type.c_str(), bytesAvail); + return std::string(buf); } template <typename T, typename = std::enable_if_t<std::is_unsigned_v<T>>> |