[haiku-commits] haiku: hrev54786 - headers/private/shared src/add-ons/accelerants/intel_extreme src/add-ons/accelerants/radeon_hd src/add-ons/accelerants/vesa src

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 13 Dec 2020 14:14:18 -0500 (EST)

hrev54786 adds 4 changesets to branch 'master'
old head: 74b60970787e901984a6bc0518cbe2d58b092589
new head: cdccd323b5056042f24338ea9471b57ccf4b075f
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=cdccd323b505+%5E74b60970787e

----------------------------------------------------------------------------

84b1893b7320: AutoDeleter: introduce HandleDeleter
  
  It allow to use arbitrary handle type, null value and destructor function.
  
  Change-Id: I87c444cb7ef1b08d1dbed7fe4171700171d651d2
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/2977
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
  Reviewed-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

553f3f2309e8: AutoDeleter: add delarations for common types and destructors
  
  Change-Id: I74b75a54038d5af370696302f33b5c0abab4820c
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/3481
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

47404f12f27f: accelerant: replace AreaCloner with AreaDeleter
  
  Reduce code duplication.
  
  Change-Id: Ice1a14fc7378382e89c3e5a1aea6fa21b903e436
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/3482
  Reviewed-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

cdccd323b505: use common AutoDeleter types
  
  Change-Id: I115e14b76f3ff049c5f7d9471efd3619a0038fcf
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/3483
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
  Reviewed-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

                                              [ X512 <danger_mail@xxxxxxx> ]

----------------------------------------------------------------------------

32 files changed, 233 insertions(+), 262 deletions(-)
.../build/private/shared/AutoDeleterDrivers.h    |  1 +
headers/build/private/shared/AutoDeleterOS.h     |  1 +
headers/build/private/shared/AutoDeleterPosix.h  |  1 +
headers/private/shared/AutoDeleter.h             | 65 ++++++++++------
headers/private/shared/AutoDeleterDrivers.h      | 43 +++++++++++
headers/private/shared/AutoDeleterOS.h           | 29 +++++++
headers/private/shared/AutoDeleterPosix.h        | 31 ++++++++
src/add-ons/accelerants/intel_extreme/Jamfile    |  1 +
.../accelerants/intel_extreme/accelerant.cpp     | 80 ++++----------------
src/add-ons/accelerants/radeon_hd/Jamfile        |  1 +
src/add-ons/accelerants/radeon_hd/accelerant.cpp | 71 +++--------------
src/add-ons/accelerants/vesa/Jamfile             |  1 +
src/add-ons/accelerants/vesa/accelerant.cpp      | 62 +++------------
src/add-ons/kernel/file_systems/bindfs/Utils.h   | 17 -----
.../kernel/file_systems/bindfs/Volume.cpp        |  5 +-
.../file_systems/bindfs/kernel_interface.cpp     |  3 +-
.../packagefs/volume/PackageFSRoot.cpp           |  4 +-
.../packagefs/volume/PackageSettings.cpp         |  5 +-
.../file_systems/packagefs/volume/Volume.cpp     | 11 +--
src/apps/aboutsystem/AboutSystem.cpp             |  3 +-
src/bin/multiuser/multiuser_utils.cpp            |  4 +-
src/bin/package/PackageWritingUtils.cpp          |  3 +-
src/bin/ramdisk.cpp                              |  3 +-
src/kits/package/RepositoryInfo.cpp              |  4 +-
src/kits/package/hpkg/PackageWriterImpl.cpp      |  9 ++-
src/kits/package/manager/RepositoryBuilder.cpp   |  3 +-
src/preferences/virtualmemory/Settings.cpp       |  4 +-
src/servers/registrar/AuthenticationManager.cpp  | 13 ++--
.../packagefs/PackageSettingsItem.cpp            |  5 +-
src/system/kernel/fs/fd.cpp                      |  3 +-
src/system/kernel/fs/vfs_request_io.cpp          |  5 +-
src/system/kernel/vm/vm.cpp                      |  4 +-

############################################################################

Commit:      84b1893b732027989e8432a49e465355a318b4d2
URL:         https://git.haiku-os.org/haiku/commit/?id=84b1893b7320
Author:      X512 <danger_mail@xxxxxxx>
Date:        Thu Jul  2 06:16:53 2020 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sun Dec 13 19:14:13 2020 UTC

AutoDeleter: introduce HandleDeleter

It allow to use arbitrary handle type, null value and destructor function.

Change-Id: I87c444cb7ef1b08d1dbed7fe4171700171d651d2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2977
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
Reviewed-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/headers/private/shared/AutoDeleter.h 
b/headers/private/shared/AutoDeleter.h
index d4f7d98d64..cbf81b1de1 100644
--- a/headers/private/shared/AutoDeleter.h
+++ b/headers/private/shared/AutoDeleter.h
@@ -11,7 +11,8 @@
        ArrayDeleter   - deletes an array
        MemoryDeleter  - free()s malloc()ed memory
        CObjectDeleter - calls an arbitrary specified destructor function
-       FileDescriptorCloser - closes a file descriptor
+       HandleDeleter  - use arbitrary handle type and destructor function
+       FileDescriptorCloser - closes a file descriptor, based on HandleDeleter
 */
 
 
@@ -211,56 +212,71 @@ struct MethodDeleter
 };
 
 
-// FileDescriptorCloser
+// HandleDeleter
 
