diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index c91d0272f7..f98ea7e604 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -1372,7 +1372,7 @@ bfs_open(fs_volume* _volume, fs_vnode* _node, int openMode, void** _cookie) cookie->last_notification = system_time(); // Disable the file cache, if requested? - CObjectDeleter fileCacheEnabler(file_cache_enable); + CObjectDeleter fileCacheEnabler; if ((openMode & O_NOCACHE) != 0 && inode->FileCache() != NULL) { status = file_cache_disable(inode->FileCache()); if (status != B_OK) diff --git a/src/add-ons/kernel/file_systems/bindfs/Volume.cpp b/src/add-ons/kernel/file_systems/bindfs/Volume.cpp index e811459d34..14b74310dc 100644 --- a/src/add-ons/kernel/file_systems/bindfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/bindfs/Volume.cpp @@ -51,8 +51,8 @@ Volume::Mount(const char* parameterString) { const char* source = NULL; void* parameterHandle = parse_driver_settings_string(parameterString); - CObjectDeleter parameterDeleter(parameterHandle, - delete_driver_settings); + CObjectDeleter + 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/packagefs/volume/PackageFSRoot.cpp b/src/add-ons/kernel/file_systems/packagefs/volume/PackageFSRoot.cpp index affa19912a..096bc8fd22 100644 --- a/src/add-ons/kernel/file_systems/packagefs/volume/PackageFSRoot.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/volume/PackageFSRoot.cpp @@ -114,7 +114,7 @@ PackageFSRoot::RegisterVolume(Volume* volume) relativeRootPath, strerror(error)); RETURN_ERROR(error); } - CObjectDeleter vnodePutter(vnode, &vfs_put_vnode); + CObjectDeleter 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 8fcf2d1114..ad2985e010 100644 --- a/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/volume/PackageSettings.cpp @@ -216,8 +216,8 @@ PackageSettings::Load(dev_t mountPointDeviceID, ino_t mountPointNodeID, void* settingsHandle = load_driver_settings(path.Path()); if (settingsHandle == NULL) return B_ENTRY_NOT_FOUND; - CObjectDeleter settingsDeleter(settingsHandle, - &unload_driver_settings); + CObjectDeleter + 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 a94886da67..9886cea9fa 100644 --- a/src/add-ons/kernel/file_systems/packagefs/volume/Volume.cpp +++ b/src/add-ons/kernel/file_systems/packagefs/volume/Volume.cpp @@ -329,8 +329,8 @@ Volume::Mount(const char* parameterString) NULL); } - CObjectDeleter parameterHandleDeleter(parameterHandle, - &delete_driver_settings); + CObjectDeleter + parameterHandleDeleter(parameterHandle); if (packages != NULL && packages[0] == '\0') { FATAL("invalid package folder ('packages' parameter)!\n"); @@ -711,7 +711,7 @@ Volume::_LoadOldPackagesStates(const char* packagesState) ERROR("Failed to open administrative directory: %s\n", strerror(errno)); RETURN_ERROR(errno); } - CObjectDeleter dirCloser(dir, closedir); + CObjectDeleter dirCloser(dir); while (dirent* entry = readdir(dir)) { if (strncmp(entry->d_name, "state_", 6) != 0 @@ -903,7 +903,7 @@ Volume::_AddInitialPackagesFromDirectory() fPackagesDirectory->Path(), strerror(errno)); RETURN_ERROR(errno); } - CObjectDeleter dirCloser(dir, closedir); + CObjectDeleter dirCloser(dir); while (dirent* entry = readdir(dir)) { // skip "." and ".." @@ -1778,7 +1778,7 @@ Volume::_PublishShineThroughDirectories() _RemoveNode(directory); continue; } - CObjectDeleter vnodePutter(vnode, &vfs_put_vnode); + CObjectDeleter vnodePutter(vnode); // stat it struct stat st; diff --git a/src/add-ons/kernel/network/stack/net_socket.cpp b/src/add-ons/kernel/network/stack/net_socket.cpp index 03297b92d3..25b10ec469 100644 --- a/src/add-ons/kernel/network/stack/net_socket.cpp +++ b/src/add-ons/kernel/network/stack/net_socket.cpp @@ -323,8 +323,9 @@ socket_receive_no_buffer(net_socket* socket, msghdr* header, void* data, if (bytesRead < 0) return bytesRead; - CObjectDeleter ancillaryDataDeleter(ancillaryData, - &delete_ancillary_data_container); + CObjectDeleter< + ancillary_data_container, void, delete_ancillary_data_container> + ancillaryDataDeleter(ancillaryData); // process ancillary data if (header != NULL) { @@ -1346,8 +1347,9 @@ socket_send(net_socket* socket, msghdr* header, const void* data, size_t length, return B_BAD_VALUE; ancillary_data_container* ancillaryData = NULL; - CObjectDeleter ancillaryDataDeleter(NULL, - &delete_ancillary_data_container); + CObjectDeleter< + ancillary_data_container, void, delete_ancillary_data_container> + ancillaryDataDeleter; if (header != NULL) { address = (const sockaddr*)header->msg_name; diff --git a/src/apps/aboutsystem/AboutSystem.cpp b/src/apps/aboutsystem/AboutSystem.cpp index 5e719d667f..f9c6149ede 100644 --- a/src/apps/aboutsystem/AboutSystem.cpp +++ b/src/apps/aboutsystem/AboutSystem.cpp @@ -1463,7 +1463,7 @@ AboutView::_AddCopyrightsFromAttribute() close(attrFD); return; } - CObjectDeleter _(attrFile, fclose); + CObjectDeleter _(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 7f538edd23..f70e549a52 100644 --- a/src/bin/multiuser/multiuser_utils.cpp +++ b/src/bin/multiuser/multiuser_utils.cpp @@ -38,7 +38,7 @@ read_password(const char* prompt, char* password, size_t bufferSize, in = tty; out = tty; } - CObjectDeleter ttyCloser(tty, fclose); + CObjectDeleter ttyCloser(tty); // disable echo int inFD = fileno(in); diff --git a/src/bin/package/PackageWritingUtils.cpp b/src/bin/package/PackageWritingUtils.cpp index 25cbe669e7..ad29dd588d 100644 --- a/src/bin/package/PackageWritingUtils.cpp +++ b/src/bin/package/PackageWritingUtils.cpp @@ -27,7 +27,7 @@ add_current_directory_entries(BPackageWriter& packageWriter, strerror(errno)); return errno; } - CObjectDeleter dirCloser(dir, &closedir); + CObjectDeleter dirCloser(dir); while (dirent* entry = readdir(dir)) { // skip "." and ".." diff --git a/src/bin/ramdisk.cpp b/src/bin/ramdisk.cpp index 4681733d54..bf4dacb49e 100644 --- a/src/bin/ramdisk.cpp +++ b/src/bin/ramdisk.cpp @@ -387,7 +387,7 @@ command_list(int argc, const char* const* argv) strerror(errno)); return 1; } - CObjectDeleter dirCloser(dir, &closedir); + CObjectDeleter 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 ac20487e3e..28957ecf55 100644 --- a/src/kits/package/RepositoryInfo.cpp +++ b/src/kits/package/RepositoryInfo.cpp @@ -360,8 +360,8 @@ BRepositoryInfo::_SetTo(const BEntry& entry) void* settingsHandle = parse_driver_settings_string(configString.String()); if (settingsHandle == NULL) return B_BAD_DATA; - CObjectDeleter settingsHandleDeleter(settingsHandle, - &unload_driver_settings); + CObjectDeleter + 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 94bdb7308d..1cf964df12 100644 --- a/src/kits/package/hpkg/PackageWriterImpl.cpp +++ b/src/kits/package/hpkg/PackageWriterImpl.cpp @@ -1138,7 +1138,7 @@ PackageWriterImpl::_UpdateCheckEntryCollisions(Attribute* parentAttribute, // first we check for colliding node attributes, though if (DIR* attrDir = fs_fopen_attr_dir(fd)) { - CObjectDeleter attrDirCloser(attrDir, fs_close_attr_dir); + CObjectDeleter attrDirCloser(attrDir); while (dirent* entry = fs_read_attr_dir(attrDir)) { attr_info attrInfo; @@ -1184,7 +1184,7 @@ PackageWriterImpl::_UpdateCheckEntryCollisions(Attribute* parentAttribute, close(clonedFD); throw status_t(errno); } - CObjectDeleter dirCloser(dir, closedir); + CObjectDeleter dirCloser(dir); while (dirent* entry = readdir(dir)) { // skip "." and ".." @@ -1525,7 +1525,7 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName, // add attributes if (DIR* attrDir = fs_fopen_attr_dir(fd)) { - CObjectDeleter attrDirCloser(attrDir, fs_close_attr_dir); + CObjectDeleter attrDirCloser(attrDir); while (dirent* entry = fs_read_attr_dir(attrDir)) { attr_info attrInfo; @@ -1586,7 +1586,7 @@ PackageWriterImpl::_AddDirectoryChildren(Entry* entry, int fd, char* pathBuffer) close(clonedFD); throw status_t(errno); } - CObjectDeleter dirCloser(dir, closedir); + CObjectDeleter 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 26e503eaf5..dcfaec7520 100644 --- a/src/kits/package/manager/RepositoryBuilder.cpp +++ b/src/kits/package/manager/RepositoryBuilder.cpp @@ -210,7 +210,7 @@ BRepositoryBuilder::AddPackagesDirectory(const char* path) DIR* dir = opendir(path); if (dir == NULL) DIE(errno, "failed to open package directory \"%s\"", path); - CObjectDeleter dirCloser(dir, &closedir); + CObjectDeleter dirCloser(dir); // iterate through directory entries while (dirent* entry = readdir(dir)) { diff --git a/src/kits/package/solver/libsolv/LibsolvSolver.cpp b/src/kits/package/solver/libsolv/LibsolvSolver.cpp index c8bd167395..78eb11bd94 100644 --- a/src/kits/package/solver/libsolv/LibsolvSolver.cpp +++ b/src/kits/package/solver/libsolv/LibsolvSolver.cpp @@ -560,8 +560,8 @@ LibsolvSolver::GetResult(BSolverResult& _result) _result.MakeEmpty(); Transaction* transaction = solver_create_transaction(fSolver); - CObjectDeleter transactionDeleter(transaction, - &transaction_free); + CObjectDeleter + transactionDeleter(transaction); if (transaction->steps.count == 0) return B_OK; diff --git a/src/preferences/virtualmemory/Settings.cpp b/src/preferences/virtualmemory/Settings.cpp index 3923544c07..a0b32d3450 100644 --- a/src/preferences/virtualmemory/Settings.cpp +++ b/src/preferences/virtualmemory/Settings.cpp @@ -139,8 +139,8 @@ Settings::ReadSwapSettings() void* settings = load_driver_settings(kVirtualMemorySettings); if (settings == NULL) return kErrorSettingsNotFound; - CObjectDeleter settingDeleter(settings, - &unload_driver_settings); + CObjectDeleter + 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 f8fa1072c3..fe6eee95d8 100644 --- a/src/servers/registrar/AuthenticationManager.cpp +++ b/src/servers/registrar/AuthenticationManager.cpp @@ -568,14 +568,14 @@ public: debug_printf("REG: Failed to open passwd file \"%s\" for " "writing: %s\n", kPasswdFile, strerror(errno)); } - CObjectDeleter _1(passwdFile, fclose); + CObjectDeleter _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 _2(shadowFile, fclose); + CObjectDeleter _2(shadowFile); // write users for (map::const_iterator it = fUsersByID.begin(); @@ -694,7 +694,7 @@ public: debug_printf("REG: Failed to open group file \"%s\" for " "writing: %s\n", kGroupFile, strerror(errno)); } - CObjectDeleter _1(groupFile, fclose); + CObjectDeleter _1(groupFile); // write groups for (map::const_iterator it = fGroupsByID.begin(); @@ -1245,7 +1245,7 @@ AuthenticationManager::_InitPasswdDB() kPasswdFile, strerror(errno)); return errno; } - CObjectDeleter _(file, fclose); + CObjectDeleter _(file); char lineBuffer[LINE_MAX]; while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) { @@ -1294,7 +1294,7 @@ AuthenticationManager::_InitGroupDB() kGroupFile, strerror(errno)); return errno; } - CObjectDeleter _(file, fclose); + CObjectDeleter _(file); char lineBuffer[LINE_MAX]; while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) { @@ -1342,7 +1342,7 @@ AuthenticationManager::_InitShadowPwdDB() kShadowPwdFile, strerror(errno)); return errno; } - CObjectDeleter _(file, fclose); + CObjectDeleter _(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 c30b8822f5..736b0729c6 100644 --- a/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp +++ b/src/system/boot/loader/file_systems/packagefs/PackageSettingsItem.cpp @@ -54,8 +54,8 @@ PackageSettingsItem::Load(::Directory* systemDirectory, const char* name) void* settingsHandle = load_driver_settings_file(fd); if (settingsHandle == NULL) return NULL; - CObjectDeleter settingsDeleter(settingsHandle, - &unload_driver_settings); + CObjectDeleter + settingsDeleter(settingsHandle); const driver_settings* settings = get_driver_settings(settingsHandle); for (int i = 0; i < settings->parameter_count; i++) { diff --git a/src/system/boot/loader/vfs.cpp b/src/system/boot/loader/vfs.cpp index 2a57686bde..4996fd159f 100644 --- a/src/system/boot/loader/vfs.cpp +++ b/src/system/boot/loader/vfs.cpp @@ -576,8 +576,8 @@ BootVolume::_OpenSystemPackage() Node* packagesNode = fSystemDirectory->Lookup("packages", false); if (packagesNode == NULL) return -1; - MethodDeleter packagesNodeReleaser(packagesNode, - &Node::Release); + MethodDeleter + packagesNodeReleaser(packagesNode); if (!S_ISDIR(packagesNode->Type())) return -1; @@ -1172,7 +1172,7 @@ open_directory(Directory* baseDirectory, const char* path) errno = error; return NULL; } - MethodDeleter nodeReleaser(node, &Node::Release); + MethodDeleter nodeReleaser(node); if (!S_ISDIR(node->Type())) { errno = error; diff --git a/src/system/kernel/arch/x86/ioapic.cpp b/src/system/kernel/arch/x86/ioapic.cpp index 45212cfca4..5e1edb1d70 100644 --- a/src/system/kernel/arch/x86/ioapic.cpp +++ b/src/system/kernel/arch/x86/ioapic.cpp @@ -706,8 +706,8 @@ ioapic_init(kernel_args* args) dprintf("acpi module not available, not configuring io-apics\n"); return; } - BPrivate::CObjectDeleter - acpiModulePutter(B_ACPI_MODULE_NAME, put_module); + BPrivate::CObjectDeleter + acpiModulePutter(B_ACPI_MODULE_NAME); acpi_table_madt* madt = NULL; if (acpiModule->get_table(ACPI_SIG_MADT, 0, (void**)&madt) != B_OK) { diff --git a/src/system/kernel/device_manager/device_manager.cpp b/src/system/kernel/device_manager/device_manager.cpp index e8bb4c2eec..9b87496f09 100644 --- a/src/system/kernel/device_manager/device_manager.cpp +++ b/src/system/kernel/device_manager/device_manager.cpp @@ -767,7 +767,8 @@ unpublish_device(device_node *node, const char *path) status_t error = devfs_get_device(path, baseDevice); if (error != B_OK) return error; - CObjectDeleter baseDevicePutter(baseDevice, &devfs_put_device); + CObjectDeleter + baseDevicePutter(baseDevice); Device* device = dynamic_cast(baseDevice); if (device == NULL || device->Node() != node) diff --git a/src/system/kernel/fs/fd.cpp b/src/system/kernel/fs/fd.cpp index 607d416ba0..90f267244a 100644 --- a/src/system/kernel/fs/fd.cpp +++ b/src/system/kernel/fs/fd.cpp @@ -497,7 +497,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 descriptorPutter(descriptor, put_fd); + CObjectDeleter 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 ffd05a75c2..2d79d80d9e 100644 --- a/src/system/kernel/fs/vfs_request_io.cpp +++ b/src/system/kernel/fs/vfs_request_io.cpp @@ -478,7 +478,7 @@ do_fd_io(int fd, io_request* request) return B_FILE_ERROR; } - CObjectDeleter descriptorPutter(descriptor, put_fd); + CObjectDeleter descriptorPutter(descriptor); return vfs_vnode_io(vnode, descriptor->cookie, request); } @@ -500,7 +500,7 @@ do_iterative_fd_io(int fd, io_request* request, iterative_io_get_vecs getVecs, return B_FILE_ERROR; } - CObjectDeleter descriptorPutter(descriptor, put_fd); + CObjectDeleter descriptorPutter(descriptor); if (!HAS_FS_CALL(vnode, io)) { // no io() call -- fall back to synchronous I/O diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index e791a27c30..f3e85edc1d 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -4426,8 +4426,8 @@ _user_get_extended_team_info(team_id teamID, uint32 flags, void* buffer, ioContext = team->io_context; vfs_get_io_context(ioContext); } - CObjectDeleter ioContextPutter(ioContext, - &vfs_put_io_context); + CObjectDeleter + ioContextPutter(ioContext); // add the basic data to the info message if (info.AddInt32("id", teamClone.id) != B_OK diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 4bdea39e3e..4d61a272b1 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -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 vnodePutter(vnode, vfs_put_vnode); + CObjectDeleter vnodePutter(vnode); // If we're going to pre-map pages, we need to reserve the pages needed by // the mapping backend upfront. diff --git a/src/tools/hvif2png/hvif2png.cpp b/src/tools/hvif2png/hvif2png.cpp index 18f5cccbdd..4f0f7779b7 100644 --- a/src/tools/hvif2png/hvif2png.cpp +++ b/src/tools/hvif2png/hvif2png.cpp @@ -92,7 +92,7 @@ h2p_close_state(h2p_state* state) static bool h2p_open_streams(h2p_state* state) { - CObjectDeleter stateCloser(state, &h2p_close_state); + CObjectDeleter stateCloser(state); if (state->params.in_filename != NULL) state->in = fopen(state->params.in_filename, "rb");