fix build after CObjectDeleter interface change

Change-Id: I76e217abcd13c22c4d68170e07333cdde4d7a891
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3461
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
X512 2020-12-04 22:21:45 +09:00 committed by Adrien Destugues
parent 71e79db9b8
commit 36aafa560b
25 changed files with 54 additions and 51 deletions

View File

@ -1372,7 +1372,7 @@ bfs_open(fs_volume* _volume, fs_vnode* _node, int openMode, void** _cookie)
cookie->last_notification = system_time(); cookie->last_notification = system_time();
// Disable the file cache, if requested? // Disable the file cache, if requested?
CObjectDeleter<void> fileCacheEnabler(file_cache_enable); CObjectDeleter<void, void, file_cache_enable> fileCacheEnabler;
if ((openMode & O_NOCACHE) != 0 && inode->FileCache() != NULL) { if ((openMode & O_NOCACHE) != 0 && inode->FileCache() != NULL) {
status = file_cache_disable(inode->FileCache()); status = file_cache_disable(inode->FileCache());
if (status != B_OK) if (status != B_OK)

View File

@ -51,8 +51,8 @@ Volume::Mount(const char* parameterString)
{ {
const char* source = NULL; const char* source = NULL;
void* parameterHandle = parse_driver_settings_string(parameterString); void* parameterHandle = parse_driver_settings_string(parameterString);
CObjectDeleter<void, status_t> parameterDeleter(parameterHandle, CObjectDeleter<void, status_t, delete_driver_settings>
delete_driver_settings); parameterDeleter(parameterHandle);
if (parameterHandle != NULL) if (parameterHandle != NULL)
source = get_driver_parameter(parameterHandle, "source", NULL, NULL); source = get_driver_parameter(parameterHandle, "source", NULL, NULL);
if (source == NULL || source[0] == '\0') { if (source == NULL || source[0] == '\0') {

View File

@ -114,7 +114,7 @@ PackageFSRoot::RegisterVolume(Volume* volume)
relativeRootPath, strerror(error)); relativeRootPath, strerror(error));
RETURN_ERROR(error); RETURN_ERROR(error);
} }
CObjectDeleter<struct vnode> vnodePutter(vnode, &vfs_put_vnode); CObjectDeleter<struct vnode, void, vfs_put_vnode> vnodePutter(vnode);
// stat it // stat it
struct stat st; struct stat st;

View File

@ -216,8 +216,8 @@ PackageSettings::Load(dev_t mountPointDeviceID, ino_t mountPointNodeID,
void* settingsHandle = load_driver_settings(path.Path()); void* settingsHandle = load_driver_settings(path.Path());
if (settingsHandle == NULL) if (settingsHandle == NULL)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
CObjectDeleter<void, status_t> settingsDeleter(settingsHandle, CObjectDeleter<void, status_t, unload_driver_settings>
&unload_driver_settings); settingsDeleter(settingsHandle);
const driver_settings* settings = get_driver_settings(settingsHandle); const driver_settings* settings = get_driver_settings(settingsHandle);
for (int i = 0; i < settings->parameter_count; i++) { for (int i = 0; i < settings->parameter_count; i++) {

View File

@ -329,8 +329,8 @@ Volume::Mount(const char* parameterString)
NULL); NULL);
} }
CObjectDeleter<void, status_t> parameterHandleDeleter(parameterHandle, CObjectDeleter<void, status_t, delete_driver_settings>
&delete_driver_settings); parameterHandleDeleter(parameterHandle);
if (packages != NULL && packages[0] == '\0') { if (packages != NULL && packages[0] == '\0') {
FATAL("invalid package folder ('packages' parameter)!\n"); 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)); ERROR("Failed to open administrative directory: %s\n", strerror(errno));
RETURN_ERROR(errno); RETURN_ERROR(errno);
} }
CObjectDeleter<DIR, int> dirCloser(dir, closedir); CObjectDeleter<DIR, int, closedir> dirCloser(dir);
while (dirent* entry = readdir(dir)) { while (dirent* entry = readdir(dir)) {
if (strncmp(entry->d_name, "state_", 6) != 0 if (strncmp(entry->d_name, "state_", 6) != 0
@ -903,7 +903,7 @@ Volume::_AddInitialPackagesFromDirectory()
fPackagesDirectory->Path(), strerror(errno)); fPackagesDirectory->Path(), strerror(errno));
RETURN_ERROR(errno); RETURN_ERROR(errno);
} }
CObjectDeleter<DIR, int> dirCloser(dir, closedir); CObjectDeleter<DIR, int, closedir> dirCloser(dir);
while (dirent* entry = readdir(dir)) { while (dirent* entry = readdir(dir)) {
// skip "." and ".." // skip "." and ".."
@ -1778,7 +1778,7 @@ Volume::_PublishShineThroughDirectories()
_RemoveNode(directory); _RemoveNode(directory);
continue; continue;
} }
CObjectDeleter<struct vnode> vnodePutter(vnode, &vfs_put_vnode); CObjectDeleter<struct vnode, void, vfs_put_vnode> vnodePutter(vnode);
// stat it // stat it
struct stat st; struct stat st;