-struct FileDescriptorCloser {
-       inline FileDescriptorCloser()
-               :
-               fDescriptor(-1)
+template<typename C, typename DestructorResult,
+       DestructorResult (*Destructor)(C), C nullValue = -1>
+class HandleDeleter {
+public:
+       inline HandleDeleter()
+               : fHandle(nullValue)
        {
        }
 
-       inline FileDescriptorCloser(int descriptor)
-               :
-               fDescriptor(descriptor)
+       inline HandleDeleter(C handle)
+               : fHandle(handle)
        {
        }
 
-       inline ~FileDescriptorCloser()
+       inline ~HandleDeleter()
        {
-               SetTo(-1);
+               Destructor(fHandle);
        }
 
-       inline void SetTo(int descriptor)
+       inline void SetTo(C handle)
        {
-               if (fDescriptor >= 0)
-                       close(fDescriptor);
-
-               fDescriptor = descriptor;
+               if (handle != fHandle) {
+                       Destructor(fHandle);
+                       fHandle = handle;
+               }
        }
 
        inline void Unset()
        {
-               SetTo(-1);
+               SetTo(nullValue);
+       }
+
+       inline void Delete()
+       {
+               SetTo(nullValue);
        }
 
-       inline int Get()
+       inline C Get() const
        {
-               return fDescriptor;
+               return fHandle;
        }
 
-       inline int Detach()
+       inline C Detach()
        {
-               int descriptor = fDescriptor;
-               fDescriptor = -1;
-               return descriptor;
+               C handle = fHandle;
+               fHandle = nullValue;
+               return handle;
        }
 
+protected:
+       C                       fHandle;
+
 private:
-       int     fDescriptor;
+       HandleDeleter(const HandleDeleter&);
+       HandleDeleter& operator=(const HandleDeleter&);
 };
 
 
+// FileDescriptorCloser
+
+typedef HandleDeleter<int, int, close, -1> FileDescriptorCloser;
+
+
 }      // namespace BPrivate
 
 
@@ -269,6 +285,7 @@ using ::BPrivate::ArrayDeleter;
 using ::BPrivate::MemoryDeleter;
 using ::BPrivate::CObjectDeleter;
 using ::BPrivate::MethodDeleter;
+using ::BPrivate::HandleDeleter;
 using ::BPrivate::FileDescriptorCloser;
 
 

############################################################################

Commit:      553f3f2309e87d95345220463fa865d5fd8cf28d
URL:         https://git.haiku-os.org/haiku/commit/?id=553f3f2309e8
Author:      X512 <danger_mail@xxxxxxx>
Date:        Wed Dec  9 09:37:12 2020 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sun Dec 13 19:14:13 2020 UTC

AutoDeleter: add delarations for common types and destructors

Change-Id: I74b75a54038d5af370696302f33b5c0abab4820c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3481
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/headers/build/private/shared/AutoDeleterDrivers.h 
b/headers/build/private/shared/AutoDeleterDrivers.h
new file mode 100644
index 0000000000..dce251d271
--- /dev/null
+++ b/headers/build/private/shared/AutoDeleterDrivers.h
@@ -0,0 +1 @@
+#include <../private/shared/AutoDeleterDrivers.h>
diff --git a/headers/build/private/shared/AutoDeleterOS.h 
b/headers/build/private/shared/AutoDeleterOS.h
new file mode 100644
index 0000000000..b3976ff8b6
--- /dev/null
+++ b/headers/build/private/shared/AutoDeleterOS.h
@@ -0,0 +1 @@
+#include <../private/shared/AutoDeleterOS.h>
diff --git a/headers/build/private/shared/AutoDeleterPosix.h 
b/headers/build/private/shared/AutoDeleterPosix.h
new file mode 100644
index 0000000000..9e8e9161a1
--- /dev/null
+++ b/headers/build/private/shared/AutoDeleterPosix.h
@@ -0,0 +1 @@
+#include <../private/shared/AutoDeleterPosix.h>
diff --git a/headers/private/shared/AutoDeleterDrivers.h 
b/headers/private/shared/AutoDeleterDrivers.h
new file mode 100644
index 0000000000..c290ede37f
--- /dev/null
+++ b/headers/private/shared/AutoDeleterDrivers.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _AUTO_DELETER_DRIVERS_H
+#define _AUTO_DELETER_DRIVERS_H
+
+
+#include <AutoDeleter.h>
+#include <driver_settings.h>
+#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
+#include <vfs.h>
+#include <fs/fd.h>
+#endif
+
+
+namespace BPrivate {
+
+
+typedef CObjectDeleter<void, status_t, unload_driver_settings> 
DriverSettingsUnloader;
+
+#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
+
+typedef CObjectDeleter<struct vnode, void, vfs_put_vnode> VnodePutter;
+typedef CObjectDeleter<file_descriptor, void, put_fd> DescriptorPutter;
+
+#endif
+
+
+}
+
+
+using ::BPrivate::DriverSettingsUnloader;
+
+#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
+
+using ::BPrivate::VnodePutter;
+using ::BPrivate::DescriptorPutter;
+
+#endif
+
+
+#endif // _AUTO_DELETER_DRIVERS_H
diff --git a/headers/private/shared/AutoDeleterOS.h 
b/headers/private/shared/AutoDeleterOS.h
new file mode 100644
index 0000000000..8c48447ad6
--- /dev/null
+++ b/headers/private/shared/AutoDeleterOS.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _AUTO_DELETER_OS_H
+#define _AUTO_DELETER_OS_H
+
+
+#include <AutoDeleter.h>
+#include <OS.h>
+
+
+namespace BPrivate {
+
+
+typedef HandleDeleter<area_id, status_t, delete_area> AreaDeleter;
+typedef HandleDeleter<sem_id, status_t, delete_sem> SemDeleter;
+typedef HandleDeleter<port_id, status_t, delete_port> PortDeleter;
+
+
+}
+
+
+using ::BPrivate::AreaDeleter;
+using ::BPrivate::SemDeleter;
+using ::BPrivate::PortDeleter;
+
+
+#endif // _AUTO_DELETER_OS_H
diff --git a/headers/private/shared/AutoDeleterPosix.h 
b/headers/private/shared/AutoDeleterPosix.h
new file mode 100644
index 0000000000..82b5ba42f8
--- /dev/null
+++ b/headers/private/shared/AutoDeleterPosix.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2020, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef _AUTO_DELETER_POSIX_H
+#define _AUTO_DELETER_POSIX_H
+
+
+#include <AutoDeleter.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <fs_attr.h>
+
+
+namespace BPrivate {
+
+
+typedef CObjectDeleter<FILE, int, fclose> FileCloser;
+typedef CObjectDeleter<DIR, int, closedir> DirCloser;
+typedef CObjectDeleter<DIR, int, fs_close_attr_dir> AttrDirCloser;
+
+
+}
+
+
+using ::BPrivate::FileCloser;
+using ::BPrivate::DirCloser;
+using ::BPrivate::AttrDirCloser;
+
+
+#endif // _AUTO_DELETER_POSIX_H

