summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2018-11-09 10:04:04 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2018-11-14 14:18:08 (GMT)
commitccad2debbf8d7322c9d2b517763d7b8e3902a828 (patch)
tree50054ea69dcf21179920ffdde5790908e48848d8 /Swiften/QA/FileTransferTest/FileTransferTest.cpp
parentc7ad127218e3901e0006e75aa7e1399b449a845e (diff)
downloadswift-ccad2debbf8d7322c9d2b517763d7b8e3902a828.zip
swift-ccad2debbf8d7322c9d2b517763d7b8e3902a828.tar.bz2
Address bad_numeric_casts for filetransfers
The filetransfer blockSize is now an unsigned integer, as 0 could be used to denote an invalid block size as well (and indeed, already indicated that better than -1 did). All use of numeric_cast in filetransfer code has been fixed to deal with the possibility of thrown exceptions. Test-Information: Unit tests pass on macOS and Debian Change-Id: I1833d553bae071238be20ebc386ef602effb78b0
Diffstat (limited to 'Swiften/QA/FileTransferTest/FileTransferTest.cpp')
-rw-r--r--Swiften/QA/FileTransferTest/FileTransferTest.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/Swiften/QA/FileTransferTest/FileTransferTest.cpp b/Swiften/QA/FileTransferTest/FileTransferTest.cpp
index ebdb36a..7d69277 100644
--- a/Swiften/QA/FileTransferTest/FileTransferTest.cpp
+++ b/Swiften/QA/FileTransferTest/FileTransferTest.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,7 +8,6 @@
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
-#include <boost/numeric/conversion/cast.hpp>
#include <Swiften/Base/Debug.h>
@@ -78,14 +77,14 @@ class FileTransferTest {
sendFilePath_ = boost::filesystem::unique_path("ft_send_%%%%%%%%%%%%%%%%.bin");
receiveFilePath_ = boost::filesystem::unique_path("ft_receive_%%%%%%%%%%%%%%%%.bin");
- size_t size = 1024 + boost::numeric_cast<size_t>(randGen.generateRandomInteger(1024 * 10));
+ size_t size = 1024 + static_cast<size_t>(randGen.generateRandomInteger(1024 * 10));
sendData_.resize(size);
for (unsigned char& n : sendData_) {
- n = boost::numeric_cast<unsigned char>(randGen.generateRandomInteger(255));
+ n = static_cast<unsigned char>(randGen.generateRandomInteger(255));
}
std::ofstream outfile(sendFilePath_.native().c_str(), std::ios::out | std::ios::binary);
- outfile.write(reinterpret_cast<char *>(&sendData_[0]), boost::numeric_cast<ptrdiff_t>(sendData_.size()));
+ outfile.write(reinterpret_cast<char *>(&sendData_[0]), static_cast<ptrdiff_t>(sendData_.size()));
outfile.close();
}