mirror of
https://github.com/monero-project/monero.git
synced 2025-12-15 09:28:52 -05:00
device: misc cleanup
use snprintf "just in case" where appropriate consistently use unsigned for temp values pass std::string by const ref rather than by value add length check (which can't happen in practice) for memcpy
This commit is contained in:
parent
3b4dec2d12
commit
41e9cab4e1
3 changed files with 14 additions and 12 deletions
|
|
@ -45,13 +45,13 @@ namespace hw {
|
|||
}
|
||||
}
|
||||
|
||||
void log_hexbuffer(std::string msg, const char* buff, size_t len) {
|
||||
void log_hexbuffer(const std::string &msg, const char* buff, size_t len) {
|
||||
char logstr[1025];
|
||||
buffer_to_str(logstr, sizeof(logstr), buff, len);
|
||||
MDEBUG(msg<< ": " << logstr);
|
||||
}
|
||||
|
||||
void log_message(std::string msg, std::string info ) {
|
||||
void log_message(const std::string &msg, const std::string &info ) {
|
||||
MDEBUG(msg << ": " << info);
|
||||
}
|
||||
|
||||
|
|
@ -122,16 +122,18 @@ namespace hw {
|
|||
|
||||
rct::keyV decrypt(const rct::keyV &keys) {
|
||||
rct::keyV x ;
|
||||
x.reserve(keys.size());
|
||||
for (unsigned int j = 0; j<keys.size(); j++) {
|
||||
x.push_back(decrypt(keys[j]));
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
static void check(std::string msg, std::string info, const char *h, const char *d, int len, bool crypted) {
|
||||
static void check(const std::string &msg, const std::string &info, const char *h, const char *d, size_t len, bool crypted) {
|
||||
char dd[32];
|
||||
char logstr[128];
|
||||
|
||||
CHECK_AND_ASSERT_THROW_MES(len <= sizeof(dd), "invalid len");
|
||||
memmove(dd,d,len);
|
||||
if (crypted) {
|
||||
CHECK_AND_ASSERT_THROW_MES(len<=32, "encrypted data greater than 32");
|
||||
|
|
@ -149,11 +151,11 @@ namespace hw {
|
|||
}
|
||||
}
|
||||
|
||||
void check32(std::string msg, std::string info, const char *h, const char *d, bool crypted) {
|
||||
void check32(const std::string &msg, const std::string &info, const char *h, const char *d, bool crypted) {
|
||||
check(msg, info, h, d, 32, crypted);
|
||||
}
|
||||
|
||||
void check8(std::string msg, std::string info, const char *h, const char *d, bool crypted) {
|
||||
void check8(const std::string &msg, const std::string &info, const char *h, const char *d, bool crypted) {
|
||||
check(msg, info, h, d, 8, crypted);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue