From 5c2ed45f8542bb73ff84087a04181a87a4bca67a Mon Sep 17 00:00:00 2001 From: Philipp Storz Date: Thu, 15 Sep 2022 18:24:25 +0200 Subject: [PATCH] adaptions for win32 --- core/src/findlib/bfile.h | 2 +- core/src/lib/CMakeLists.txt | 5 +++++ core/src/lib/bpoll.cc | 6 +++-- core/src/lib/daemon.cc | 6 ++--- core/src/lib/guid_to_name.cc | 6 +++-- core/src/lib/mntent_cache.cc | 11 ++++----- core/src/lib/priv.cc | 6 +++-- core/src/stored/ndmp_tape.cc | 4 ++-- core/src/win32/compat/compat.cc | 37 +++++++++++++++++++++++-------- core/src/win32/compat/winapi.cc | 4 ++-- core/src/win32/generic/main.cc | 4 ++-- core/src/win32/generic/service.cc | 7 +++--- 12 files changed, 65 insertions(+), 33 deletions(-) diff --git a/core/src/findlib/bfile.h b/core/src/findlib/bfile.h index 8ee8fa67af0..8ceaed322bd 100644 --- a/core/src/findlib/bfile.h +++ b/core/src/findlib/bfile.h @@ -85,7 +85,7 @@ struct BareosWinFilePacket { int BErrNo = 0; /**< errno */ boffset_t offset = 0; /**< Delta offset */ JobControlRecord* jcr = nullptr; /**< jcr for editing job codes */ - PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32Decomplugin_private_context{0}; /**< context for decomposition + PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32Decomplugin_private_context{}; /**< context for decomposition of win32 backup streams */ int use_backup_decomp = 0; /**< set if using BackupRead Stream Decomposition */ bool reparse_point = false; /**< set if reparse point */ diff --git a/core/src/lib/CMakeLists.txt b/core/src/lib/CMakeLists.txt index 85d9ad60d84..b086277b201 100644 --- a/core/src/lib/CMakeLists.txt +++ b/core/src/lib/CMakeLists.txt @@ -113,6 +113,11 @@ if(HAVE_WIN32) set_source_files_properties( ../win32/compat/glob.cc PROPERTIES COMPILE_DEFINITIONS register= ) + set_source_files_properties( + ../win32/compat/winapi.cc ../win32/compat/service.cc + ../win32/generic/service.cc osinfo_win32.cc + PROPERTIES COMPILE_FLAGS -Wno-cast-function-type + ) else() list(APPEND BAREOS_SRCS scsi_tapealert.cc) diff --git a/core/src/lib/bpoll.cc b/core/src/lib/bpoll.cc index f3bb147e72e..cee892ed28b 100644 --- a/core/src/lib/bpoll.cc +++ b/core/src/lib/bpoll.cc @@ -2,7 +2,7 @@ BAREOS® - Backup Archiving REcovery Open Sourced Copyright (C) 2011-2012 Planets Communications B.V. - Copyright (C) 2013-2018 Bareos GmbH & Co. KG + Copyright (C) 2013-2022 Bareos GmbH & Co. KG This program is Free Software; you can redistribute it and/or modify it under the terms of version three of the GNU Affero General Public @@ -151,7 +151,9 @@ int WaitForReadableFd(int fd, int msec, bool ignore_interupts) * 0 if timeout * -1 if error */ -int WaitForWritableFd(int fd, int msec, bool ignore_interupts) +int WaitForWritableFd([[maybe_unused]] int fd, + [[maybe_unused]] int msec, + [[maybe_unused]] bool ignore_interupts) { # if defined(HAVE_WIN32) return 1; diff --git a/core/src/lib/daemon.cc b/core/src/lib/daemon.cc index ef0b0f4a423..6633a9be254 100644 --- a/core/src/lib/daemon.cc +++ b/core/src/lib/daemon.cc @@ -38,9 +38,9 @@ #if defined(HAVE_WIN32) -void daemon_start(const char* progname, - int pidfile_fd, - std::string pidfile_path) +void daemon_start([[maybe_unused]] const char* progname, + [[maybe_unused]] int pidfile_fd, + [[maybe_unused]] std::string pidfile_path) { return; } diff --git a/core/src/lib/guid_to_name.cc b/core/src/lib/guid_to_name.cc index b7e26de65a1..06112cd6f2b 100644 --- a/core/src/lib/guid_to_name.cc +++ b/core/src/lib/guid_to_name.cc @@ -94,7 +94,8 @@ static int GidCompare(guitem* item1, guitem* item2) } -static void GetUidname(uid_t uid, guitem* item) +static void GetUidname([[maybe_unused]] uid_t uid, + [[maybe_unused]] guitem* item) { #ifndef HAVE_WIN32 struct passwd* pwbuf; @@ -107,7 +108,8 @@ static void GetUidname(uid_t uid, guitem* item) #endif } -static void GetGidname(gid_t gid, guitem* item) +static void GetGidname([[maybe_unused]] gid_t gid, + [[maybe_unused]] guitem* item) { #ifndef HAVE_WIN32 struct group* grbuf; diff --git a/core/src/lib/mntent_cache.cc b/core/src/lib/mntent_cache.cc index 5799c67a354..12c98b6bb06 100644 --- a/core/src/lib/mntent_cache.cc +++ b/core/src/lib/mntent_cache.cc @@ -223,11 +223,12 @@ static inline bool SkipFstype(const char* fstype) * This function should be called with a write lock on the mntent_cache. */ static void refresh_mount_cache( - mntent_cache_entry_t* handle_entry(uint32_t dev, - const char* special, - const char* mountpoint, - const char* fstype, - const char* mntopts)) + [[maybe_unused]] mntent_cache_entry_t* handle_entry( + [[maybe_unused]] uint32_t dev, + [[maybe_unused]] const char* special, + [[maybe_unused]] const char* mountpoint, + [[maybe_unused]] const char* fstype, + [[maybe_unused]] const char* mntopts)) { #if defined(HAVE_GETMNTENT) FILE* fp; diff --git a/core/src/lib/priv.cc b/core/src/lib/priv.cc index cd6c2b5dace..4694c07ed29 100644 --- a/core/src/lib/priv.cc +++ b/core/src/lib/priv.cc @@ -2,7 +2,7 @@ BAREOS® - Backup Archiving REcovery Open Sourced Copyright (C) 2000-2011 Free Software Foundation Europe e.V. - Copyright (C) 2013-2021 Bareos GmbH & Co. KG + Copyright (C) 2013-2022 Bareos GmbH & Co. KG This program is Free Software; you can redistribute it and/or modify it under the terms of version three of the GNU Affero General Public @@ -44,7 +44,9 @@ extern "C" int initgroups(const char*, int); * Lower privileges by switching to new UID and GID if non-NULL. * If requested, keep readall capabilities after switch. */ -void drop(char* uname, char* gname, bool keep_readall_caps) +void drop([[maybe_unused]] char* uname, + [[maybe_unused]] char* gname, + [[maybe_unused]] bool keep_readall_caps) { #if defined(HAVE_PWD_H) && defined(HAVE_GRP_H) struct passwd* passw = NULL; diff --git a/core/src/stored/ndmp_tape.cc b/core/src/stored/ndmp_tape.cc index 7378601dff0..705d0fc24e8 100644 --- a/core/src/stored/ndmp_tape.cc +++ b/core/src/stored/ndmp_tape.cc @@ -1305,8 +1305,8 @@ void StopNdmpThreadServer() } } #else -void EndOfNdmpBackup(JobControlRecord* jcr) {} +void EndOfNdmpBackup([[maybe_unused]] JobControlRecord* jcr) {} -void EndOfNdmpRestore(JobControlRecord* jcr) {} +void EndOfNdmpRestore([[maybe_unused]] JobControlRecord* jcr) {} #endif /* HAVE_NDMP */ } /* namespace storagedaemon */ diff --git a/core/src/win32/compat/compat.cc b/core/src/win32/compat/compat.cc index 7ebb666d97f..5e73ffde27b 100644 --- a/core/src/win32/compat/compat.cc +++ b/core/src/win32/compat/compat.cc @@ -832,11 +832,21 @@ char* dlerror(void) return buf; } -int fcntl(int fd, int cmd) { return 0; } +int fcntl([[maybe_unused]] int fd, [[maybe_unused]] int cmd) { return 0; } -int chown(const char* k, uid_t, gid_t) { return 0; } +int chown([[maybe_unused]] const char* k, + [[maybe_unused]] uid_t, + [[maybe_unused]] gid_t) +{ + return 0; +} -int lchown(const char* k, uid_t, gid_t) { return 0; } +int lchown([[maybe_unused]] const char* k, + [[maybe_unused]] uid_t, + [[maybe_unused]] gid_t) +{ + return 0; +} long int random(void) { return rand(); } @@ -1794,7 +1804,7 @@ int win32_ftruncate(int fd, int64_t length) return 0; } -int fcntl(int fd, int cmd, long arg) +int fcntl([[maybe_unused]] int fd, int cmd, [[maybe_unused]] long arg) { int rval = 0; @@ -1939,7 +1949,8 @@ int win32_symlink(const char* name1, const char* name2, _dev_t st_rdev) } // Create a hardlink -int link(const char* existing, const char* newfile) +int link([[maybe_unused]] const char* existing, + [[maybe_unused]] const char* newfile) { errno = ENOSYS; return -1; @@ -1951,7 +1962,7 @@ int gettimeofday(struct timeval* tv, struct timezone* tz) } // Write in Windows System log -extern "C" void syslog(int type, const char* fmt, ...) +extern "C" void syslog([[maybe_unused]] int type, const char* fmt, ...) { va_list arg_ptr; int len, maxlen; @@ -2158,7 +2169,7 @@ int inet_aton(const char* a, struct in_addr* inp) return 1; } -void InitSignals(void Terminate(int sig)) {} +void InitSignals([[maybe_unused]] void Terminate(int sig)) {} void InitStackDump(void) {} @@ -2167,6 +2178,7 @@ long pathconf(const char* path, int name) switch (name) { case _PC_PATH_MAX: if (strncmp(path, "\\\\?\\", 4) == 0) return 32767; + [[fallthrough]]; case _PC_NAME_MAX: return 255; } @@ -3004,7 +3016,10 @@ static void CloseHandleIfValid(HANDLE handle) if (handle != INVALID_HANDLE_VALUE) { CloseHandle(handle); } } -Bpipe* OpenBpipe(char* prog, int wait, const char* mode, bool dup_stderr) +Bpipe* OpenBpipe(char* prog, + int wait, + const char* mode, + [[maybe_unused]] bool dup_stderr) { int mode_read, mode_write; SECURITY_ATTRIBUTES saAttr; @@ -3199,7 +3214,11 @@ int CloseWpipe(Bpipe* bpipe) } // Syslog function, added by Nicolas Boichat -extern "C" void openlog(const char* ident, int option, int facility) {} +extern "C" void openlog([[maybe_unused]] const char* ident, + [[maybe_unused]] int option, + [[maybe_unused]] int facility) +{ +} // Log an error message void LogErrorMsg(const char* message) diff --git a/core/src/win32/compat/winapi.cc b/core/src/win32/compat/winapi.cc index 1cc9f0136eb..7b862f3e3f6 100644 --- a/core/src/win32/compat/winapi.cc +++ b/core/src/win32/compat/winapi.cc @@ -3,7 +3,7 @@ Copyright (C) 2003-2008 Free Software Foundation Europe e.V. Copyright (C) 2011-2012 Planets Communications B.V. - Copyright (C) 2013-2017 Bareos GmbH & Co. KG + Copyright (C) 2013-2022 Bareos GmbH & Co. KG This program is Free Software; you can redistribute it and/or modify it under the terms of version three of the GNU Affero General Public @@ -108,7 +108,7 @@ t_GetLogicalDriveStringsW p_GetLogicalDriveStringsW = NULL; void InitWinAPIWrapper() { - OSVERSIONINFO osversioninfo = {sizeof(OSVERSIONINFO)}; + OSVERSIONINFO osversioninfo = {sizeof(OSVERSIONINFO), 0, 0, 0, 0, 0}; // Get the current OS version if (!GetVersionEx(&osversioninfo)) { diff --git a/core/src/win32/generic/main.cc b/core/src/win32/generic/main.cc index 4120584dc36..1b808c5a7a0 100644 --- a/core/src/win32/generic/main.cc +++ b/core/src/win32/generic/main.cc @@ -2,7 +2,7 @@ BAREOS® - Backup Archiving REcovery Open Sourced Copyright (C) 2007-2011 Free Software Foundation Europe e.V. - Copyright (C) 2016-2020 Bareos GmbH & Co. KG + Copyright (C) 2016-2022 Bareos GmbH & Co. KG This program is Free Software; you can redistribute it and/or modify it under the terms of version three of the GNU Affero General Public @@ -234,7 +234,7 @@ LRESULT CALLBACK bacWinProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) * Called as a thread from BareosAppMain() * Here we handle the Windows messages */ -void* Main_Msg_Loop(LPVOID lpwThreadParam) +void* Main_Msg_Loop([[maybe_unused]] LPVOID lpwThreadParam) { MSG msg; diff --git a/core/src/win32/generic/service.cc b/core/src/win32/generic/service.cc index d3a986e8df4..2d41360250f 100644 --- a/core/src/win32/generic/service.cc +++ b/core/src/win32/generic/service.cc @@ -2,7 +2,7 @@ BAREOS® - Backup Archiving REcovery Open Sourced Copyright (C) 2007-2010 Free Software Foundation Europe e.V. - Copyright (C) 2013-2017 Bareos GmbH & Co. KG + Copyright (C) 2013-2022 Bareos GmbH & Co. KG This program is Free Software; you can redistribute it and/or modify it under the terms of version three of the GNU Affero General Public @@ -76,7 +76,8 @@ int stopRunningBareos() * the OS returns control here immediately after starting * the service. */ -void WINAPI serviceStartCallback(DWORD argc, char** argv) +void WINAPI serviceStartCallback([[maybe_unused]] DWORD argc, + [[maybe_unused]] char** argv) { DWORD dwThreadID; @@ -176,7 +177,7 @@ int bareosServiceMain() } // New style service bareos worker thread -DWORD WINAPI bareosWorkerThread(LPVOID lpwThreadParam) +DWORD WINAPI bareosWorkerThread([[maybe_unused]] LPVOID lpwThreadParam) { service_thread_id = GetCurrentThreadId();