From 50be68034f57389568a61d92c87346b35b38a71f Mon Sep 17 00:00:00 2001 From: Jan Henrik Weinstock Date: Sat, 21 Dec 2024 09:24:41 +0100 Subject: [PATCH] clang-tidy: minor fixes --- src/vcml/debugging/gdbserver.cpp | 6 +++--- src/vcml/debugging/vspserver.cpp | 2 +- src/vcml/models/ethernet/backend_slirp.cpp | 4 ++-- test/models/can_mcan.cpp | 14 ++++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/vcml/debugging/gdbserver.cpp b/src/vcml/debugging/gdbserver.cpp index 47df8b67..d8222f36 100644 --- a/src/vcml/debugging/gdbserver.cpp +++ b/src/vcml/debugging/gdbserver.cpp @@ -311,9 +311,9 @@ string gdbserver::handle_xfer(const string& cmd) { if (args.size() != 5) return ERR_COMMAND; - string object = args[1]; - string read = args[2]; - string annex = args[3]; + const string& object = args[1]; + const string& read = args[2]; + const string& annex = args[3]; if (read != "read") return ERR_COMMAND; diff --git a/src/vcml/debugging/vspserver.cpp b/src/vcml/debugging/vspserver.cpp index 64cca942..0c2b4a66 100644 --- a/src/vcml/debugging/vspserver.cpp +++ b/src/vcml/debugging/vspserver.cpp @@ -441,7 +441,7 @@ string vspserver::handle_geta(const string& cmd) { if (args.size() < 2) return mkstr("E,insufficient arguments %zu", args.size()); - string name = args[1]; + const string& name = args[1]; sc_attr_base* attr = find_attribute(name); if (attr == nullptr) return mkstr("E,attribute '%s' not found", name.c_str()); diff --git a/src/vcml/models/ethernet/backend_slirp.cpp b/src/vcml/models/ethernet/backend_slirp.cpp index fbcac9ac..45e53213 100644 --- a/src/vcml/models/ethernet/backend_slirp.cpp +++ b/src/vcml/models/ethernet/backend_slirp.cpp @@ -263,8 +263,8 @@ void slirp_network::host_port_forwarding(const string& desc) { if (args.size() != 4) VCML_ERROR("invalid port forwarding: '%s'", desc.c_str()); - string protocol = args[0]; - string guest_addr = args[1]; + const string& protocol = args[0]; + const string& guest_addr = args[1]; u16 guest_port = from_string(args[2]); u16 host_port = from_string(args[3]); diff --git a/test/models/can_mcan.cpp b/test/models/can_mcan.cpp index b1931b1d..467e524d 100644 --- a/test/models/can_mcan.cpp +++ b/test/models/can_mcan.cpp @@ -10,17 +10,17 @@ #include "testing.h" -MATCHER_P(TxEvFIFOElemEq, n, "Equality matcher for TX event FIFO elements") { +MATCHER_P(fifo_match, n, "Equality matcher for TX event FIFO elements") { return (arg[0] == n[0]) && ((arg[1] | bit(22)) == n[1]); } -MATCHER_P(CanFrameEq, n, "Equality matcher for CAN frames") { +MATCHER_P(can_frame_match, n, "Equality matcher for CAN frames") { return (arg.msgid == n.msgid) && (arg.dlc == n.dlc) && std::equal(std::begin(arg.data), std::end(arg.data), std::begin(n.data)); } -MATCHER_P(CanFrameFDEq, n, "Equality matcher for CAN FD frames") { +MATCHER_P(canfd_frame_match, n, "Equality matcher for CAN FD frames") { return (arg.msgid == n.msgid) && (arg.dlc == n.dlc) && (arg.flags == n.flags) && std::equal(std::begin(arg.data), std::end(arg.data), @@ -275,7 +275,7 @@ class m_can_bench : public test_base u64 addr = addr_msgram.start + TX_EVFIFO_START_ADDR + get_field(txefs) * TX_EFIFO_ELEM_SZ; EXPECT_OK(out.readw(addr, evfifo)) << "cannot read from tx evfifo"; - EXPECT_THAT(test, TxEvFIFOElemEq(evfifo)) + EXPECT_THAT(test, fifo_match(evfifo)) << "tx evfifo data is not matching"; // acknowledge read & check new fifo fill level @@ -319,7 +319,8 @@ class m_can_bench : public test_base can_frame chk = {}; ASSERT_TRUE(can.can_rx_pop(chk)); - EXPECT_THAT(test, CanFrameEq(chk)) << "tx can frames to not match"; + EXPECT_THAT(test, can_frame_match(chk)) + << "tx can frames to not match"; EXPECT_TRUE(irq0.read()) << "irq did not get raised"; check_irq(IR_TEFN | IR_TC); EXPECT_FALSE(irq0.read()) << "irq did not get cleared"; @@ -352,7 +353,8 @@ class m_can_bench : public test_base can_frame chk = {}; ASSERT_TRUE(can.can_rx_pop(chk)); - EXPECT_THAT(test, CanFrameFDEq(chk)) << "tx can frames to not match"; + EXPECT_THAT(test, canfd_frame_match(chk)) + << "tx can frames to not match"; EXPECT_TRUE(irq0.read()) << "irq did not get raised"; check_irq(IR_TEFN | IR_TC); EXPECT_FALSE(irq0.read()) << "irq did not get cleared";