From 9a890ec2fc10e5bef4e2d3b9800186ec1673cde1 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 26 Jun 2020 01:07:44 +0200 Subject: Windows: fix warning reported by static code analyzed by adding copy constructor to _TEXT_EDIT_DIALOG_PARAM and = operator to HostDevice --- src/Common/Dlgcode.c | 12 ++++++++---- src/Common/Dlgcode.h | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 737e02ef..fc1cdc31 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -3670,11 +3670,15 @@ struct _TEXT_EDIT_DIALOG_PARAM { std::string& Text; const WCHAR* Title; - _TEXT_EDIT_DIALOG_PARAM(BOOL _readOnly, const WCHAR* title, std::string& _text) : Title(title), Text(_text), ReadOnly(_readOnly) {} + _TEXT_EDIT_DIALOG_PARAM (const _TEXT_EDIT_DIALOG_PARAM& other) : ReadOnly (other.ReadOnly), Text (other.Text), Title (other.Title) {} + _TEXT_EDIT_DIALOG_PARAM(BOOL _readOnly, const WCHAR* title, std::string& _text) : ReadOnly(_readOnly), Text(_text), Title(title) {} _TEXT_EDIT_DIALOG_PARAM& operator=( const _TEXT_EDIT_DIALOG_PARAM& other) { - ReadOnly = other.ReadOnly; - Text = other.Text; - Title = other.Title; + if (this != &other) + { + ReadOnly = other.ReadOnly; + Text = other.Text; + Title = other.Title; + } return *this; } }; diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index b2324b12..29a13624 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -601,6 +601,30 @@ struct HostDevice ~HostDevice () {} + HostDevice& operator= (const HostDevice& device) + { + if (this != &device) + { + Bootable = device.Bootable; + ContainsSystem = device.ContainsSystem; + DynamicVolume = device.DynamicVolume; + Floppy = device.Floppy; + IsPartition = device.IsPartition; + IsVirtualPartition = device.IsVirtualPartition; + HasUnencryptedFilesystem = device.HasUnencryptedFilesystem; + MountPoint = device.MountPoint; + Name = device.Name; + Path = device.Path; + Removable = device.Removable; + Size = device.Size; + SystemNumber = device.SystemNumber; + HasVolumeIDs = device.HasVolumeIDs; + Partitions = device.Partitions; + memcpy (VolumeIDs, device.VolumeIDs, sizeof (VolumeIDs)); + } + return *this; + } + bool Bootable; bool ContainsSystem; bool DynamicVolume; -- cgit v1.2.3