Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #325 from gnustomp/fix-unaligned
Browse files Browse the repository at this point in the history
uv_metadata: use unaligned access functions
  • Loading branch information
cole-miller authored Nov 16, 2022
2 parents 212b609 + 0debe4f commit 7a2d087
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/uv_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
static void uvMetadataEncode(const struct uvMetadata *metadata, void *buf)
{
void *cursor = buf;
bytePut64(&cursor, UV__DISK_FORMAT);
bytePut64(&cursor, metadata->version);
bytePut64(&cursor, metadata->term);
bytePut64(&cursor, metadata->voted_for);
bytePut64Unaligned(&cursor, UV__DISK_FORMAT);
bytePut64Unaligned(&cursor, metadata->version);
bytePut64Unaligned(&cursor, metadata->term);
bytePut64Unaligned(&cursor, metadata->voted_for);
}

/* Decode the content of a metadata file. */
Expand All @@ -27,14 +27,14 @@ static int uvMetadataDecode(const void *buf,
{
const void *cursor = buf;
uint64_t format;
format = byteGet64(&cursor);
format = byteGet64Unaligned(&cursor);
if (format != UV__DISK_FORMAT) {
ErrMsgPrintf(errmsg, "bad format version %ju", format);
return RAFT_MALFORMED;
}
metadata->version = byteGet64(&cursor);
metadata->term = byteGet64(&cursor);
metadata->voted_for = byteGet64(&cursor);
metadata->version = byteGet64Unaligned(&cursor);
metadata->term = byteGet64Unaligned(&cursor);
metadata->voted_for = byteGet64Unaligned(&cursor);

/* Coherence checks that values make sense */
if (metadata->version == 0) {
Expand Down

0 comments on commit 7a2d087

Please sign in to comment.