Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Nov 23, 2023
1 parent 7561770 commit 7301263
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions include/ylt/struct_pack/endian_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ template <std::size_t block_size, typename writer_t, typename T>
void low_bytes_write_wrapper(writer_t& writer, const T& elem) {
static_assert(sizeof(T) >= block_size);
if constexpr (is_system_little_endian || block_size == sizeof(T)) {
const char* SP_RESTRICT data = (const char*)&elem;
const char* data = (const char*)&elem;
writer.write(data, block_size);
}
else {
const char* SP_RESTRICT data = sizeof(T) - block_size + (const char*)&elem;
const char* data = sizeof(T) - block_size + (const char*)&elem;
if constexpr (block_size == 1) {
writer.write((char*)&data, block_size);
writer.write(data, block_size);
}
else if constexpr (block_size == 2) {
auto tmp = bswap16(*(uint16_t*)data);
Expand Down Expand Up @@ -230,11 +230,11 @@ template <std::size_t block_size, typename reader_t, typename T>
bool low_bytes_read_wrapper(reader_t& reader, T& elem) {
static_assert(sizeof(T) >= block_size);
if constexpr (is_system_little_endian || block_size == sizeof(T)) {
char* SP_RESTRICT data = (char*)&elem;
char* data = (char*)&elem;
return static_cast<bool>(reader.read(data, block_size));
}
else {
char* SP_RESTRICT data = (char*)&elem + sizeof(T) - block_size;
char* data = (char*)&elem + sizeof(T) - block_size;
if constexpr (block_size > 1) {
char tmp[block_size];
bool res = static_cast<bool>(reader.read(tmp, block_size));
Expand Down
3 changes: 1 addition & 2 deletions include/ylt/struct_pack/unpacker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class unpacker {
}
}
else {
return {errc::too_width_size, data_len};
return {errc::too_width_size, 0};
}
break;
default:
Expand Down Expand Up @@ -993,7 +993,6 @@ class unpacker {
}
else if constexpr (is_little_endian_copyable<sizeof(
value_type)>) {

item.resize(size64);
if SP_UNLIKELY (!read_bytes_array(
reader_, (char *)item.data(),
Expand Down

0 comments on commit 7301263

Please sign in to comment.