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 @@
1/* 1/*
2 * Copyright (c) 2014-2016 Isode Limited. 2 * Copyright (c) 2014-2018 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -8,7 +8,6 @@
8 8
9#include <boost/algorithm/string.hpp> 9#include <boost/algorithm/string.hpp>
10#include <boost/filesystem.hpp> 10#include <boost/filesystem.hpp>
11#include <boost/numeric/conversion/cast.hpp>
12 11
13 12
14#include <Swiften/Base/Debug.h> 13#include <Swiften/Base/Debug.h>
@@ -78,14 +77,14 @@ class FileTransferTest {
78 sendFilePath_ = boost::filesystem::unique_path("ft_send_%%%%%%%%%%%%%%%%.bin"); 77 sendFilePath_ = boost::filesystem::unique_path("ft_send_%%%%%%%%%%%%%%%%.bin");
79 receiveFilePath_ = boost::filesystem::unique_path("ft_receive_%%%%%%%%%%%%%%%%.bin"); 78 receiveFilePath_ = boost::filesystem::unique_path("ft_receive_%%%%%%%%%%%%%%%%.bin");
80 79
81 size_t size = 1024 + boost::numeric_cast<size_t>(randGen.generateRandomInteger(1024 * 10)); 80 size_t size = 1024 + static_cast<size_t>(randGen.generateRandomInteger(1024 * 10));
82 sendData_.resize(size); 81 sendData_.resize(size);
83 for (unsigned char& n : sendData_) { 82 for (unsigned char& n : sendData_) {
84 n = boost::numeric_cast<unsigned char>(randGen.generateRandomInteger(255)); 83 n = static_cast<unsigned char>(randGen.generateRandomInteger(255));
85 } 84 }
86 85
87 std::ofstream outfile(sendFilePath_.native().c_str(), std::ios::out | std::ios::binary); 86 std::ofstream outfile(sendFilePath_.native().c_str(), std::ios::out | std::ios::binary);
88 outfile.write(reinterpret_cast<char *>(&sendData_[0]), boost::numeric_cast<ptrdiff_t>(sendData_.size())); 87 outfile.write(reinterpret_cast<char *>(&sendData_[0]), static_cast<ptrdiff_t>(sendData_.size()));
89 outfile.close(); 88 outfile.close();
90 } 89 }
91 90