From 99ffb980f9f4bca37ceae73a056f274add83e3f7 Mon Sep 17 00:00:00 2001 From: Mathieu Donze Date: Fri, 17 Oct 2025 11:10:13 +0200 Subject: [PATCH 1/3] Fix some compilation warnings on ESP32 (IDF 5.1.0) --- src/BER.h | 54 +++++++++++++++++++++++------------------------ src/SNMPMessage.h | 16 +++++++------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/BER.h b/src/BER.h index e542f7e..c852106 100644 --- a/src/BER.h +++ b/src/BER.h @@ -286,39 +286,39 @@ class Type: public Base { */ enum : uint16_t { // Universal - Boolean = Class::Universal | Form::Primitive | 0x01, /**< 0x01 */ - Integer, /**< 0x02 */ - BitString, /**< 0x03 */ - OctetString, /**< 0x04 */ - Null, /**< 0x05 */ - ObjectIdentifier, /**< 0x06 */ - Sequence = Class::Universal | Form::Constructed | 0x10, /**< 0x30 */ + Boolean = static_cast(Class::Universal) | static_cast(Form::Primitive) | 0x01, /**< 0x01 */ + Integer, /**< 0x02 */ + BitString, /**< 0x03 */ + OctetString, /**< 0x04 */ + Null, /**< 0x05 */ + ObjectIdentifier, /**< 0x06 */ + Sequence = static_cast(Class::Universal) | static_cast(Form::Constructed) | 0x10, /**< 0x30 */ // Application - IPAddress = Class::Application | 0x00, /**< 0x40 */ - Counter32, /**< 0x41 */ - Gauge32, /**< 0x42 */ - TimeTicks, /**< 0x43 */ - Opaque, /**< 0x44 */ - Counter64 = Class::Application | 0x06, /**< 0x46 */ - Float = Class::Application | 0x08, /**< 0x48 */ + IPAddress = static_cast(Class::Application) | 0x00, /**< 0x40 */ + Counter32, /**< 0x41 */ + Gauge32, /**< 0x42 */ + TimeTicks, /**< 0x43 */ + Opaque, /**< 0x44 */ + Counter64 = static_cast(Class::Application) | 0x06, /**< 0x46 */ + Float = static_cast(Class::Application) | 0x08, /**< 0x48 */ // Context - NoSuchObject = Class::Context | 0x00, /**< 0x80 */ - NoSuchInstance, /**< 0x81 */ - EndOfMIBView, /**< 0x82 */ + NoSuchObject = static_cast(Class::Context) | 0x00, /**< 0x80 */ + NoSuchInstance, /**< 0x81 */ + EndOfMIBView, /**< 0x82 */ // Version 1 - GetRequest = Class::Context | Form::Constructed | 0x00, /**< 0xA0 */ - GetNextRequest, /**< 0xA1 */ - GetResponse, /**< 0xA2 */ - SetRequest, /**< 0xA3 */ - Trap, /**< 0xA4 */ + GetRequest = static_cast(Class::Context) | static_cast(Form::Constructed) | 0x00, /**< 0xA0 */ + GetNextRequest, /**< 0xA1 */ + GetResponse, /**< 0xA2 */ + SetRequest, /**< 0xA3 */ + Trap, /**< 0xA4 */ // Version 2C - GetBulkRequest, /**< 0xA5 */ - InformRequest, /**< 0xA6 */ - SNMPv2Trap, /**< 0xA7 */ + GetBulkRequest, /**< 0xA5 */ + InformRequest, /**< 0xA6 */ + SNMPv2Trap, /**< 0xA7 */ // Version 3 - Report, /**< 0xA8 */ + Report, /**< 0xA8 */ // Opaque type - OpaqueFloat = 0x9F78 /**< 0x9F78 */ + OpaqueFloat = 0x9F78 /**< 0x9F78 */ }; /** diff --git a/src/SNMPMessage.h b/src/SNMPMessage.h index b7dc14e..3a80894 100644 --- a/src/SNMPMessage.h +++ b/src/SNMPMessage.h @@ -115,16 +115,16 @@ class Message: public SequenceBER, private PDU { */ class OID { public: - static constexpr char *COLDSTART = "1.3.6.1.6.3.1.1.5.1"; - static constexpr char *WARMSTART = "1.3.6.1.6.3.1.1.5.2"; - static constexpr char *LINKDOWN = "1.3.6.1.6.3.1.1.5.3"; - static constexpr char *LINKUP = "1.3.6.1.6.3.1.1.5.4"; - static constexpr char *AUTHENTICATIONFAILURE = "1.3.6.1.6.3.1.1.5.5"; + static constexpr const char *COLDSTART = "1.3.6.1.6.3.1.1.5.1"; + static constexpr const char *WARMSTART = "1.3.6.1.6.3.1.1.5.2"; + static constexpr const char *LINKDOWN = "1.3.6.1.6.3.1.1.5.3"; + static constexpr const char *LINKUP = "1.3.6.1.6.3.1.1.5.4"; + static constexpr const char *AUTHENTICATIONFAILURE = "1.3.6.1.6.3.1.1.5.5"; private: - static constexpr char *SYSUPTIME = "1.3.6.1.2.1.1.3.0"; - static constexpr char *SNMPTRAPOID = "1.3.6.1.6.3.1.1.4.1.0"; - static constexpr char *SNMPTRAPENTERPRISE = "1.3.6.1.6.3.1.1.4.3.0"; + static constexpr const char *SYSUPTIME = "1.3.6.1.2.1.1.3.0"; + static constexpr const char *SNMPTRAPOID = "1.3.6.1.6.3.1.1.4.1.0"; + static constexpr const char *SNMPTRAPENTERPRISE = "1.3.6.1.6.3.1.1.4.3.0"; friend class Message; }; From 168f6f1d99df25c78500febcb6a1562cb5c62f51 Mon Sep 17 00:00:00 2001 From: BwanaFr Date: Fri, 17 Oct 2025 16:39:09 +0200 Subject: [PATCH 2/3] Fixed indentation --- src/BER.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BER.h b/src/BER.h index c852106..11746e2 100644 --- a/src/BER.h +++ b/src/BER.h @@ -300,7 +300,7 @@ class Type: public Base { TimeTicks, /**< 0x43 */ Opaque, /**< 0x44 */ Counter64 = static_cast(Class::Application) | 0x06, /**< 0x46 */ - Float = static_cast(Class::Application) | 0x08, /**< 0x48 */ + Float = static_cast(Class::Application) | 0x08, /**< 0x48 */ // Context NoSuchObject = static_cast(Class::Context) | 0x00, /**< 0x80 */ NoSuchInstance, /**< 0x81 */ @@ -2642,3 +2642,4 @@ class OpaqueFloatBER: public FloatBER { } // namespace SNMP #endif /* BER_H_ */ + From 5fe75e539c20b14ea3e00de9bc67e1de7e2465b3 Mon Sep 17 00:00:00 2001 From: BwanaFr Date: Thu, 30 Oct 2025 10:54:28 +0100 Subject: [PATCH 3/3] Avoid static_cast in enums --- src/BER.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/BER.h b/src/BER.h index 11746e2..51c1864 100644 --- a/src/BER.h +++ b/src/BER.h @@ -286,27 +286,27 @@ class Type: public Base { */ enum : uint16_t { // Universal - Boolean = static_cast(Class::Universal) | static_cast(Form::Primitive) | 0x01, /**< 0x01 */ + Boolean = +Class::Universal | +Form::Primitive | 0x01, /**< 0x01 */ Integer, /**< 0x02 */ BitString, /**< 0x03 */ OctetString, /**< 0x04 */ Null, /**< 0x05 */ ObjectIdentifier, /**< 0x06 */ - Sequence = static_cast(Class::Universal) | static_cast(Form::Constructed) | 0x10, /**< 0x30 */ + Sequence = +Class::Universal | +Form::Constructed | 0x10, /**< 0x30 */ // Application - IPAddress = static_cast(Class::Application) | 0x00, /**< 0x40 */ + IPAddress = +Class::Application | 0x00, /**< 0x40 */ Counter32, /**< 0x41 */ Gauge32, /**< 0x42 */ TimeTicks, /**< 0x43 */ Opaque, /**< 0x44 */ - Counter64 = static_cast(Class::Application) | 0x06, /**< 0x46 */ - Float = static_cast(Class::Application) | 0x08, /**< 0x48 */ + Counter64 = +Class::Application | 0x06, /**< 0x46 */ + Float = +Class::Application | 0x08, /**< 0x48 */ // Context - NoSuchObject = static_cast(Class::Context) | 0x00, /**< 0x80 */ + NoSuchObject = +Class::Context | 0x00, /**< 0x80 */ NoSuchInstance, /**< 0x81 */ EndOfMIBView, /**< 0x82 */ // Version 1 - GetRequest = static_cast(Class::Context) | static_cast(Form::Constructed) | 0x00, /**< 0xA0 */ + GetRequest = +Class::Context | +Form::Constructed | 0x00, /**< 0xA0 */ GetNextRequest, /**< 0xA1 */ GetResponse, /**< 0xA2 */ SetRequest, /**< 0xA3 */ @@ -2643,3 +2643,4 @@ class OpaqueFloatBER: public FloatBER { #endif /* BER_H_ */ +