From ecb5ea9671fb899aee98af218da09048317f4809 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 18 May 2023 23:12:01 +0200 Subject: [PATCH] Fix compiler warnings (#1030) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixing the following compiler warnings: FuseService.cpp: In function ‘int VeraCrypt::fuse_service_read(const char*, char*, size_t, off_t, fuse_file_info*)’: FuseService.cpp:233:12: warning: catching polymorphic type ‘struct VeraCrypt::MissingVolumeData’ by value [-Wcatch-value=] 233 | catch (MissingVolumeData) | ^~~~~~~~~~~~~~~~~ FuseService.cpp: In static member function ‘static int VeraCrypt::FuseService::ExceptionToErrorCode()’: FuseService.cpp:362:15: warning: catching polymorphic type ‘class std::bad_alloc’ by value [-Wcatch-value=] 362 | catch (std::bad_alloc) | ^~~~~~~~~ Apart from warnings, the current code creates unnecessary copies of the exception object in debug mode. (But not in -O3) --- src/Driver/Fuse/FuseService.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Driver/Fuse/FuseService.cpp b/src/Driver/Fuse/FuseService.cpp index eee0c433..bc3d1023 100644 --- a/src/Driver/Fuse/FuseService.cpp +++ b/src/Driver/Fuse/FuseService.cpp @@ -230,7 +230,7 @@ namespace VeraCrypt FuseService::ReadVolumeSectors (BufferPtr ((byte *) buf, size), offset); } } - catch (MissingVolumeData) + catch (MissingVolumeData&) { return 0; } @@ -359,7 +359,7 @@ namespace VeraCrypt { throw; } - catch (std::bad_alloc) + catch (std::bad_alloc&) { return -ENOMEM; }