############################################################################

Commit:      47404f12f27fc45fc0c011b1c5ac6f0c1b52e0e6
URL:         https://git.haiku-os.org/haiku/commit/?id=47404f12f27f
Author:      X512 <danger_mail@xxxxxxx>
Date:        Wed Dec  9 07:06:53 2020 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sun Dec 13 19:14:13 2020 UTC

accelerant: replace AreaCloner with AreaDeleter

Reduce code duplication.

Change-Id: Ice1a14fc7378382e89c3e5a1aea6fa21b903e436
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3482
Reviewed-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/add-ons/accelerants/intel_extreme/Jamfile 
b/src/add-ons/accelerants/intel_extreme/Jamfile
index 4f6fbf498d..cb4750872c 100644
--- a/src/add-ons/accelerants/intel_extreme/Jamfile
+++ b/src/add-ons/accelerants/intel_extreme/Jamfile
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons accelerants intel_extreme ;
 UsePrivateHeaders graphics ;
 UsePrivateHeaders [ FDirName graphics intel_extreme ] ;
 UsePrivateHeaders [ FDirName graphics common ] ;
+UsePrivateHeaders shared ;
 
 Addon intel_extreme.accelerant :
        accelerant.cpp
diff --git a/src/add-ons/accelerants/intel_extreme/accelerant.cpp 
b/src/add-ons/accelerants/intel_extreme/accelerant.cpp
index 2ce15758aa..e81a34c5e2 100644
--- a/src/add-ons/accelerants/intel_extreme/accelerant.cpp
+++ b/src/add-ons/accelerants/intel_extreme/accelerant.cpp
@@ -22,6 +22,7 @@
 #include <new>
 
 #include <AGP.h>
+#include <AutoDeleterOS.h>
 
 
 #undef TRACE
@@ -40,53 +41,6 @@ struct accelerant_info* gInfo;
 uint32 gDumpCount;
 
 
-class AreaCloner {
-public:
-                                                       AreaCloner();
-                                                       ~AreaCloner();
-
-                       area_id                 Clone(const char* name, void** 
_address,
-                                                               uint32 spec, 
uint32 protection,
-                                                               area_id 
sourceArea);
-                       status_t                InitCheck()
-                                                               { return fArea 
< 0 ? (status_t)fArea : B_OK; }
-                       void                    Keep();
-
-private:
-                       area_id                 fArea;
-};
-
-
-AreaCloner::AreaCloner()
-       :
-       fArea(-1)
-{
-}
-
-
-AreaCloner::~AreaCloner()
-{
-       if (fArea >= 0)
-               delete_area(fArea);
-}
-
-
-area_id
-AreaCloner::Clone(const char* name, void** _address, uint32 spec,
-       uint32 protection, area_id sourceArea)
-{
-       fArea = clone_area(name, _address, spec, protection, sourceArea);
-       return fArea;
-}
-
-
-void
-AreaCloner::Keep()
-{
-       fArea = -1;
-}
-
-
 //     #pragma mark -
 
 
@@ -134,6 +88,7 @@ init_common(int device, bool isClone)
        gInfo = (accelerant_info*)malloc(sizeof(accelerant_info));
        if (gInfo == NULL)
                return B_NO_MEMORY;
+       MemoryDeleter infoDeleter(gInfo);
 
        memset(gInfo, 0, sizeof(accelerant_info));
 
@@ -146,33 +101,26 @@ init_common(int device, bool isClone)
        data.magic = INTEL_PRIVATE_DATA_MAGIC;
 
        if (ioctl(device, INTEL_GET_PRIVATE_DATA, &data,
-                       sizeof(intel_get_private_data)) != 0) {
-               free(gInfo);
+                       sizeof(intel_get_private_data)) != 0)
                return B_ERROR;
-       }
 
-       AreaCloner sharedCloner;
-       gInfo->shared_info_area = sharedCloner.Clone("intel extreme shared 
info",
+       AreaDeleter sharedDeleter(clone_area("intel extreme shared info",
                (void**)&gInfo->shared_info, B_ANY_ADDRESS, B_READ_AREA | 
B_WRITE_AREA,
-               data.shared_info_area);
-       status_t status = sharedCloner.InitCheck();
-       if (status < B_OK) {
-               free(gInfo);
+               data.shared_info_area));
+       status_t status = gInfo->shared_info_area = sharedDeleter.Get();
+       if (status < B_OK)
                return status;
-       }
 
-       AreaCloner regsCloner;
-       gInfo->regs_area = regsCloner.Clone("intel extreme regs",
+       AreaDeleter regsDeleter(clone_area("intel extreme regs",
                (void**)&gInfo->registers, B_ANY_ADDRESS, B_READ_AREA | 
B_WRITE_AREA,
-               gInfo->shared_info->registers_area);
-       status = regsCloner.InitCheck();
-       if (status < B_OK) {
-               free(gInfo);
+               gInfo->shared_info->registers_area));
+       status = gInfo->regs_area = regsDeleter.Get();
+       if (status < B_OK)
                return status;
-       }
 
-       sharedCloner.Keep();
-       regsCloner.Keep();
+       infoDeleter.Detach();
+       sharedDeleter.Detach();
+       regsDeleter.Detach();
 
        // The overlay registers, hardware status, and cursor memory share
        // a single area with the shared_info
diff --git a/src/add-ons/accelerants/radeon_hd/Jamfile 
b/src/add-ons/accelerants/radeon_hd/Jamfile
index 42ea0fb242..d2ddb3efc3 100644
--- a/src/add-ons/accelerants/radeon_hd/Jamfile
+++ b/src/add-ons/accelerants/radeon_hd/Jamfile
@@ -6,6 +6,7 @@ UseHeaders [ FDirName $(SUBDIR) atombios ] ;
 UsePrivateHeaders graphics ;
 UsePrivateHeaders [ FDirName graphics radeon_hd ] ;
 UsePrivateHeaders [ FDirName graphics common ] ;
