szaszm commented on code in PR #1348:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1348#discussion_r897965273


##########
libminifi/src/utils/Id.cpp:
##########
@@ -193,8 +190,8 @@ IdGenerator::~IdGenerator() = default;
 
 uint64_t IdGenerator::getDeviceSegmentFromString(const std::string& str, int 
numBits) const {
   uint64_t deviceSegment = 0;
-  for (size_t i = 0; i < str.length(); i++) {
-    unsigned char c = toupper(str[i]);
+  for (auto ch : str) {
+    auto c = gsl::narrow<unsigned char>(std::toupper(gsl::narrow<unsigned 
char>(ch)));

Review Comment:
   @fgerlits suggested `gsl::narrow` originally. It shouldn't matter, since 
this function is working with a restricted set of characters. I suggested 
`gsl::narrow_cast` or `static_cast`, but since it hex digits only, @fgerlits 
commented that terminating is OK in that case. I don't think we should enforce 
that here, but I don't care that much.



-- 
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]

Reply via email to