From 68051af82c7ab5ca16585f89845c9b5c7a6003cc Mon Sep 17 00:00:00 2001 From: Lucas Czech Date: Tue, 2 Jul 2024 15:36:44 +0200 Subject: [PATCH] Minor fixes for compiler matrix --- .github/workflows/ci.yaml | 5 ++++- .../utils/containers/sequential_output_buffer.hpp | 8 ++++---- lib/genesis/utils/core/info.cpp | 10 ++++++++-- test/src/utils/containers/sequential_output_buffer.cpp | 8 ++++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 894a6fa8..375f2913 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -244,7 +244,10 @@ jobs: # 3: Install gdb for debugging output. run: | sudo apt-get install autoconf automake zlib1g-dev libbz2-dev liblzma-dev - sudo apt-get install libtinfo5 gdb + sudo apt-get install gdb + if [[ ${{ matrix.os }} != ubuntu-24.04 ]] ; then + sudo apt-get install libtinfo5 + fi # sudo apt-get remove autoconf # sudo apt-get install autoconf2.64 liblzma-dev libbz2-dev diff --git a/lib/genesis/utils/containers/sequential_output_buffer.hpp b/lib/genesis/utils/containers/sequential_output_buffer.hpp index 53fe2cf3..49525e31 100644 --- a/lib/genesis/utils/containers/sequential_output_buffer.hpp +++ b/lib/genesis/utils/containers/sequential_output_buffer.hpp @@ -72,11 +72,11 @@ namespace utils { * Example: * * // Create a buffer that prints lines in the correct order. - * auto seq_out_buff = SequentialOutputBuffer( + * SequentialOutputBuffer seq_out_buff{ * [&]( std::string&& line ){ * std::cout << line << "\n"; * } - * ); + * }; * * // Emplace elements in the buffer. This loop can be run in a thread pool, * // where each thread processed a subset of lines in some order. In that case, @@ -156,10 +156,10 @@ class SequentialOutputBuffer } SequentialOutputBuffer( SequentialOutputBuffer const& ) = delete; - SequentialOutputBuffer( SequentialOutputBuffer&& ) = default; + SequentialOutputBuffer( SequentialOutputBuffer&& ) = delete; SequentialOutputBuffer& operator= ( SequentialOutputBuffer const& ) = delete; - SequentialOutputBuffer& operator= ( SequentialOutputBuffer&& ) = default; + SequentialOutputBuffer& operator= ( SequentialOutputBuffer&& ) = delete; // ------------------------------------------------------------------------- // Element Access diff --git a/lib/genesis/utils/core/info.cpp b/lib/genesis/utils/core/info.cpp index 9d98e4bd..2946334d 100644 --- a/lib/genesis/utils/core/info.cpp +++ b/lib/genesis/utils/core/info.cpp @@ -1613,12 +1613,15 @@ size_t info_current_file_count() return 0.0; } - fscanf( + auto const scanned = fscanf( file, "cpu %llu %llu %llu %llu", &lastTotalUser, &lastTotalUserLow, &lastTotalSys, &lastTotalIdle ); fclose(file); num_processors = info_process_number_of_processors_(); + if( scanned != 4 ) { + return 0.0; + } initialized = true; return 0.0; @@ -1632,11 +1635,14 @@ size_t info_current_file_count() if( ! file ) { return 0.0; } - fscanf( + auto const scanned = fscanf( file, "cpu %llu %llu %llu %llu", &totalUser, &totalUserLow, &totalSys, &totalIdle ); fclose(file); + if( scanned != 4 ) { + return 0.0; + } if( totalUser < lastTotalUser || totalUserLow < lastTotalUserLow || diff --git a/test/src/utils/containers/sequential_output_buffer.cpp b/test/src/utils/containers/sequential_output_buffer.cpp index 5f9fa600..ab123092 100644 --- a/test/src/utils/containers/sequential_output_buffer.cpp +++ b/test/src/utils/containers/sequential_output_buffer.cpp @@ -55,11 +55,11 @@ void test_sequential_output_buffer_() results.reserve( max_elem ); // Make a buffer that on output writes the value to the results vector. - auto buff = SequentialOutputBuffer( + SequentialOutputBuffer buff{ [&]( size_t value ){ results.push_back( value ); } - ); + }; // Make a vector with all sequential numbers up to the max, randomized. auto values = std::vector( max_elem ); @@ -111,11 +111,11 @@ void test_sequential_output_buffer_parallel_() results.reserve( max_elem ); // Make a buffer that on output writes the value to the results vector. - auto seq_out_buff = SequentialOutputBuffer( + SequentialOutputBuffer seq_out_buff{ [&]( size_t value ){ results.push_back( value ); } - ); + }; // Make a vector with all sequential numbers up to the max, randomized. auto values = std::vector( max_elem );