From cb125e6336c85f0827769961ea6a83e24ef9d67c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 22 Jan 2024 21:17:00 -0500 Subject: [PATCH] Use constexpr functions rather than macros. --- .../MassStorage/SCSI/TargetImplementation.hpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Storage/MassStorage/SCSI/TargetImplementation.hpp b/Storage/MassStorage/SCSI/TargetImplementation.hpp index 4ef8e230d..67078484e 100644 --- a/Storage/MassStorage/SCSI/TargetImplementation.hpp +++ b/Storage/MassStorage/SCSI/TargetImplementation.hpp @@ -170,14 +170,16 @@ template void Target::begin_command(uint8_t first_ } } +namespace { + +constexpr uint8_t G0(uint8_t opcode) { return 0x00 | opcode; } +constexpr uint8_t G1(uint8_t opcode) { return 0x20 | opcode; } +constexpr uint8_t G5(uint8_t opcode) { return 0xa0 | opcode; } + +} + template bool Target::dispatch_command() { - CommandState arguments(command_, data_); - -#define G0(x) x -#define G1(x) (0x20|x) -#define G5(x) (0xa0|x) - log_.info().append("---Command %02x---", command_[0]); switch(command_[0]) { @@ -209,14 +211,9 @@ template bool Target::dispatch_command() { case G1(0x1c): return executor_.read_buffer(arguments, *this); case G1(0x15): return executor_.mode_select(arguments, *this); - case G5(0x09): return executor_.set_block_limits(arguments, *this); } -#undef G0 -#undef G1 -#undef G5 - return false; }