+UsePrivateHeaders shared ;
 
 Addon radeon_hd.accelerant :
        accelerant.cpp
diff --git a/src/add-ons/accelerants/radeon_hd/accelerant.cpp 
b/src/add-ons/accelerants/radeon_hd/accelerant.cpp
index 727a3ca38a..4939654f31 100644
--- a/src/add-ons/accelerants/radeon_hd/accelerant.cpp
+++ b/src/add-ons/accelerants/radeon_hd/accelerant.cpp
@@ -19,6 +19,8 @@
 #include <syslog.h>
 #include <unistd.h>
 
+#include <AutoDeleterOS.h>
+
 #include "accelerant_protos.h"
 
 #include "bios.h"
@@ -46,53 +48,6 @@ connector_info* gConnector[ATOM_MAX_SUPPORTED_DEVICE];
 gpio_info* gGPIOInfo[MAX_GPIO_PINS];
 
 
-class AreaCloner {
-public:
-                                                               AreaCloner();
-                                                               ~AreaCloner();
-
-                       area_id                         Clone(const char* name, 
void** _address,
-                                                                       uint32 
spec, uint32 protection,
-                                                                       area_id 
sourceArea);
-                       status_t                        InitCheck()
-                                                                       {return 
fArea < 0 ? (status_t)fArea : B_OK;}
-                       void                            Keep();
-
-private:
-                       area_id                         fArea;
-};
-
-
-AreaCloner::AreaCloner()
-       :
-       fArea(-1)
-{
-}
-
-
-AreaCloner::~AreaCloner()
-{
-       if (fArea >= 0)
-               delete_area(fArea);
-}
-
-
-area_id
-AreaCloner::Clone(const char* name, void** _address, uint32 spec,
-       uint32 protection, area_id sourceArea)
-{
-       fArea = clone_area(name, _address, spec, protection, sourceArea);
-       return fArea;
-}
-
-
-void
-AreaCloner::Keep()
-{
-       fArea = -1;
-}
-
-
 //     #pragma mark -
 
 
@@ -105,6 +60,7 @@ init_common(int device, bool isClone)
        // initialize global accelerant info structure
 
        gInfo = (accelerant_info*)malloc(sizeof(accelerant_info));
+       MemoryDeleter infoDeleter(gInfo);
 
        if (gInfo == NULL)
                return B_NO_MEMORY;
@@ -161,24 +117,20 @@ init_common(int device, bool isClone)
                return B_ERROR;
        }
 
-       AreaCloner sharedCloner;
-       gInfo->shared_info_area = sharedCloner.Clone("radeon hd shared info",
+       AreaDeleter sharedDeleter(clone_area("radeon hd shared info",
                (void**)&gInfo->shared_info, B_ANY_ADDRESS, B_READ_AREA | 
B_WRITE_AREA,
-               data.shared_info_area);
-       status_t status = sharedCloner.InitCheck();
+               data.shared_info_area));
+       status_t status = gInfo->shared_info_area = sharedDeleter.Get();
        if (status < B_OK) {
-               free(gInfo);
                TRACE("%s, failed to create shared area\n", __func__);
                return status;
        }
 
-       AreaCloner regsCloner;
-       gInfo->regs_area = regsCloner.Clone("radeon hd regs",
+       AreaDeleter regsDeleter(clone_area("radeon hd regs",
                (void**)&gInfo->regs, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA,
-               gInfo->shared_info->registers_area);
-       status = regsCloner.InitCheck();
+               gInfo->shared_info->registers_area));
+       status = gInfo->regs_area = regsDeleter.Get();
        if (status < B_OK) {
-               free(gInfo);
                TRACE("%s, failed to create mmio area\n", __func__);
                return status;
        }
@@ -195,8 +147,9 @@ init_common(int device, bool isClone)
        if (gInfo->rom[0] != 0x55 || gInfo->rom[1] != 0xAA)
                TRACE("%s: didn't find a VGA bios in cloned region!\n", 
__func__);
 
-       sharedCloner.Keep();
-       regsCloner.Keep();
+       infoDeleter.Detach();
+       sharedDeleter.Detach();
+       regsDeleter.Detach();
 
        return B_OK;
 }
diff --git a/src/add-ons/accelerants/vesa/Jamfile 
b/src/add-ons/accelerants/vesa/Jamfile
index 0983a5100a..5818056f80 100644
--- a/src/add-ons/accelerants/vesa/Jamfile
+++ b/src/add-ons/accelerants/vesa/Jamfile
@@ -3,6 +3,7 @@ SubDir HAIKU_TOP src add-ons accelerants vesa ;
 UsePrivateHeaders graphics ;
 UsePrivateHeaders [ FDirName graphics vesa ] ;
 UsePrivateHeaders [ FDirName graphics common ] ;
+UsePrivateHeaders shared ;
 
 #AddResources vesa.accelerant : vesa.accelerant.rdef ;
 
diff --git a/src/add-ons/accelerants/vesa/accelerant.cpp 
b/src/add-ons/accelerants/vesa/accelerant.cpp
index 3120d46b7d..0597719e8c 100644
--- a/src/add-ons/accelerants/vesa/accelerant.cpp
+++ b/src/add-ons/accelerants/vesa/accelerant.cpp
@@ -14,6 +14,8 @@
 #include <errno.h>
 #include <syslog.h>
 
+#include <AutoDeleterOS.h>
+
 
 //#define TRACE_ACCELERANT
 #ifdef TRACE_ACCELERANT
@@ -27,51 +29,6 @@ extern "C" void _sPrintf(const char *format, ...);
 struct accelerant_info *gInfo;
 
 
-class AreaCloner {
-       public:
-               AreaCloner();
-               ~AreaCloner();
-
-               area_id Clone(const char *name, void **_address, uint32 spec,
-                                       uint32 protection, area_id sourceArea);
-               status_t InitCheck() { return fArea < B_OK ? (status_t)fArea : 
B_OK; }
-               void Keep();
-
-       private:
-               area_id fArea;
-};
-
-
-AreaCloner::AreaCloner()
-       :
-       fArea(-1)
-{
-}
-
-
-AreaCloner::~AreaCloner()
-{
-       if (fArea >= B_OK)
-               delete_area(fArea);
-}
-
-
-area_id
-AreaCloner::Clone(const char *name, void **_address, uint32 spec,
-       uint32 protection, area_id sourceArea)
-{
-       fArea = clone_area(name, _address, spec, protection, sourceArea);
-       return fArea;
-}
-
-
-void
-AreaCloner::Keep()
-{
-       fArea = -1;
-}
-
-
 //     #pragma mark -
 
 
