summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-05-22 21:37:47 +0300
committerOxore <oxore@protonmail.com>2023-05-22 21:40:56 +0300
commit8de6e3253b614f2b751cb760b489f487b927d1c5 (patch)
tree07b3db01ec39cdc72f83d8206d05ff47551f8da8
parentcdabbbcfa0717b2253f79e04eb6ac14996cf9dca (diff)
Fix Clang errors and warnings
-rw-r--r--disasm.cpp6
-rw-r--r--disasm.h30
-rw-r--r--main.cpp4
3 files changed, 20 insertions, 20 deletions
diff --git a/disasm.cpp b/disasm.cpp
index a878c92..09a5149 100644
--- a/disasm.cpp
+++ b/disasm.cpp
@@ -738,7 +738,7 @@ static size_t disasm_move_to(
case AddrMode::kImmediate:
break;
}
- node.op = Op::Typical(OpCode::kMOVE, opsize, src, Arg{reg, 0});
+ node.op = Op::Typical(OpCode::kMOVE, opsize, src, Arg{{reg}, {0}});
return node.size = kInstructionSizeStepBytes + src.Size(opsize);
}
@@ -1806,8 +1806,8 @@ static size_t snprint_reg_mask(
const size_t remaining = bufsz - written;
const int ret = snprintf(buf + written, remaining, "%s%%%c%d", delimiter, regtype, id);
assert(ret > 0);
- assert(static_cast<unsigned>(ret) >= strlen("%d0"));
- assert(static_cast<unsigned>(ret) <= strlen("-%d0"));
+ assert(static_cast<unsigned>(ret) >= sizeof("%d0")-1);
+ assert(static_cast<unsigned>(ret) <= sizeof("-%d0")-1);
written += Min(remaining, ret);
first_printed = true;
}
diff --git a/disasm.h b/disasm.h
index 68bb824..441f7da 100644
--- a/disasm.h
+++ b/disasm.h
@@ -213,7 +213,7 @@ struct Arg {
return 0;
}
static constexpr auto AddrModeXn(const ArgType type, const uint8_t xn) {
- Arg a{type, 0};
+ Arg a{{type}, {0}};
a.xn = xn;
return a;
}
@@ -230,67 +230,67 @@ struct Arg {
}
static constexpr auto D16AnAddr(const uint8_t xn, const int16_t d16)
{
- Arg a{ArgType::kD16AnAddr, 0};
+ Arg a{{ArgType::kD16AnAddr}, {0}};
a.d16_an = D16AnPCAddr{xn, d16};
return a;
}
static constexpr auto D16PCAddr(const int16_t d16)
{
- Arg a{ArgType::kD16PCAddr, 0};
+ Arg a{{ArgType::kD16PCAddr}, {0}};
a.d16_pc = D16AnPCAddr{0, d16};
return a;
}
static constexpr auto Word(const int16_t w)
{
- Arg a{ArgType::kWord, 0};
+ Arg a{{ArgType::kWord}, {0}};
a.lword = w;
return a;
}
static constexpr auto Long(const int32_t l)
{
- Arg a{ArgType::kLong, 0};
+ Arg a{{ArgType::kLong}, {0}};
a.lword = l;
return a;
}
static constexpr auto D8AnXiAddr(
const uint8_t xn, const uint8_t xi, const OpSize s, const int8_t d8)
{
- Arg a{ArgType::kD8AnXiAddr, 0};
+ Arg a{{ArgType::kD8AnXiAddr}, {0}};
a.d8_an_xi = D8AnPCXiAddr{xn, uint8_t(xi | (s == OpSize::kLong ? 0x10u : 0u)), d8};
return a;
}
static constexpr auto D8PCXiAddr(
const uint8_t xn, const uint8_t xi, const OpSize s, const int8_t d8)
{
- Arg a{ArgType::kD8PCXiAddr, 0};
+ Arg a{{ArgType::kD8PCXiAddr}, {0}};
a.d8_pc_xi = D8AnPCXiAddr{xn, uint8_t(xi | (s == OpSize::kLong ? 0x10u : 0u)), d8};
return a;
}
static constexpr auto Immediate(const int32_t value) {
- Arg a{ArgType::kImmediate, 0};
+ Arg a{{ArgType::kImmediate}, {0}};
a.lword = value;
return a;
}
static constexpr auto RegMask(const uint16_t regmask) {
- Arg a{ArgType::kRegMask, 0};
+ Arg a{{ArgType::kRegMask}, {0}};
a.uword = regmask;
return a;
}
static constexpr auto RegMaskPredecrement(const uint16_t regmask) {
- Arg a{ArgType::kRegMaskPredecrement, 0};
+ Arg a{{ArgType::kRegMaskPredecrement}, {0}};
a.uword = regmask;
return a;
}
static constexpr auto Displacement(const int32_t displacement) {
- Arg a{ArgType::kDisplacement, 0};
+ Arg a{{ArgType::kDisplacement}, {0}};
a.lword = displacement;
return a;
}
- static constexpr auto CCR() { return Arg{ArgType::kCCR, 0}; }
- static constexpr auto SR() { return Arg{ArgType::kSR, 0}; }
- static constexpr auto USP() { return Arg{ArgType::kUSP, 0}; }
+ static constexpr auto CCR() { return Arg{{ArgType::kCCR}, {0}}; }
+ static constexpr auto SR() { return Arg{{ArgType::kSR}, {0}}; }
+ static constexpr auto USP() { return Arg{{ArgType::kUSP}, {0}}; }
static constexpr auto Raw(const uint16_t instr) {
- Arg a{ArgType::kRaw, 0};
+ Arg a{{ArgType::kRaw}, {0}};
a.uword = instr;
return a;
}
diff --git a/main.cpp b/main.cpp
index d970d79..d3c570c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -459,7 +459,7 @@ static int M68kDisasmAll(FILE *input_stream, FILE *output_stream, const Settings
static bool IsValidFeature(const char *feature)
{
- constexpr size_t sizeof_no_prefix = strlen("no-");
+ constexpr size_t sizeof_no_prefix = sizeof("no-")-1;
if (0 == memcmp(feature, "no-", sizeof_no_prefix)) {
feature += sizeof_no_prefix;
}
@@ -484,7 +484,7 @@ static bool IsValidFeature(const char *feature)
static void ApplyFeature(Settings& s, const char *feature)
{
bool disable{};
- constexpr size_t sizeof_no_prefix = strlen("no-");
+ constexpr size_t sizeof_no_prefix = sizeof("no-")-1;
if (0 == memcmp(feature, "no-", sizeof_no_prefix)) {
disable = true;
feature += sizeof_no_prefix;