From 220349921596d2f1e36574667814bf0981cfbbbf Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 9 Nov 2017 22:14:22 -0500 Subject: [PATCH] Enables -Wreorder and corrects a few of the more trivial fixes thereby suggested. --- Machines/ZX8081/Video.cpp | 6 +----- Machines/ZX8081/Video.hpp | 7 ++++--- OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj | 8 ++++++++ Outputs/Speaker.hpp | 9 +++++---- Storage/Tape/Formats/TapePRG.cpp | 4 ---- Storage/Tape/Formats/TapePRG.hpp | 8 ++++---- Storage/Tape/Parsers/TapeParser.hpp | 5 ++--- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Machines/ZX8081/Video.cpp b/Machines/ZX8081/Video.cpp index 89c73fc9e..f92e60479 100644 --- a/Machines/ZX8081/Video.cpp +++ b/Machines/ZX8081/Video.cpp @@ -11,11 +11,7 @@ using namespace ZX8081; Video::Video() : - crt_(new Outputs::CRT::CRT(207 * 2, 1, Outputs::CRT::DisplayType::PAL50, 1)), - line_data_(nullptr), - line_data_pointer_(nullptr), - cycles_since_update_(0), - sync_(false) { + crt_(new Outputs::CRT::CRT(207 * 2, 1, Outputs::CRT::DisplayType::PAL50, 1)) { // Set a composite sampling function that assumes 8bpp input grayscale. // TODO: lessen this to 1bpp. diff --git a/Machines/ZX8081/Video.hpp b/Machines/ZX8081/Video.hpp index 29aa00821..d6ef09cf3 100644 --- a/Machines/ZX8081/Video.hpp +++ b/Machines/ZX8081/Video.hpp @@ -42,9 +42,10 @@ class Video { void output_byte(uint8_t byte); private: - bool sync_; - uint8_t *line_data_, *line_data_pointer_; - unsigned int cycles_since_update_; + bool sync_ = false; + uint8_t *line_data_ = nullptr; + uint8_t *line_data_pointer_ = nullptr; + unsigned int cycles_since_update_ = 0; std::shared_ptr crt_; void flush(bool next_sync); diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index e8c6029ad..5510aa6c0 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -3651,6 +3651,10 @@ GCC_WARN_SIGN_COMPARE = YES; INFOPLIST_FILE = "Clock Signal/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + OTHER_CPLUSPLUSFLAGS = ( + "$(OTHER_CFLAGS)", + "-Wreorder", + ); PRODUCT_BUNDLE_IDENTIFIER = "TH.Clock-Signal"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Clock Signal/ClockSignal-Bridging-Header.h"; @@ -3685,6 +3689,10 @@ GCC_WARN_SIGN_COMPARE = YES; INFOPLIST_FILE = "Clock Signal/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + OTHER_CPLUSPLUSFLAGS = ( + "$(OTHER_CFLAGS)", + "-Wreorder", + ); PRODUCT_BUNDLE_IDENTIFIER = "TH.Clock-Signal"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Clock Signal/ClockSignal-Bridging-Header.h"; diff --git a/Outputs/Speaker.hpp b/Outputs/Speaker.hpp index 1b2c77986..5437ffda5 100644 --- a/Outputs/Speaker.hpp +++ b/Outputs/Speaker.hpp @@ -83,7 +83,7 @@ class Speaker { set_needs_updated_filter_coefficients(); } - Speaker() : buffer_in_progress_pointer_(0), requested_number_of_taps_(0), high_frequency_cut_off_(-1.0), _queue(new Concurrency::AsyncTaskQueue) {} + Speaker() : _queue(new Concurrency::AsyncTaskQueue) {} /*! Ensures any deferred processing occurs now. @@ -107,9 +107,10 @@ class Speaker { std::shared_ptr>> queued_functions_; std::vector buffer_in_progress_; - float high_frequency_cut_off_; - size_t buffer_in_progress_pointer_; - size_t number_of_taps_, requested_number_of_taps_; + float high_frequency_cut_off_ = -1.0; + size_t buffer_in_progress_pointer_ = 0; + size_t number_of_taps_; + size_t requested_number_of_taps_ = 0; bool coefficients_are_dirty_; Delegate *delegate_ = nullptr; diff --git a/Storage/Tape/Formats/TapePRG.cpp b/Storage/Tape/Formats/TapePRG.cpp index 8b8bc1d2f..e1131fa8d 100644 --- a/Storage/Tape/Formats/TapePRG.cpp +++ b/Storage/Tape/Formats/TapePRG.cpp @@ -49,10 +49,6 @@ using namespace Storage::Tape; PRG::PRG(const char *file_name) : - bit_phase_(3), - file_phase_(FilePhaseLeadIn), - phase_offset_(0), - copy_mask_(0x80), file_(file_name) { // There's really no way to validate other than that if this file is larger than 64kb, diff --git a/Storage/Tape/Formats/TapePRG.hpp b/Storage/Tape/Formats/TapePRG.hpp index e8a91f63b..907f09a3b 100644 --- a/Storage/Tape/Formats/TapePRG.hpp +++ b/Storage/Tape/Formats/TapePRG.hpp @@ -50,10 +50,10 @@ class PRG: public Tape { FilePhaseHeaderDataGap, FilePhaseData, FilePhaseAtEnd - } file_phase_; - int phase_offset_; + } file_phase_ = FilePhaseLeadIn; + int phase_offset_ = 0; - int bit_phase_; + int bit_phase_ = 3; enum OutputToken { Leader, Zero, @@ -65,7 +65,7 @@ class PRG: public Tape { void get_next_output_token(); uint8_t output_byte_; uint8_t check_digit_; - uint8_t copy_mask_; + uint8_t copy_mask_ = 0x80; }; } diff --git a/Storage/Tape/Parsers/TapeParser.hpp b/Storage/Tape/Parsers/TapeParser.hpp index d171c4dd6..013f7bcdb 100644 --- a/Storage/Tape/Parsers/TapeParser.hpp +++ b/Storage/Tape/Parsers/TapeParser.hpp @@ -20,7 +20,6 @@ namespace Tape { template class Parser { public: - Parser() : has_next_symbol_(false), error_flag_(false) {} /// Resets the error flag. void reset_error_flag() { error_flag_ = false; } /// @returns @c true if an error has occurred since the error flag was last reset; @c false otherwise. @@ -81,9 +80,9 @@ template class Parser { error_flag_ = true; } - bool error_flag_; + bool error_flag_ = false; SymbolType next_symbol_; - bool has_next_symbol_; + bool has_next_symbol_ = false; }; /*!