@@ -84,6 +41,7 @@ init_common(int device, bool isClone)
        // initialize global accelerant info structure
 
        gInfo = (accelerant_info *)malloc(sizeof(accelerant_info));
+       MemoryDeleter infoDeleter(gInfo);
        if (gInfo == NULL)
                return B_NO_MEMORY;
 
@@ -102,15 +60,12 @@ init_common(int device, bool isClone)
                return B_ERROR;
        }
 
-       AreaCloner sharedCloner;
-       gInfo->shared_info_area = sharedCloner.Clone("vesa shared info",
+       AreaDeleter sharedDeleter(clone_area("vesa shared info",
                (void **)&gInfo->shared_info, B_ANY_ADDRESS,
-               B_READ_AREA | B_WRITE_AREA, sharedArea);
-       status_t status = sharedCloner.InitCheck();
-       if (status < B_OK) {
-               free(gInfo);
+               B_READ_AREA | B_WRITE_AREA, sharedArea));
+       status_t status = gInfo->shared_info_area = sharedDeleter.Get();
+       if (status < B_OK)
                return status;
-       }
 
        if (gInfo->shared_info->vesa_mode_count == 0)
                gInfo->vesa_modes = NULL;
@@ -118,7 +73,8 @@ init_common(int device, bool isClone)
                gInfo->vesa_modes = (vesa_mode *)((uint8 *)gInfo->shared_info
                        + gInfo->shared_info->vesa_mode_offset);
 
-       sharedCloner.Keep();
+       infoDeleter.Detach();
+       sharedDeleter.Detach();
        return B_OK;
 }
 

############################################################################

Revision:    hrev54786
Commit:      cdccd323b5056042f24338ea9471b57ccf4b075f
URL:         https://git.haiku-os.org/haiku/commit/?id=cdccd323b505
Author:      X512 <danger_mail@xxxxxxx>
Date:        Wed Dec  9 09:39:56 2020 UTC
Committer:   Adrien Destugues <pulkomandy@xxxxxxxxx>
Commit-Date: Sun Dec 13 19:14:13 2020 UTC

use common AutoDeleter types

Change-Id: I115e14b76f3ff049c5f7d9471efd3619a0038fcf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3483
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>
Reviewed-by: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/bindfs/Utils.h 
b/src/add-ons/kernel/file_systems/bindfs/Utils.h
deleted file mode 100644
index bff927bd5e..0000000000
--- a/src/add-ons/kernel/file_systems/bindfs/Utils.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2011, Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
- * Distributed under the terms of the MIT License.
- */
-#ifndef UTILS_H
-#define UTILS_H
-
-
-#include <AutoDeleter.h>
-
-#include <vfs.h>
-
-
-typedef CObjectDeleter<vnode, void, vfs_put_vnode> VnodePutter;
-
-
-#endif // UTILS_H
diff --git a/src/add-ons/kernel/file_systems/bindfs/Volume.cpp 
b/src/add-ons/kernel/file_systems/bindfs/Volume.cpp
index 14b74310dc..5f53bd074a 100644
--- a/src/add-ons/kernel/file_systems/bindfs/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/bindfs/Volume.cpp
@@ -19,11 +19,11 @@
 #include <vfs.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 
 #include "DebugSupport.h"
 #include "kernel_interface.h"
 #include "Node.h"
-#include "Utils.h"
 
 
 // #pragma mark - Volume
@@ -51,8 +51,7 @@ Volume::Mount(const char* parameterString)
 {
        const char* source = NULL;
        void* parameterHandle = parse_driver_settings_string(parameterString);
-       CObjectDeleter<void, status_t, delete_driver_settings>
-               parameterDeleter(parameterHandle);
+       DriverSettingsUnloader parameterDeleter(parameterHandle);
        if (parameterHandle != NULL)
                source = get_driver_parameter(parameterHandle, "source", NULL, 
NULL);
        if (source == NULL || source[0] == '\0') {
diff --git a/src/add-ons/kernel/file_systems/bindfs/kernel_interface.cpp 
b/src/add-ons/kernel/file_systems/bindfs/kernel_interface.cpp
index 50f6422f6f..89a0f4cfad 100644
--- a/src/add-ons/kernel/file_systems/bindfs/kernel_interface.cpp
+++ b/src/add-ons/kernel/file_systems/bindfs/kernel_interface.cpp
@@ -12,12 +12,11 @@
 
 #include <vfs.h>
 
-#include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 
 #include "DebugSupport.h"
 #include "kernel_interface.h"
 #include "Node.h"
-#include "Utils.h"
 #include "Volume.h"
 
 
diff --git a/src/add-ons/kernel/file_systems/packagefs/volume/PackageFSRoot.cpp 
b/src/add-ons/kernel/file_systems/packagefs/volume/PackageFSRoot.cpp
index 096bc8fd22..d1033b517a 100644
--- a/src/add-ons/kernel/file_systems/packagefs/volume/PackageFSRoot.cpp
+++ b/src/add-ons/kernel/file_systems/packagefs/volume/PackageFSRoot.cpp
@@ -6,7 +6,7 @@
 
 #include "PackageFSRoot.h"
 
-#include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 
 #include <vfs.h>
 
@@ -114,7 +114,7 @@ PackageFSRoot::RegisterVolume(Volume* volume)
                                relativeRootPath, strerror(error));
                        RETURN_ERROR(error);
                }
-               CObjectDeleter<struct vnode, void, vfs_put_vnode> 
vnodePutter(vnode);
+               VnodePutter vnodePutter(vnode);
 
                // stat it
                struct stat st;
diff --git 
a/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp 
b/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp
index ad2985e010..e7889f6a07 100644
--- a/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp
+++ b/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp
@@ -8,7 +8,7 @@
 
 #include <driver_settings.h>
 
