Fix some compiler warnings and an issue with ox_atio.

This commit is contained in:
2016-12-14 22:36:56 -06:00
parent c66533fc70
commit b40faa70f3
3 changed files with 9 additions and 6 deletions
+7 -4
View File
@@ -5,6 +5,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <iostream>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -17,6 +18,7 @@
#endif #endif
using namespace ox::fs; using namespace ox::fs;
using namespace std;
const static auto oxfstoolVersion = "1.0.0"; const static auto oxfstoolVersion = "1.0.0";
const static auto usage = "usage:\n" 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); auto size = ::ox_strlen(str);
const auto lastChar = str[size-1]; const auto lastChar = str[size-1];
auto multiplier = 1; auto multiplier = 1;
@@ -69,7 +71,7 @@ uint64_t bytes(const char *str) {
multiplier = -1; multiplier = -1;
} }
} }
const auto retval = ((uint64_t) ::ox_atoi(copy)) * multiplier; const auto retval = ((size_t) ox_atoi(copy)) * multiplier;
delete copy; delete copy;
return retval; return retval;
} }
@@ -79,12 +81,13 @@ int format(int argc, char **args) {
auto err = 0; auto err = 0;
if (argc >= 5) { if (argc >= 5) {
auto type = ox_atoi(args[2]); auto type = ox_atoi(args[2]);
cout << args[3] << endl;
auto size = bytes(args[3]); auto size = bytes(args[3]);
auto path = args[4]; auto path = args[4];
auto buff = (uint8_t*) malloc(size); auto buff = (uint8_t*) malloc(size);
printf("Size: %llu bytes\n", size); cout << "Size: " << size << " bytes\n";
printf("Type: %d\n", type); cout << "Type: " << type << endl;
if (size < sizeof(FileStore64)) { if (size < sizeof(FileStore64)) {
err = 1; err = 1;
+1 -1
View File
@@ -34,7 +34,7 @@ int ox_atoi(const char *str) {
int total = 0; int total = 0;
int multiplier = 1; 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; total += (str[i] - '0') * multiplier;
multiplier *= 10; multiplier *= 10;
} }
+1 -1
View File
@@ -7,7 +7,7 @@
*/ */
#pragma once #pragma once
typedef char int8_t; typedef signed char int8_t;
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef short int16_t; typedef short int16_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;