Browse Source

fixed some warnings that appeared on some systems when building

Marcel 6 years ago
parent
commit
4e521eb1b7
2 changed files with 15 additions and 15 deletions
  1. 14 14
      code_boost/src/cxx/botnet_comm_processor.cpp
  2. 1 1
      code_boost/src/cxx/statistics.cpp

+ 14 - 14
code_boost/src/cxx/botnet_comm_processor.cpp

@@ -51,7 +51,7 @@ int botnet_comm_processor::get_message_count(){
  * @param assignment The XML attribute assignment in notation: attribute="value"
  */
 void botnet_comm_processor::process_xml_attrib_assign(abstract_msg &msg, const std::string &assignment) {
-    int split_pos = assignment.find("=");
+    std::size_t split_pos = assignment.find("=");
     if (split_pos != std::string::npos){
         std::string key = assignment.substr(0, split_pos);
         std::string value = assignment.substr(split_pos + 2, assignment.length() - 1);
@@ -96,7 +96,7 @@ unsigned int botnet_comm_processor::parse_csv(const std::string &filepath){
         // iterate over every key:value entry
         for (std::string pair; std::getline(line_stream, pair, ','); ){
             boost::replace_all(pair, " ", "");
-            int split_pos = pair.find(":");
+            std::size_t split_pos = pair.find(":");
             if (split_pos != std::string::npos){
                 std::string key = pair.substr(0, split_pos);
                 std::string value = pair.substr(split_pos + 1, pair.length());
@@ -185,7 +185,7 @@ std::string botnet_comm_processor::write_xml(const std::string &filename){
  */
 py::list botnet_comm_processor::get_messages(unsigned int start_idx, unsigned int end_idx){
     py::list py_messages;
-    for (int i = start_idx; i <= end_idx; i++){
+    for (std::size_t i = start_idx; i <= end_idx; i++){
         if (i >= messages.size())
             break;
         py::dict py_msg;
@@ -213,7 +213,7 @@ py::list botnet_comm_processor::find_optimal_interval(int number_ids, double max
     std::vector<std::future<std::vector<comm_interval> > > futures;
 
     // create as many threads as can run concurrently and assign them respective sections
-    for (int i = 0; i < logical_thread_count; i++){
+    for (std::size_t i = 0; i < logical_thread_count; i++){
         unsigned int start_idx = (i * messages.size() / logical_thread_count);
         unsigned int end_idx = (i + 1) * messages.size() / logical_thread_count;
         std::promise<std::vector<comm_interval> > p;  // use promises to retrieve return values
@@ -282,11 +282,11 @@ void botnet_comm_processor::find_optimal_interval_helper(std::promise<std::vecto
         if (greater_than(cur_int_time, max_int_time) || idx_high >= messages.size()){
             std::set<unsigned int> interval_ids;
 
-            for (int i = 0; i < init_ids.size(); i++) 
+            for (std::size_t i = 0; i < init_ids.size(); i++) 
                 interval_ids.insert(init_ids[i]);
 
             // if the interval contains enough initiator IDs, add it to possible_intervals
-            if (interval_ids.size() >= number_ids){
+            if (interval_ids.size() >= (unsigned int) number_ids){
                 comm_interval interval = {interval_ids, comm_sum, idx_low, idx_high - 1};
                 // reset possible intervals if new maximum of communication is found
                 if (comm_sum > cur_highest_sum){
@@ -306,7 +306,7 @@ void botnet_comm_processor::find_optimal_interval_helper(std::promise<std::vecto
 
         // let idx_low "catch up" so that the current interval time fits into the maximum time period again
         while (greater_than(cur_int_time, max_int_time)){
-            if (idx_low >= end_idx)
+            if (idx_low >= (unsigned int) end_idx)
                 goto end; 
 
             abstract_msg &cur_msg = messages[idx_low];
@@ -356,7 +356,7 @@ py::dict botnet_comm_processor::find_interval_from_startidx(int start_idx, int n
     std::deque<unsigned int> init_ids;  // the initiator IDs seen in the current interval in order of appearance
     py::dict comm_interval_py;  // the communication interval that is returned
 
-    if (start_idx >= messages.size()){
+    if ((unsigned int) start_idx >= messages.size()){
         return comm_interval_py;
     }
 
@@ -370,11 +370,11 @@ py::dict botnet_comm_processor::find_interval_from_startidx(int start_idx, int n
         if (greater_than(cur_int_time, max_int_time) || cur_idx >= messages.size()){
             std::set<unsigned int> interval_ids;
 
-            for (int i = 0; i < init_ids.size(); i++) 
+            for (std::size_t i = 0; i < init_ids.size(); i++) 
                 interval_ids.insert(init_ids[i]);
 
             // if the interval contains enough initiator IDs, convert it to python representation and return it
-            if (interval_ids.size() >= number_ids){
+            if (interval_ids.size() >= (unsigned int) number_ids){
                 py::list py_ids;
                 for (const auto &id : interval_ids){
                     py_ids.append(id);
@@ -432,11 +432,11 @@ py::dict botnet_comm_processor::find_interval_from_endidx(int end_idx, int numbe
         if (greater_than(cur_int_time, max_int_time) || cur_idx < 0){
             std::set<unsigned int> interval_ids;
 
-            for (int i = 0; i < init_ids.size(); i++) 
+            for (std::size_t i = 0; i < init_ids.size(); i++) 
                 interval_ids.insert(init_ids[i]);
 
             // if the interval contains enough initiator IDs, convert it to python representation and return it
-            if (interval_ids.size() >= number_ids){
+            if (interval_ids.size() >= (unsigned int) number_ids){
                 py::list py_ids;
                 for (const auto &id : interval_ids){
                     py_ids.append(id);
@@ -476,14 +476,14 @@ py::list botnet_comm_processor::get_interval_init_ids(int start_idx, int end_idx
     std::set<unsigned int> interval_ids;
     py::list py_ids;  // the communication interval that is returned
 
-    if (start_idx >= messages.size()){
+    if ((unsigned int) start_idx >= messages.size()){
         return py_ids;
     }
 
     // Iterate over all messages starting at start_idx until the duration or the current index exceeds a boundary
     while (1){
         // if messages have been processed
-        if (cur_idx >= messages.size() || cur_idx > end_idx){
+        if (cur_idx >= messages.size() || cur_idx > (unsigned int) end_idx){
             for (const auto &id : interval_ids)
                 py_ids.append(id);
             return py_ids;

+ 1 - 1
code_boost/src/cxx/statistics.cpp

@@ -350,7 +350,7 @@ void statistics::createCommIntervalStats(){
             std::chrono::microseconds time_between_ints_sum = (std::chrono::microseconds) 0;
             std::chrono::microseconds summed_int_duration = intervals[0].end - intervals[0].start;
 
-            for (int i = 1; i < intervals.size(); i++) {
+            for (std::size_t i = 1; i < intervals.size(); i++) {
                 summed_pkts_count += intervals[i].pkts_count;
                 summed_int_duration += intervals[i].end - intervals[i].start;
                 time_between_ints_sum += intervals[i].start - intervals[i - 1].end;