From 8bb015754af68c14fbdda7d92fc8baaef0928229 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 17 Apr 2025 14:36:55 -0700 Subject: [PATCH] Fix clang-tidy bugprone-throw-keyword-missing warnings This one renames the Modbus Exception binpac type to ExcResponse. clang-tidy insisted that anything named started with Exception was actually an exception and needed to be thrown. --- .clang-tidy | 1 + src/analyzer/protocol/modbus/modbus-analyzer.pac | 2 +- src/analyzer/protocol/modbus/modbus-protocol.pac | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index d7ebf7a090..bfa2a00f91 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -14,4 +14,5 @@ Checks: [-*, bugprone-suspicious-string-compare, bugprone-suspicious-include, bugprone-suspicious-realloc-usage, + bugprone-throw-keyword-missing, ] diff --git a/src/analyzer/protocol/modbus/modbus-analyzer.pac b/src/analyzer/protocol/modbus/modbus-analyzer.pac index d53e2aa16e..03a124045f 100644 --- a/src/analyzer/protocol/modbus/modbus-analyzer.pac +++ b/src/analyzer/protocol/modbus/modbus-analyzer.pac @@ -114,7 +114,7 @@ refine flow ModbusTCP_Flow += { %} # EXCEPTION - function deliver_Exception(header: ModbusTCP_TransportHeader, message: Exception): bool + function deliver_Exception(header: ModbusTCP_TransportHeader, message: ModbusTCP_ExceptResponse): bool %{ if ( ::modbus_exception ) { diff --git a/src/analyzer/protocol/modbus/modbus-protocol.pac b/src/analyzer/protocol/modbus/modbus-protocol.pac index 4edf458ecf..d811806bbf 100644 --- a/src/analyzer/protocol/modbus/modbus-protocol.pac +++ b/src/analyzer/protocol/modbus/modbus-protocol.pac @@ -112,7 +112,7 @@ type ModbusTCP_Request(header: ModbusTCP_TransportHeader) = case header.fc of { # type ModbusTCP_Response(header: ModbusTCP_TransportHeader) = case header.fc & 0x80 of { 0 -> normal_response : ModbusTCP_NormalResponse(header); - default -> exception_response : Exception(header); + default -> exception_response : ModbusTCP_ExceptResponse(header); }; type ModbusTCP_NormalResponse(header: ModbusTCP_TransportHeader) = case header.fc of { @@ -140,7 +140,7 @@ type ModbusTCP_NormalResponse(header: ModbusTCP_TransportHeader) = case header.f default -> unknown: bytestring &restofdata; }; -type Exception(header: ModbusTCP_TransportHeader) = record { +type ModbusTCP_ExceptResponse(header: ModbusTCP_TransportHeader) = record { code: uint8; } &let { deliver: bool = $context.flow.deliver_Exception(header, this);