szaszm commented on a change in pull request #1249:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1249#discussion_r800669223
##########
File path: libminifi/src/utils/StringUtils.cpp
##########
@@ -268,8 +321,8 @@ bool StringUtils::from_hex(uint8_t* data, size_t*
data_length, const char* hex,
return true;
}
-std::vector<uint8_t> StringUtils::from_hex(const char* hex, size_t hex_length)
{
- std::vector<uint8_t> decoded(hex_length / 2);
+std::vector<std::byte> StringUtils::from_hex(const char* hex, size_t
hex_length) {
+ std::vector<std::byte> decoded(hex_length / 2);
size_t data_length = decoded.size();
if (!from_hex(decoded.data(), &data_length, hex, hex_length)) {
throw std::invalid_argument("Hexencoded string is malformatted");
Review comment:
Chaging both to "malformed". I've never heard/read the word
"malformatted" before. After searching the internet for it, it looks like it
exists, but is very rarely used, so I'm not convinced that it's not just a
common mistake.
[30de0dc](https://github.com/apache/nifi-minifi-cpp/pull/1249/commits/30de0dc2abaed028ebf8ebb08be2bd9fd86edb52)
##########
File path: libminifi/src/io/FileStream.cpp
##########
@@ -141,17 +141,15 @@ size_t FileStream::write(const uint8_t *value, size_t
size) {
return size;
}
-size_t FileStream::read(uint8_t *buf, size_t buflen) {
- if (buflen == 0) {
- return 0;
- }
+size_t FileStream::read(gsl::span<std::byte> buf) {
+ if (buf.empty()) { return 0; }
if (!IsNullOrEmpty(buf)) {
Review comment:
done in
[30de0dc](https://github.com/apache/nifi-minifi-cpp/pull/1249/commits/30de0dc2abaed028ebf8ebb08be2bd9fd86edb52)
##########
File path: libminifi/src/c2/C2Payload.cpp
##########
@@ -64,20 +64,20 @@ void C2Payload::addContent(C2ContentResponse &&content,
bool collapsible) {
}
void C2Payload::setRawData(const std::string &data) {
+ const auto byte_view = gsl::make_span(data).as_span<const std::byte>();
raw_data_.reserve(raw_data_.size() + data.size());
- raw_data_.insert(std::end(raw_data_), std::begin(data), std::end(data));
+ raw_data_.insert(std::end(raw_data_), std::begin(byte_view),
std::end(byte_view));
}
void C2Payload::setRawData(const std::vector<char> &data) {
+ const auto byte_view = gsl::make_span(data).as_span<const std::byte>();
raw_data_.reserve(raw_data_.size() + data.size());
- raw_data_.insert(std::end(raw_data_), std::begin(data), std::end(data));
+ raw_data_.insert(std::end(raw_data_), std::begin(byte_view),
std::end(byte_view));
}
Review comment:
done in
[30de0dc](https://github.com/apache/nifi-minifi-cpp/pull/1249/commits/30de0dc2abaed028ebf8ebb08be2bd9fd86edb52)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]