-#include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 #include <directories.h>
 #include <fs/KPath.h>
 #include <vfs.h>
@@ -216,8 +216,7 @@ PackageSettings::Load(dev_t mountPointDeviceID, ino_t 
mountPointNodeID,
        void* settingsHandle = load_driver_settings(path.Path());
        if (settingsHandle == NULL)
                return B_ENTRY_NOT_FOUND;
-       CObjectDeleter<void, status_t, unload_driver_settings>
-               settingsDeleter(settingsHandle);
+       DriverSettingsUnloader settingsDeleter(settingsHandle);
 
        const driver_settings* settings = get_driver_settings(settingsHandle);
        for (int i = 0; i < settings->parameter_count; i++) {
diff --git a/src/add-ons/kernel/file_systems/packagefs/volume/Volume.cpp 
b/src/add-ons/kernel/file_systems/packagefs/volume/Volume.cpp
index 9886cea9fa..eecfa5390a 100644
--- a/src/add-ons/kernel/file_systems/packagefs/volume/Volume.cpp
+++ b/src/add-ons/kernel/file_systems/packagefs/volume/Volume.cpp
@@ -22,6 +22,8 @@
 #include <package/PackageInfoAttributes.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
+#include <AutoDeleterDrivers.h>
 #include <PackagesDirectoryDefs.h>
 
 #include <vfs.h>
@@ -329,8 +331,7 @@ Volume::Mount(const char* parameterString)
                        NULL);
        }
 
-       CObjectDeleter<void, status_t, delete_driver_settings>
-               parameterHandleDeleter(parameterHandle);
+       DriverSettingsUnloader parameterHandleDeleter(parameterHandle);
 
        if (packages != NULL && packages[0] == '\0') {
                FATAL("invalid package folder ('packages' parameter)!\n");
@@ -711,7 +712,7 @@ Volume::_LoadOldPackagesStates(const char* packagesState)
                ERROR("Failed to open administrative directory: %s\n", 
strerror(errno));
                RETURN_ERROR(errno);
        }
-       CObjectDeleter<DIR, int, closedir> dirCloser(dir);
+       DirCloser dirCloser(dir);
 
        while (dirent* entry = readdir(dir)) {
                if (strncmp(entry->d_name, "state_", 6) != 0
@@ -903,7 +904,7 @@ Volume::_AddInitialPackagesFromDirectory()
                        fPackagesDirectory->Path(), strerror(errno));
                RETURN_ERROR(errno);
        }
-       CObjectDeleter<DIR, int, closedir> dirCloser(dir);
+       DirCloser dirCloser(dir);
 
        while (dirent* entry = readdir(dir)) {
                // skip "." and ".."
@@ -1778,7 +1779,7 @@ Volume::_PublishShineThroughDirectories()
                        _RemoveNode(directory);
                        continue;
                }
-               CObjectDeleter<struct vnode, void, vfs_put_vnode> 
vnodePutter(vnode);
+               VnodePutter vnodePutter(vnode);
 
                // stat it
                struct stat st;
diff --git a/src/apps/aboutsystem/AboutSystem.cpp 
b/src/apps/aboutsystem/AboutSystem.cpp
index f9c6149ede..afcfd51c46 100644
--- a/src/apps/aboutsystem/AboutSystem.cpp
+++ b/src/apps/aboutsystem/AboutSystem.cpp
@@ -51,6 +51,7 @@
 
 #include <AppMisc.h>
 #include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
 #include <cpu_type.h>
 #include <parsedate.h>
 #include <system_revision.h>
@@ -1463,7 +1464,7 @@ AboutView::_AddCopyrightsFromAttribute()
                close(attrFD);
                return;
        }
-       CObjectDeleter<FILE, int, fclose> _(attrFile);
+       FileCloser _(attrFile);
 
        // read and parse the copyrights
        BMessage package;
diff --git a/src/bin/multiuser/multiuser_utils.cpp 
b/src/bin/multiuser/multiuser_utils.cpp
index f70e549a52..54838ebcaa 100644
--- a/src/bin/multiuser/multiuser_utils.cpp
+++ b/src/bin/multiuser/multiuser_utils.cpp
@@ -12,7 +12,7 @@
 #include <termios.h>
 #include <unistd.h>
 
-#include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
 
 #include <user_group.h>
 
@@ -38,7 +38,7 @@ read_password(const char* prompt, char* password, size_t 
bufferSize,
                in = tty;
                out = tty;
        }
-       CObjectDeleter<FILE, int, fclose> ttyCloser(tty);
+       FileCloser ttyCloser(tty);
 
        // disable echo
        int inFD = fileno(in);
diff --git a/src/bin/package/PackageWritingUtils.cpp 
b/src/bin/package/PackageWritingUtils.cpp
index ad29dd588d..88aa9850a1 100644
--- a/src/bin/package/PackageWritingUtils.cpp
+++ b/src/bin/package/PackageWritingUtils.cpp
@@ -14,6 +14,7 @@
 #include <package/hpkg/HPKGDefs.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
 
 
 status_t
@@ -27,7 +28,7 @@ add_current_directory_entries(BPackageWriter& packageWriter,
                        strerror(errno));
                return errno;
        }
-       CObjectDeleter<DIR, int, closedir> dirCloser(dir);
+       DirCloser dirCloser(dir);
 
        while (dirent* entry = readdir(dir)) {
                // skip "." and ".."
diff --git a/src/bin/ramdisk.cpp b/src/bin/ramdisk.cpp
index bf4dacb49e..b851025a39 100644
--- a/src/bin/ramdisk.cpp
+++ b/src/bin/ramdisk.cpp
@@ -17,6 +17,7 @@
 #include <String.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
 #include <StringForSize.h>
 #include <TextTable.h>
 
@@ -387,7 +388,7 @@ command_list(int argc, const char* const* argv)
                        strerror(errno));
                return 1;
        }
-       CObjectDeleter<DIR, int, closedir> dirCloser(dir);
+       DirCloser dirCloser(dir);
 
        TextTable table;
        table.AddColumn("ID", B_ALIGN_RIGHT);
