aboutsummaryrefslogtreecommitdiff
path: root/src/format_v2.h
diff options
context:
space:
mode:
authorJan Sucan <jan@jansucan.com>2025-01-26 16:10:51 +0100
committerJán Sučan <jan@jansucan.com>2025-01-26 16:13:00 +0100
commitfb24a40eea3914fe1e112776a92d62d1feeb93fb (patch)
treec413e081d76f54e5eae298685fc7f191c8e7e5f7 /src/format_v2.h
parentfb8fd05da33aa789676603836143691939d0e4d2 (diff)
Reduce diff file version field size
Diffstat (limited to 'src/format_v2.h')
-rw-r--r--src/format_v2.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/format_v2.h b/src/format_v2.h
index e1c752a..f79df1e 100644
--- a/src/format_v2.h
+++ b/src/format_v2.h
@@ -36,7 +36,7 @@ namespace FormatV2
{
const std::string FileSignature{"diff-dd image"};
-const uint16_t FileVersion{2};
+const uint8_t FileVersion{2};
const size_t RecordHeaderSize{sizeof(uint64_t) + sizeof(uint32_t)};
struct RecordData {
@@ -77,7 +77,7 @@ class Writer
{
m_writer.write(FileSignature.data(), FileSignature.size());
- uint16_t val{htobe16(FileVersion)};
+ uint8_t val{FileVersion};
m_writer.write(reinterpret_cast<char *>(&val), sizeof(val));
};
@@ -123,13 +123,13 @@ class Reader
throw new Error("wrong file header signature");
}
- uint16_t rawVersion;
- r = {m_reader.read(sizeof(rawVersion),
- reinterpret_cast<char *>(&rawVersion))};
- if (r < sizeof(rawVersion)) {
+ uint8_t version;
+ r = {
+ m_reader.read(sizeof(version), reinterpret_cast<char *>(&version))};
+ if (r < sizeof(version)) {
throw new Error("cannot read file header version");
}
- if (be16toh(rawVersion) != FileVersion) {
+ if (version != FileVersion) {
throw new Error("wrong file header version");
}
};