break;
case CEPH_OSD_CMPXATTR_MODE_U64:
{
- uint64_t val;
+ uint64_t lhs;
try {
- decode(val, bp);
+ decode(lhs, bp);
} catch (ceph::buffer::error& e) {
logger().info("cmp_xattr: buffer error expection");
result = -EINVAL;
break;
}
- result = do_xattr_cmp_u64(osd_op.op.xattr.cmp_op, val, xattr);
+ result = do_xattr_cmp_u64(osd_op.op.xattr.cmp_op, lhs, xattr);
}
break;
default:
*
*/
+#include <charconv>
+
#include "boost/tuple/tuple.hpp"
#include "boost/intrusive_ptr.hpp"
#include "PG.h"
} // anonymous namespace
-int PrimaryLogPG::do_xattr_cmp_u64(int op, __u64 v1, bufferlist& xattr)
+int PrimaryLogPG::do_xattr_cmp_u64(int op, uint64_t v1, bufferlist& xattr)
{
- __u64 v2;
+ uint64_t v2;
- string v2s(xattr.c_str(), xattr.length());
- if (v2s.length())
- v2 = strtoull(v2s.c_str(), NULL, 10);
- else
+ if (xattr.length()) {
+ const char* first = xattr.c_str();
+ if (auto [p, ec] = std::from_chars(first, first + xattr.length(), v2);
+ ec != std::errc()) {
+ return -EINVAL;
+ }
+ } else {
v2 = 0;
-
+ }
dout(20) << "do_xattr_cmp_u64 '" << v1 << "' vs '" << v2 << "' op " << op << dendl;
return do_cmp_xattr(op, v1, v2);
}
unsigned split_bits) override;
void apply_and_flush_repops(bool requeue);
- int do_xattr_cmp_u64(int op, __u64 v1, ceph::buffer::list& xattr);
+ int do_xattr_cmp_u64(int op, uint64_t v1, ceph::buffer::list& xattr);
int do_xattr_cmp_str(int op, std::string& v1s, ceph::buffer::list& xattr);
// -- checksum --