diff --git a/src/kits/package/RepositoryInfo.cpp 
b/src/kits/package/RepositoryInfo.cpp
index 28957ecf55..f2120f7282 100644
--- a/src/kits/package/RepositoryInfo.cpp
+++ b/src/kits/package/RepositoryInfo.cpp
@@ -19,6 +19,7 @@
 #include <Message.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 #include <package/PackageInfo.h>
 
 
@@ -360,8 +361,7 @@ BRepositoryInfo::_SetTo(const BEntry& entry)
        void* settingsHandle = 
parse_driver_settings_string(configString.String());
        if (settingsHandle == NULL)
                return B_BAD_DATA;
-       CObjectDeleter<void, status_t, unload_driver_settings>
-               settingsHandleDeleter(settingsHandle);
+       DriverSettingsUnloader settingsHandleDeleter(settingsHandle);
 
        const char* name = get_driver_parameter(settingsHandle, "name", NULL, 
NULL);
        const char* identifier = get_driver_parameter(settingsHandle, 
"identifier", NULL, NULL);
diff --git a/src/kits/package/hpkg/PackageWriterImpl.cpp 
b/src/kits/package/hpkg/PackageWriterImpl.cpp
index 1cf964df12..301e2d4bfd 100644
--- a/src/kits/package/hpkg/PackageWriterImpl.cpp
+++ b/src/kits/package/hpkg/PackageWriterImpl.cpp
@@ -33,6 +33,7 @@
 #include <package/hpkg/PackageDataReader.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
 #include <RangeArray.h>
 
 #include <package/hpkg/HPKGDefsPrivate.h>
