Fix big endian reading of Inode size

This commit is contained in:
2017-04-09 15:55:39 -05:00
parent 4c55409dc4
commit 4fdf5f48eb
4 changed files with 49 additions and 1 deletions
+1 -1
View File
@@ -316,7 +316,7 @@ class FileStore {
template<typename Header>
typename Header::FsSize_t FileStore<Header>::Inode::size() {
return std::nativizeLittleEndian(sizeof(Inode) + getDataLen());
return sizeof(Inode) + getDataLen();
}
template<typename Header>
+1
View File
@@ -13,6 +13,7 @@
namespace ox {
namespace std {
inline uint16_t byteSwap(uint16_t i) {
return (i << 8) | (i >> 8);
}
+13
View File
@@ -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\\ resize\\ !=\\ read" StrOpsTest "resize > read")
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")
+34
View File
@@ -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;
}