View File

@ -323,8 +323,9 @@ socket_receive_no_buffer(net_socket* socket, msghdr* header, void* data,
if (bytesRead < 0) if (bytesRead < 0)
return bytesRead; return bytesRead;
CObjectDeleter<ancillary_data_container> ancillaryDataDeleter(ancillaryData, CObjectDeleter<
&delete_ancillary_data_container); ancillary_data_container, void, delete_ancillary_data_container>
ancillaryDataDeleter(ancillaryData);
// process ancillary data // process ancillary data
if (header != NULL) { if (header != NULL) {
@ -1346,8 +1347,9 @@ socket_send(net_socket* socket, msghdr* header, const void* data, size_t length,
return B_BAD_VALUE; return B_BAD_VALUE;
ancillary_data_container* ancillaryData = NULL; ancillary_data_container* ancillaryData = NULL;
CObjectDeleter<ancillary_data_container> ancillaryDataDeleter(NULL, CObjectDeleter<
&delete_ancillary_data_container); ancillary_data_container, void, delete_ancillary_data_container>
ancillaryDataDeleter;
if (header != NULL) { if (header != NULL) {
address = (const sockaddr*)header->msg_name; address = (const sockaddr*)header->msg_name;

View File

@ -1463,7 +1463,7 @@ AboutView::_AddCopyrightsFromAttribute()
close(attrFD); close(attrFD);
return; return;
} }
CObjectDeleter<FILE, int> _(attrFile, fclose); CObjectDeleter<FILE, int, fclose> _(attrFile);
// read and parse the copyrights // read and parse the copyrights
BMessage package; BMessage package;

View File

@ -38,7 +38,7 @@ read_password(const char* prompt, char* password, size_t bufferSize,
in = tty; in = tty;
out = tty; out = tty;
} }
CObjectDeleter<FILE, int> ttyCloser(tty, fclose); CObjectDeleter<FILE, int, fclose> ttyCloser(tty);
// disable echo // disable echo
int inFD = fileno(in); int inFD = fileno(in);

View File

@ -27,7 +27,7 @@ add_current_directory_entries(BPackageWriter& packageWriter,
strerror(errno)); strerror(errno));
return errno; return errno;
} }
CObjectDeleter<DIR, int> dirCloser(dir, &closedir); CObjectDeleter<DIR, int, closedir> dirCloser(dir);
while (dirent* entry = readdir(dir)) { while (dirent* entry = readdir(dir)) {
// skip "." and ".." // skip "." and ".."

View File

@ -387,7 +387,7 @@ command_list(int argc, const char* const* argv)
strerror(errno)); strerror(errno));
return 1; return 1;
} }
CObjectDeleter<DIR, int> dirCloser(dir, &closedir); CObjectDeleter<DIR, int, closedir> dirCloser(dir);
TextTable table; TextTable table;
table.AddColumn("ID", B_ALIGN_RIGHT); table.AddColumn("ID", B_ALIGN_RIGHT);

