Fix big endian reading of Inode size
This commit is contained in:
@@ -316,7 +316,7 @@ class FileStore {
|
|||||||
|
|
||||||
template<typename Header>
|
template<typename Header>
|
||||||
typename Header::FsSize_t FileStore<Header>::Inode::size() {
|
typename Header::FsSize_t FileStore<Header>::Inode::size() {
|
||||||
return std::nativizeLittleEndian(sizeof(Inode) + getDataLen());
|
return sizeof(Inode) + getDataLen();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Header>
|
template<typename Header>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
namespace ox {
|
namespace ox {
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
|
|
||||||
inline uint16_t byteSwap(uint16_t i) {
|
inline uint16_t byteSwap(uint16_t i) {
|
||||||
return (i << 8) | (i >> 8);
|
return (i << 8) | (i >> 8);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,3 +28,16 @@ add_test("Test\\ ox_strcmp\\ hijk\\ !=\\ asdf" StrOpsTest "hijk > asdf")
|
|||||||
add_test("Test\\ ox_strcmp\\ read\\ !=\\ resize" StrOpsTest "read < resize")
|
add_test("Test\\ ox_strcmp\\ read\\ !=\\ resize" StrOpsTest "read < resize")
|
||||||
add_test("Test\\ ox_strcmp\\ resize\\ !=\\ read" StrOpsTest "resize > read")
|
add_test("Test\\ ox_strcmp\\ resize\\ !=\\ read" StrOpsTest "resize > read")
|
||||||
add_test("Test\\ ox_strcmp\\ resize\\ ==\\ resize" StrOpsTest "resize == resize")
|
add_test("Test\\ ox_strcmp\\ resize\\ ==\\ resize" StrOpsTest "resize == resize")
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Byte Swap Tests
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
ByteSwapTest
|
||||||
|
byteswap_test.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(ByteSwapTest OxStd)
|
||||||
|
|
||||||
|
add_test("Test\\ nativizeLittleEndian\\ 40\\ ==\\ 671088640" ByteSwapTest "40")
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 - 2017 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <functional>
|
||||||
|
#include <ox/std/std.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace ox::std;
|
||||||
|
|
||||||
|
map<string, function<int()>> tests = {
|
||||||
|
{
|
||||||
|
"40",
|
||||||
|
[]() {
|
||||||
|
cout << (nativizeLittleEndian((uint32_t) 40)) << endl;
|
||||||
|
return !(nativizeLittleEndian((uint32_t) 40) == 671088640);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, const char **args) {
|
||||||
|
if (argc > 1) {
|
||||||
|
auto testName = args[1];
|
||||||
|
if (tests.find(testName) != tests.end()) {
|
||||||
|
return tests[testName]();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user