@@ -1138,7 +1139,7 @@ PackageWriterImpl::_UpdateCheckEntryCollisions(Attribute* 
parentAttribute,
 
                // first we check for colliding node attributes, though
                if (DIR* attrDir = fs_fopen_attr_dir(fd)) {
-                       CObjectDeleter<DIR, int, fs_close_attr_dir> 
attrDirCloser(attrDir);
+                       AttrDirCloser attrDirCloser(attrDir);
 
                        while (dirent* entry = fs_read_attr_dir(attrDir)) {
                                attr_info attrInfo;
@@ -1184,7 +1185,7 @@ PackageWriterImpl::_UpdateCheckEntryCollisions(Attribute* 
parentAttribute,
                        close(clonedFD);
                        throw status_t(errno);
                }
-               CObjectDeleter<DIR, int, closedir> dirCloser(dir);
+               DirCloser dirCloser(dir);
 
                while (dirent* entry = readdir(dir)) {
                        // skip "." and ".."
@@ -1525,7 +1526,7 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, 
const char* fileName,
 
        // add attributes
        if (DIR* attrDir = fs_fopen_attr_dir(fd)) {
-               CObjectDeleter<DIR, int, fs_close_attr_dir> 
attrDirCloser(attrDir);
+               AttrDirCloser attrDirCloser(attrDir);
 
                while (dirent* entry = fs_read_attr_dir(attrDir)) {
                        attr_info attrInfo;
@@ -1586,7 +1587,7 @@ PackageWriterImpl::_AddDirectoryChildren(Entry* entry, 
int fd, char* pathBuffer)
                        close(clonedFD);
                        throw status_t(errno);
                }
-               CObjectDeleter<DIR, int, closedir> dirCloser(dir);
+               DirCloser dirCloser(dir);
 
                while (dirent* entry = readdir(dir)) {
                        // skip "." and ".."
diff --git a/src/kits/package/manager/RepositoryBuilder.cpp 
b/src/kits/package/manager/RepositoryBuilder.cpp
index dcfaec7520..fe9bbe395d 100644
--- a/src/kits/package/manager/RepositoryBuilder.cpp
+++ b/src/kits/package/manager/RepositoryBuilder.cpp
@@ -18,6 +18,7 @@
 #include <Path.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
 
 #include "PackageManagerUtils.h"
 
@@ -210,7 +211,7 @@ BRepositoryBuilder::AddPackagesDirectory(const char* path)
        DIR* dir = opendir(path);
        if (dir == NULL)
                DIE(errno, "failed to open package directory \"%s\"", path);
-       CObjectDeleter<DIR, int, closedir> dirCloser(dir);
+       DirCloser dirCloser(dir);
 
        // iterate through directory entries
        while (dirent* entry = readdir(dir)) {
diff --git a/src/preferences/virtualmemory/Settings.cpp 
b/src/preferences/virtualmemory/Settings.cpp
index a0b32d3450..270defd88e 100644
--- a/src/preferences/virtualmemory/Settings.cpp
+++ b/src/preferences/virtualmemory/Settings.cpp
@@ -18,6 +18,7 @@
 #include <string.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 #include <File.h>
 #include <FindDirectory.h>
 #include <Path.h>
@@ -139,8 +140,7 @@ Settings::ReadSwapSettings()
        void* settings = load_driver_settings(kVirtualMemorySettings);
        if (settings == NULL)
                return kErrorSettingsNotFound;
-       CObjectDeleter<void, status_t, unload_driver_settings>
-               settingDeleter(settings);
+       DriverSettingsUnloader settingDeleter(settings);
 
        const char* enabled = get_driver_parameter(settings, "vm", NULL, NULL);
        const char* automatic = get_driver_parameter(settings, "swap_auto",
diff --git a/src/servers/registrar/AuthenticationManager.cpp 
b/src/servers/registrar/AuthenticationManager.cpp
index fe6eee95d8..ddc6ef9fb6 100644
--- a/src/servers/registrar/AuthenticationManager.cpp
+++ b/src/servers/registrar/AuthenticationManager.cpp
@@ -20,6 +20,7 @@
 #include <StringList.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterPosix.h>
 #include <LaunchRoster.h>
 #include <RegistrarDefs.h>
 
@@ -568,14 +569,14 @@ public:
                        debug_printf("REG: Failed to open passwd file \"%s\" 
for "
                                "writing: %s\n", kPasswdFile, strerror(errno));
                }
-               CObjectDeleter<FILE, int, fclose> _1(passwdFile);
+               FileCloser _1(passwdFile);
 
                FILE* shadowFile = fopen(kShadowPwdFile, "w");
                if (shadowFile == NULL) {
                        debug_printf("REG: Failed to open shadow passwd file 
\"%s\" for "
                                "writing: %s\n", kShadowPwdFile, 
strerror(errno));
                }
-               CObjectDeleter<FILE, int, fclose> _2(shadowFile);
+               FileCloser _2(shadowFile);
 
                // write users
                for (map<uid_t, User*>::const_iterator it = fUsersByID.begin();
@@ -694,7 +695,7 @@ public:
                        debug_printf("REG: Failed to open group file \"%s\" for 
"
                                "writing: %s\n", kGroupFile, strerror(errno));
                }
-               CObjectDeleter<FILE, int, fclose> _1(groupFile);
+               FileCloser _1(groupFile);
 
                // write groups
                for (map<gid_t, Group*>::const_iterator it = 
fGroupsByID.begin();
@@ -1245,7 +1246,7 @@ AuthenticationManager::_InitPasswdDB()
                        kPasswdFile, strerror(errno));
                return errno;
        }
-       CObjectDeleter<FILE, int, fclose> _(file);
+       FileCloser _(file);
 
        char lineBuffer[LINE_MAX];
        while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) {
@@ -1294,7 +1295,7 @@ AuthenticationManager::_InitGroupDB()
                        kGroupFile, strerror(errno));
                return errno;
        }
-       CObjectDeleter<FILE, int, fclose> _(file);
+       FileCloser _(file);
 
        char lineBuffer[LINE_MAX];
        while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) {
@@ -1342,7 +1343,7 @@ AuthenticationManager::_InitShadowPwdDB()
                        kShadowPwdFile, strerror(errno));
                return errno;
        }
-       CObjectDeleter<FILE, int, fclose> _(file);
+       FileCloser _(file);
 
        char lineBuffer[LINE_MAX];
        while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) {
diff --git 
a/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp 
b/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp
index 736b0729c6..771c8f9ebd 100644
--- a/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp
+++ b/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp
@@ -8,7 +8,7 @@
 
 #include <driver_settings.h>
 
-#include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 #include <boot/vfs.h>
 #include <system/directories.h>
 
@@ -54,8 +54,7 @@ PackageSettingsItem::Load(::Directory* systemDirectory, const 
char* name)
        void* settingsHandle = load_driver_settings_file(fd);
        if (settingsHandle == NULL)
                return NULL;
-       CObjectDeleter<void, status_t, &unload_driver_settings>
-               settingsDeleter(settingsHandle);
+       DriverSettingsUnloader settingsDeleter(settingsHandle);
 
        const driver_settings* settings = get_driver_settings(settingsHandle);
        for (int i = 0; i < settings->parameter_count; i++) {
diff --git a/src/system/kernel/fs/fd.cpp b/src/system/kernel/fs/fd.cpp
index 90f267244a..4389bfe557 100644
--- a/src/system/kernel/fs/fd.cpp
+++ b/src/system/kernel/fs/fd.cpp
@@ -16,6 +16,7 @@
 #include <OS.h>
 
 #include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 #include <BytePointer.h>
 
 #include <syscalls.h>
@@ -497,7 +498,7 @@ dup_foreign_fd(team_id fromTeam, int fd, bool kernel)
        file_descriptor* descriptor = get_fd(fromContext, fd);
        if (descriptor == NULL)
                return B_FILE_ERROR;
-       CObjectDeleter<file_descriptor, void, put_fd> 
descriptorPutter(descriptor);
+       DescriptorPutter descriptorPutter(descriptor);
 
        // create a new FD in the target I/O context
        int result = new_fd(get_current_io_context(kernel), descriptor);
diff --git a/src/system/kernel/fs/vfs_request_io.cpp 
b/src/system/kernel/fs/vfs_request_io.cpp
index 2d79d80d9e..264977f542 100644
--- a/src/system/kernel/fs/vfs_request_io.cpp
+++ b/src/system/kernel/fs/vfs_request_io.cpp
@@ -15,6 +15,7 @@
 
 
 #include <heap.h>
+#include <AutoDeleterDrivers.h>
 
 
 // #pragma mark - AsyncIOCallback
@@ -478,7 +479,7 @@ do_fd_io(int fd, io_request* request)
                return B_FILE_ERROR;
        }
 
-       CObjectDeleter<file_descriptor, void, put_fd> 
descriptorPutter(descriptor);
+       DescriptorPutter descriptorPutter(descriptor);
 
        return vfs_vnode_io(vnode, descriptor->cookie, request);
 }
@@ -500,7 +501,7 @@ do_iterative_fd_io(int fd, io_request* request, 
iterative_io_get_vecs getVecs,
                return B_FILE_ERROR;
        }
 
-       CObjectDeleter<file_descriptor, void, put_fd> 
descriptorPutter(descriptor);
+       DescriptorPutter descriptorPutter(descriptor);
 
        if (!HAS_FS_CALL(vnode, io)) {
                // no io() call -- fall back to synchronous I/O
diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp
index 4d61a272b1..6c92a5933a 100644
--- a/src/system/kernel/vm/vm.cpp
+++ b/src/system/kernel/vm/vm.cpp
@@ -21,7 +21,7 @@
 #include <OS.h>
 #include <KernelExport.h>
 
-#include <AutoDeleter.h>
+#include <AutoDeleterDrivers.h>
 
 #include <symbol_versioning.h>
 
@@ -2054,7 +2054,7 @@ _vm_map_file(team_id team, const char* name, void** 
_address,
        status_t status = vfs_get_vnode_from_fd(fd, kernel, &vnode);
        if (status < B_OK)
                return status;
-       CObjectDeleter<struct vnode, void, vfs_put_vnode> vnodePutter(vnode);
+       VnodePutter vnodePutter(vnode);
 
        // If we're going to pre-map pages, we need to reserve the pages needed 
by
        // the mapping backend upfront.



Other related posts:

  • » [haiku-commits] haiku: hrev54786 - headers/private/shared src/add-ons/accelerants/intel_extreme src/add-ons/accelerants/radeon_hd src/add-ons/accelerants/vesa src - Adrien Destugues