View File

@ -360,8 +360,8 @@ BRepositoryInfo::_SetTo(const BEntry& entry)
void* settingsHandle = parse_driver_settings_string(configString.String()); void* settingsHandle = parse_driver_settings_string(configString.String());
if (settingsHandle == NULL) if (settingsHandle == NULL)
return B_BAD_DATA; return B_BAD_DATA;
CObjectDeleter<void, status_t> settingsHandleDeleter(settingsHandle, CObjectDeleter<void, status_t, unload_driver_settings>
&unload_driver_settings); settingsHandleDeleter(settingsHandle);
const char* name = get_driver_parameter(settingsHandle, "name", NULL, NULL); const char* name = get_driver_parameter(settingsHandle, "name", NULL, NULL);
const char* identifier = get_driver_parameter(settingsHandle, "identifier", NULL, NULL); const char* identifier = get_driver_parameter(settingsHandle, "identifier", NULL, NULL);

View File

@ -1138,7 +1138,7 @@ PackageWriterImpl::_UpdateCheckEntryCollisions(Attribute* parentAttribute,
// first we check for colliding node attributes, though // first we check for colliding node attributes, though
if (DIR* attrDir = fs_fopen_attr_dir(fd)) { if (DIR* attrDir = fs_fopen_attr_dir(fd)) {
CObjectDeleter<DIR, int> attrDirCloser(attrDir, fs_close_attr_dir); CObjectDeleter<DIR, int, fs_close_attr_dir> attrDirCloser(attrDir);
while (dirent* entry = fs_read_attr_dir(attrDir)) { while (dirent* entry = fs_read_attr_dir(attrDir)) {
attr_info attrInfo; attr_info attrInfo;
@ -1184,7 +1184,7 @@ PackageWriterImpl::_UpdateCheckEntryCollisions(Attribute* parentAttribute,
close(clonedFD); close(clonedFD);
throw status_t(errno); throw status_t(errno);
} }
CObjectDeleter<DIR, int> dirCloser(dir, closedir); CObjectDeleter<DIR, int, closedir> dirCloser(dir);
while (dirent* entry = readdir(dir)) { while (dirent* entry = readdir(dir)) {
// skip "." and ".." // skip "." and ".."
@ -1525,7 +1525,7 @@ PackageWriterImpl::_AddEntry(int dirFD, Entry* entry, const char* fileName,
// add attributes // add attributes
if (DIR* attrDir = fs_fopen_attr_dir(fd)) { if (DIR* attrDir = fs_fopen_attr_dir(fd)) {
CObjectDeleter<DIR, int> attrDirCloser(attrDir, fs_close_attr_dir); CObjectDeleter<DIR, int, fs_close_attr_dir> attrDirCloser(attrDir);
while (dirent* entry = fs_read_attr_dir(attrDir)) { while (dirent* entry = fs_read_attr_dir(attrDir)) {
attr_info attrInfo; attr_info attrInfo;
@ -1586,7 +1586,7 @@ PackageWriterImpl::_AddDirectoryChildren(Entry* entry, int fd, char* pathBuffer)
close(clonedFD); close(clonedFD);
throw status_t(errno); throw status_t(errno);
} }
CObjectDeleter<DIR, int> dirCloser(dir, closedir); CObjectDeleter<DIR, int, closedir> dirCloser(dir);
while (dirent* entry = readdir(dir)) { while (dirent* entry = readdir(dir)) {
// skip "." and ".." // skip "." and ".."

View File

@ -210,7 +210,7 @@ BRepositoryBuilder::AddPackagesDirectory(const char* path)
DIR* dir = opendir(path); DIR* dir = opendir(path);
if (dir == NULL) if (dir == NULL)
DIE(errno, "failed to open package directory \"%s\"", path); DIE(errno, "failed to open package directory \"%s\"", path);
CObjectDeleter<DIR, int> dirCloser(dir, &closedir); CObjectDeleter<DIR, int, closedir> dirCloser(dir);
// iterate through directory entries // iterate through directory entries
while (dirent* entry = readdir(dir)) { while (dirent* entry = readdir(dir)) {

View File

@ -560,8 +560,8 @@ LibsolvSolver::GetResult(BSolverResult& _result)
_result.MakeEmpty(); _result.MakeEmpty();
Transaction* transaction = solver_create_transaction(fSolver); Transaction* transaction = solver_create_transaction(fSolver);
CObjectDeleter<Transaction> transactionDeleter(transaction, CObjectDeleter<Transaction, void, transaction_free>
&transaction_free); transactionDeleter(transaction);
if (transaction->steps.count == 0) if (transaction->steps.count == 0)
return B_OK; return B_OK;

View File

@ -139,8 +139,8 @@ Settings::ReadSwapSettings()
void* settings = load_driver_settings(kVirtualMemorySettings); void* settings = load_driver_settings(kVirtualMemorySettings);
if (settings == NULL) if (settings == NULL)
return kErrorSettingsNotFound; return kErrorSettingsNotFound;
CObjectDeleter<void, status_t> settingDeleter(settings, CObjectDeleter<void, status_t, unload_driver_settings>
&unload_driver_settings); settingDeleter(settings);
const char* enabled = get_driver_parameter(settings, "vm", NULL, NULL); const char* enabled = get_driver_parameter(settings, "vm", NULL, NULL);
const char* automatic = get_driver_parameter(settings, "swap_auto", const char* automatic = get_driver_parameter(settings, "swap_auto",

View File

@ -568,14 +568,14 @@ public:
debug_printf("REG: Failed to open passwd file \"%s\" for " debug_printf("REG: Failed to open passwd file \"%s\" for "
"writing: %s\n", kPasswdFile, strerror(errno)); "writing: %s\n", kPasswdFile, strerror(errno));
} }
CObjectDeleter<FILE, int> _1(passwdFile, fclose); CObjectDeleter<FILE, int, fclose> _1(passwdFile);
FILE* shadowFile = fopen(kShadowPwdFile, "w"); FILE* shadowFile = fopen(kShadowPwdFile, "w");
if (shadowFile == NULL) { if (shadowFile == NULL) {
debug_printf("REG: Failed to open shadow passwd file \"%s\" for " debug_printf("REG: Failed to open shadow passwd file \"%s\" for "
"writing: %s\n", kShadowPwdFile, strerror(errno)); "writing: %s\n", kShadowPwdFile, strerror(errno));
} }
CObjectDeleter<FILE, int> _2(shadowFile, fclose); CObjectDeleter<FILE, int, fclose> _2(shadowFile);
// write users // write users
for (map<uid_t, User*>::const_iterator it = fUsersByID.begin(); for (map<uid_t, User*>::const_iterator it = fUsersByID.begin();
@ -694,7 +694,7 @@ public:
debug_printf("REG: Failed to open group file \"%s\" for " debug_printf("REG: Failed to open group file \"%s\" for "
"writing: %s\n", kGroupFile, strerror(errno)); "writing: %s\n", kGroupFile, strerror(errno));
} }
CObjectDeleter<FILE, int> _1(groupFile, fclose); CObjectDeleter<FILE, int, fclose> _1(groupFile);
// write groups // write groups
for (map<gid_t, Group*>::const_iterator it = fGroupsByID.begin(); for (map<gid_t, Group*>::const_iterator it = fGroupsByID.begin();
@ -1245,7 +1245,7 @@ AuthenticationManager::_InitPasswdDB()
kPasswdFile, strerror(errno)); kPasswdFile, strerror(errno));
return errno; return errno;
} }
CObjectDeleter<FILE, int> _(file, fclose); CObjectDeleter<FILE, int, fclose> _(file);
char lineBuffer[LINE_MAX]; char lineBuffer[LINE_MAX];
while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) { while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) {
@ -1294,7 +1294,7 @@ AuthenticationManager::_InitGroupDB()
kGroupFile, strerror(errno)); kGroupFile, strerror(errno));
return errno; return errno;
} }
CObjectDeleter<FILE, int> _(file, fclose); CObjectDeleter<FILE, int, fclose> _(file);
char lineBuffer[LINE_MAX]; char lineBuffer[LINE_MAX];
while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) { while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) {
@ -1342,7 +1342,7 @@ AuthenticationManager::_InitShadowPwdDB()
kShadowPwdFile, strerror(errno)); kShadowPwdFile, strerror(errno));
return errno; return errno;
} }
CObjectDeleter<FILE, int> _(file, fclose); CObjectDeleter<FILE, int, fclose> _(file);
char lineBuffer[LINE_MAX]; char lineBuffer[LINE_MAX];
while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) { while (char* line = fgets(lineBuffer, sizeof(lineBuffer), file)) {

View File

@ -54,8 +54,8 @@ PackageSettingsItem::Load(::Directory* systemDirectory, const char* name)
void* settingsHandle = load_driver_settings_file(fd); void* settingsHandle = load_driver_settings_file(fd);
if (settingsHandle == NULL) if (settingsHandle == NULL)
return NULL; return NULL;
CObjectDeleter<void, status_t> settingsDeleter(settingsHandle, CObjectDeleter<void, status_t, &unload_driver_settings>
&unload_driver_settings); settingsDeleter(settingsHandle);
const driver_settings* settings = get_driver_settings(settingsHandle); const driver_settings* settings = get_driver_settings(settingsHandle);
for (int i = 0; i < settings->parameter_count; i++) { for (int i = 0; i < settings->parameter_count; i++) {

View File

@ -576,8 +576,8 @@ BootVolume::_OpenSystemPackage()
Node* packagesNode = fSystemDirectory->Lookup("packages", false); Node* packagesNode = fSystemDirectory->Lookup("packages", false);
if (packagesNode == NULL) if (packagesNode == NULL)
return -1; return -1;
MethodDeleter<Node, status_t> packagesNodeReleaser(packagesNode, MethodDeleter<Node, status_t, &Node::Release>
&Node::Release); packagesNodeReleaser(packagesNode);
if (!S_ISDIR(packagesNode->Type())) if (!S_ISDIR(packagesNode->Type()))
return -1; return -1;
@ -1172,7 +1172,7 @@ open_directory(Directory* baseDirectory, const char* path)
errno = error; errno = error;
return NULL; return NULL;
} }
MethodDeleter<Node, status_t> nodeReleaser(node, &Node::Release); MethodDeleter<Node, status_t, &Node::Release> nodeReleaser(node);
if (!S_ISDIR(node->Type())) { if (!S_ISDIR(node->Type())) {
errno = error; errno = error;

View File

@ -706,8 +706,8 @@ ioapic_init(kernel_args* args)
dprintf("acpi module not available, not configuring io-apics\n"); dprintf("acpi module not available, not configuring io-apics\n");
return; return;
} }
BPrivate::CObjectDeleter<const char, status_t> BPrivate::CObjectDeleter<const char, status_t, put_module>
acpiModulePutter(B_ACPI_MODULE_NAME, put_module); acpiModulePutter(B_ACPI_MODULE_NAME);
acpi_table_madt* madt = NULL; acpi_table_madt* madt = NULL;
if (acpiModule->get_table(ACPI_SIG_MADT, 0, (void**)&madt) != B_OK) { if (acpiModule->get_table(ACPI_SIG_MADT, 0, (void**)&madt) != B_OK) {

View File

@ -767,7 +767,8 @@ unpublish_device(device_node *node, const char *path)
status_t error = devfs_get_device(path, baseDevice); status_t error = devfs_get_device(path, baseDevice);
if (error != B_OK) if (error != B_OK)
return error; return error;
CObjectDeleter<BaseDevice> baseDevicePutter(baseDevice, &devfs_put_device); CObjectDeleter<BaseDevice, void, devfs_put_device>
baseDevicePutter(baseDevice);
Device* device = dynamic_cast<Device*>(baseDevice); Device* device = dynamic_cast<Device*>(baseDevice);
if (device == NULL || device->Node() != node) if (device == NULL || device->Node() != node)

View File

@ -497,7 +497,7 @@ dup_foreign_fd(team_id fromTeam, int fd, bool kernel)
file_descriptor* descriptor = get_fd(fromContext, fd); file_descriptor* descriptor = get_fd(fromContext, fd);
if (descriptor == NULL) if (descriptor == NULL)
return B_FILE_ERROR; return B_FILE_ERROR;
CObjectDeleter<file_descriptor> descriptorPutter(descriptor, put_fd); CObjectDeleter<file_descriptor, void, put_fd> descriptorPutter(descriptor);
// create a new FD in the target I/O context // create a new FD in the target I/O context
int result = new_fd(get_current_io_context(kernel), descriptor); int result = new_fd(get_current_io_context(kernel), descriptor);

View File

@ -478,7 +478,7 @@ do_fd_io(int fd, io_request* request)
return B_FILE_ERROR; return B_FILE_ERROR;
} }
CObjectDeleter<file_descriptor> descriptorPutter(descriptor, put_fd); CObjectDeleter<file_descriptor, void, put_fd> descriptorPutter(descriptor);
return vfs_vnode_io(vnode, descriptor->cookie, request); 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; return B_FILE_ERROR;
} }
CObjectDeleter<file_descriptor> descriptorPutter(descriptor, put_fd); CObjectDeleter<file_descriptor, void, put_fd> descriptorPutter(descriptor);
if (!HAS_FS_CALL(vnode, io)) { if (!HAS_FS_CALL(vnode, io)) {
// no io() call -- fall back to synchronous I/O // no io() call -- fall back to synchronous I/O

View File

@ -4426,8 +4426,8 @@ _user_get_extended_team_info(team_id teamID, uint32 flags, void* buffer,
ioContext = team->io_context; ioContext = team->io_context;
vfs_get_io_context(ioContext); vfs_get_io_context(ioContext);
} }
CObjectDeleter<io_context> ioContextPutter(ioContext, CObjectDeleter<io_context, void, vfs_put_io_context>
&vfs_put_io_context); ioContextPutter(ioContext);
// add the basic data to the info message // add the basic data to the info message
if (info.AddInt32("id", teamClone.id) != B_OK if (info.AddInt32("id", teamClone.id) != B_OK

View File

@ -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); status_t status = vfs_get_vnode_from_fd(fd, kernel, &vnode);
if (status < B_OK) if (status < B_OK)
return status; return status;
CObjectDeleter<struct vnode> vnodePutter(vnode, vfs_put_vnode); CObjectDeleter<struct vnode, void, vfs_put_vnode> vnodePutter(vnode);
// If we're going to pre-map pages, we need to reserve the pages needed by // If we're going to pre-map pages, we need to reserve the pages needed by
// the mapping backend upfront. // the mapping backend upfront.

View File

@ -92,7 +92,7 @@ h2p_close_state(h2p_state* state)
static bool static bool
h2p_open_streams(h2p_state* state) h2p_open_streams(h2p_state* state)
{ {
CObjectDeleter<h2p_state> stateCloser(state, &h2p_close_state); CObjectDeleter<h2p_state, void, &h2p_close_state> stateCloser(state);
if (state->params.in_filename != NULL) if (state->params.in_filename != NULL)
state->in = fopen(state->params.in_filename, "rb"); state->in = fopen(state->params.in_filename, "rb");