evindj commented on code in PR #846:
URL: https://github.com/apache/iceberg-cpp/pull/846#discussion_r3651116335
##########
src/iceberg/table_metadata.cc:
##########
@@ -517,11 +517,18 @@ int32_t
TableMetadataUtil::ParseVersionFromLocation(std::string_view metadata_lo
size_t version_start = metadata_location.find_last_of('/') + 1;
size_t version_end = metadata_location.find('-', version_start);
+ if (version_end == std::string::npos) {
+ return -1;
+ }
+
int32_t version = -1;
- if (version_end != std::string::npos) {
- std::from_chars(metadata_location.data() + version_start,
- metadata_location.data() + version_end, version);
+ const auto* version_begin = metadata_location.data() + version_start;
+ const auto* version_limit = metadata_location.data() + version_end;
+ const auto [ptr, ec] = std::from_chars(version_begin, version_limit,
version);
+ if (ec != std::errc{} || ptr != version_limit) {
+ return -1;
Review Comment:
This is a non blocking comment (especially given that this is a private
method) but I wonder if we should change ```ParseVersionFromLocation()``` to
return ```Result<>``` to ensure that callers explicit have to check for errors
and act accordingly.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]