mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 23:43:26 +01:00
Correct ato* clang warnings
This commit is contained in:
parent
135fe9e98b
commit
4e19edfd56
@ -644,7 +644,7 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() {
|
|||||||
cout << "\n" << _("Enter the number corresponding to your choice: ");
|
cout << "\n" << _("Enter the number corresponding to your choice: ");
|
||||||
char answer[10];
|
char answer[10];
|
||||||
char *res = fgets(answer, sizeof(answer), stdin);
|
char *res = fgets(answer, sizeof(answer), stdin);
|
||||||
int cipherNum = (res == nullptr ? 0 : atoi(answer));
|
int cipherNum = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
|
|
||||||
if (cipherNum < 1 || cipherNum > (int)algorithms.size()) {
|
if (cipherNum < 1 || cipherNum > (int)algorithms.size()) {
|
||||||
@ -688,7 +688,7 @@ static Interface selectNameCoding() {
|
|||||||
cout << "\n" << _("Enter the number corresponding to your choice: ");
|
cout << "\n" << _("Enter the number corresponding to your choice: ");
|
||||||
char answer[10];
|
char answer[10];
|
||||||
char *res = fgets(answer, sizeof(answer), stdin);
|
char *res = fgets(answer, sizeof(answer), stdin);
|
||||||
int algNum = (res == nullptr ? 0 : atoi(answer));
|
int algNum = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
|
|
||||||
if (algNum < 1 || algNum > (int)algorithms.size()) {
|
if (algNum < 1 || algNum > (int)algorithms.size()) {
|
||||||
@ -755,7 +755,7 @@ static int selectKeySize(const Cipher::CipherAlgorithm &alg) {
|
|||||||
|
|
||||||
char answer[10];
|
char answer[10];
|
||||||
char *res = fgets(answer, sizeof(answer), stdin);
|
char *res = fgets(answer, sizeof(answer), stdin);
|
||||||
int keySize = (res == nullptr ? 0 : atoi(answer));
|
int keySize = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
|
|
||||||
keySize = alg.keyLength.closest(keySize);
|
keySize = alg.keyLength.closest(keySize);
|
||||||
@ -795,8 +795,8 @@ static int selectBlockSize(const Cipher::CipherAlgorithm &alg) {
|
|||||||
char *res = fgets(answer, sizeof(answer), stdin);
|
char *res = fgets(answer, sizeof(answer), stdin);
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
|
|
||||||
if (res != nullptr && atoi(answer) >= alg.blockSize.min()) {
|
if (res != nullptr && (int)strtol(answer, nullptr, 10) >= alg.blockSize.min()) {
|
||||||
blockSize = atoi(answer);
|
blockSize = (int)strtol(answer, nullptr, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
blockSize = alg.blockSize.closest(blockSize);
|
blockSize = alg.blockSize.closest(blockSize);
|
||||||
@ -900,7 +900,7 @@ static void selectBlockMAC(int *macBytes, int *macRandBytes, bool forceMac) {
|
|||||||
char *res = fgets(answer, sizeof(answer), stdin);
|
char *res = fgets(answer, sizeof(answer), stdin);
|
||||||
cout << "\n";
|
cout << "\n";
|
||||||
|
|
||||||
randSize = (res == nullptr ? 0 : atoi(answer));
|
randSize = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
|
||||||
if (randSize < 0) {
|
if (randSize < 0) {
|
||||||
randSize = 0;
|
randSize = 0;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <algorithm> // for remove_if
|
#include <algorithm> // for remove_if
|
||||||
#include <cstring> // for NULL
|
#include <cstring> // for NULL
|
||||||
#include <fstream> // for ifstream
|
#include <fstream> // for ifstream
|
||||||
|
#include <limits>
|
||||||
#include <memory> // for shared_ptr
|
#include <memory> // for shared_ptr
|
||||||
#include <sstream> // for ostringstream
|
#include <sstream> // for ostringstream
|
||||||
|
|
||||||
@ -60,7 +61,15 @@ bool XmlValue::read(const char *path, int *out) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = atoi(value->text().c_str());
|
char * e;
|
||||||
|
long lout = strtol(value->text().c_str(), &e, 10);
|
||||||
|
if (*e != '\0') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (lout < std::numeric_limits<int>::min() || lout > std::numeric_limits<int>::max()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*out = (int)lout;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +79,9 @@ bool XmlValue::read(const char *path, long *out) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = atol(value->text().c_str());
|
char * e;
|
||||||
return true;
|
*out = strtol(value->text().c_str(), &e, 10);
|
||||||
|
return (*e == '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlValue::read(const char *path, double *out) const {
|
bool XmlValue::read(const char *path, double *out) const {
|
||||||
@ -80,8 +90,9 @@ bool XmlValue::read(const char *path, double *out) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = atof(value->text().c_str());
|
char * e;
|
||||||
return true;
|
*out = strtod(value->text().c_str(), &e);
|
||||||
|
return (*e == '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlValue::read(const char *path, bool *out) const {
|
bool XmlValue::read(const char *path, bool *out) const {
|
||||||
@ -90,8 +101,9 @@ bool XmlValue::read(const char *path, bool *out) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = (atoi(value->text().c_str()) != 0);
|
char * e;
|
||||||
return true;
|
*out = (strtol(value->text().c_str(), &e, 10) != 0);
|
||||||
|
return (*e == '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlValue::readB64(const char *path, unsigned char *data,
|
bool XmlValue::readB64(const char *path, unsigned char *data,
|
||||||
|
Loading…
Reference in New Issue
Block a user