From: Nadav Har'El <n...@scylladb.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

virtiofs: fix incorrect use of unique_ptr

dax_window_impl::unmap() did:

   std::unique_ptr<u8> in_args {new (std::nothrow) u8[in_args_size]}

But since we use "new u8[]" here, not "new u8", we need to also delete
it with delete[], not delete, and std::unique_ptr<u8> doesn't - and
gcc 12.1.1 started detecting this and complaining.

The fix is to use std::unique_ptr<u8[]>.

This is one of the fixes needed to build on Fedora 36 (refs #1198).

Signed-off-by: Nadav Har'El <n...@scylladb.com>

---
diff --git a/fs/virtiofs/virtiofs_dax.cc b/fs/virtiofs/virtiofs_dax.cc
--- a/fs/virtiofs/virtiofs_dax.cc
+++ b/fs/virtiofs/virtiofs_dax.cc
@@ -217,7 +217,7 @@ int dax_window_impl::unmap(uint64_t len, uint64_t mstart)
     // fuse_removemapping_in.count fuse_removemapping_one arguments in general.
     auto in_args_size = sizeof(fuse_removemapping_in) +
         sizeof(fuse_removemapping_one);
-    std::unique_ptr<u8> in_args {new (std::nothrow) u8[in_args_size]};
+    std::unique_ptr<u8[]> in_args {new (std::nothrow) u8[in_args_size]};
     if (!in_args) {
         return ENOMEM;
     }

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/0000000000008bd58305e2543036%40google.com.

Reply via email to