From b40faa70f3dfc0762966beb9be50b9e61c174d77 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 14 Dec 2016 22:36:56 -0600 Subject: [PATCH] Fix some compiler warnings and an issue with ox_atio. --- src/ox/fs/oxfstool.cpp | 11 +++++++---- src/ox/std/strops.cpp | 2 +- src/ox/std/types.hpp | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ox/fs/oxfstool.cpp b/src/ox/fs/oxfstool.cpp index baed8b380..4b037ce48 100644 --- a/src/ox/fs/oxfstool.cpp +++ b/src/ox/fs/oxfstool.cpp @@ -5,6 +5,7 @@ * 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 #include #include #include @@ -17,6 +18,7 @@ #endif using namespace ox::fs; +using namespace std; const static auto oxfstoolVersion = "1.0.0"; const static auto usage = "usage:\n" @@ -44,7 +46,7 @@ char *loadFileBuff(const char *path, ::size_t *sizeOut = nullptr) { } } -uint64_t bytes(const char *str) { +size_t bytes(const char *str) { auto size = ::ox_strlen(str); const auto lastChar = str[size-1]; auto multiplier = 1; @@ -69,7 +71,7 @@ uint64_t bytes(const char *str) { multiplier = -1; } } - const auto retval = ((uint64_t) ::ox_atoi(copy)) * multiplier; + const auto retval = ((size_t) ox_atoi(copy)) * multiplier; delete copy; return retval; } @@ -79,12 +81,13 @@ int format(int argc, char **args) { auto err = 0; if (argc >= 5) { auto type = ox_atoi(args[2]); + cout << args[3] << endl; auto size = bytes(args[3]); auto path = args[4]; auto buff = (uint8_t*) malloc(size); - printf("Size: %llu bytes\n", size); - printf("Type: %d\n", type); + cout << "Size: " << size << " bytes\n"; + cout << "Type: " << type << endl; if (size < sizeof(FileStore64)) { err = 1; diff --git a/src/ox/std/strops.cpp b/src/ox/std/strops.cpp index 1332ccc11..f1900748b 100644 --- a/src/ox/std/strops.cpp +++ b/src/ox/std/strops.cpp @@ -34,7 +34,7 @@ int ox_atoi(const char *str) { int total = 0; int multiplier = 1; - for (auto i = ox_strlen(str) - 1; i != 0; i--) { + for (auto i = ox_strlen(str) - 1; i != -1; i--) { total += (str[i] - '0') * multiplier; multiplier *= 10; } diff --git a/src/ox/std/types.hpp b/src/ox/std/types.hpp index 0c62a2472..2dbec740c 100644 --- a/src/ox/std/types.hpp +++ b/src/ox/std/types.hpp @@ -7,7 +7,7 @@ */ #pragma once -typedef char int8_t; +typedef signed char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t;