From 21eb9650ab6734054a142a4853fae4dccbfe9532 Mon Sep 17 00:00:00 2001 From: Jeremy Boynes Date: Thu, 2 Nov 2023 15:09:40 +0000 Subject: [PATCH 1/3] Fix #217 issue with compiling with newer compiler --- api/CanMsg.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/api/CanMsg.h b/api/CanMsg.h index eaa3f0ed..b26a48b5 100644 --- a/api/CanMsg.h +++ b/api/CanMsg.h @@ -51,12 +51,7 @@ class CanMsg : public Printable CanMsg() : CanMsg(0, 0, nullptr) { } - CanMsg(CanMsg const & other) - { - this->id = other.id; - this->data_length = other.data_length; - if (this->data_length && other.data) - memcpy(this->data, other.data, this->data_length); + CanMsg(CanMsg const & other) : CanMsg(other.id, other.data_length, other.data) { } virtual ~CanMsg() { } @@ -65,10 +60,10 @@ class CanMsg : public Printable { if (this != &other) { - this->id = other.id; - this->data_length = other.data_length; - if (this->data_length && other.data) - memcpy(this->data, other.data, this->data_length); + id = other.id; + data_length = other.data_length; + if (data_length > 0) + memcpy(data, other.data, data_length); } return (*this); } From 5ba50100429f04798f877a09feb69b581a9f4d7f Mon Sep 17 00:00:00 2001 From: Jeremy Boynes Date: Fri, 3 Nov 2023 09:33:36 +0000 Subject: [PATCH 2/3] Don't use construtor delegation --- api/CanMsg.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/CanMsg.h b/api/CanMsg.h index b26a48b5..cae7cc10 100644 --- a/api/CanMsg.h +++ b/api/CanMsg.h @@ -51,7 +51,11 @@ class CanMsg : public Printable CanMsg() : CanMsg(0, 0, nullptr) { } - CanMsg(CanMsg const & other) : CanMsg(other.id, other.data_length, other.data) { + CanMsg(CanMsg const & other) { + id = other.id; + data_length = other.data_length; + if (data_length > 0) + memcpy(data, other.data, data_length); } virtual ~CanMsg() { } From 8ffd335132add989d720d1237d09aff0bee06c1c Mon Sep 17 00:00:00 2001 From: Jeremy Boynes Date: Mon, 6 Nov 2023 07:34:42 +0000 Subject: [PATCH 3/3] Fix brace style and indent --- api/CanMsg.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/api/CanMsg.h b/api/CanMsg.h index cae7cc10..3e103c0b 100644 --- a/api/CanMsg.h +++ b/api/CanMsg.h @@ -51,11 +51,12 @@ class CanMsg : public Printable CanMsg() : CanMsg(0, 0, nullptr) { } - CanMsg(CanMsg const & other) { - id = other.id; - data_length = other.data_length; - if (data_length > 0) - memcpy(data, other.data, data_length); + CanMsg(CanMsg const & other) + { + id = other.id; + data_length = other.data_length; + if (data_length > 0) + memcpy(data, other.data, data_length); } virtual ~CanMsg() { }