From: Mikko Rasa Date: Fri, 15 Sep 2023 21:03:21 +0000 (+0300) Subject: Use default member initializers in datatool X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=1bd6d1acfc4ec7358c0546fee61a8f460b237e6c;p=libs%2Fdatafile.git Use default member initializers in datatool This also fixes one uninitialized flag. --- diff --git a/tool/compiler.cpp b/tool/compiler.cpp index b7f310c..cae7f83 100644 --- a/tool/compiler.cpp +++ b/tool/compiler.cpp @@ -8,8 +8,7 @@ using namespace std; using namespace Msp; Compiler::Compiler(DataFile::Writer &w): - writer(w), - reset_src(false) + writer(w) { add("file", &Compiler::file); add("for_each", &Compiler::for_each); diff --git a/tool/compiler.h b/tool/compiler.h index 0462099..5092cd3 100644 --- a/tool/compiler.h +++ b/tool/compiler.h @@ -13,7 +13,7 @@ class Compiler: public Msp::DataFile::Loader private: Msp::DataFile::Writer &writer; - bool reset_src; + bool reset_src = false; public: Compiler(Msp::DataFile::Writer &); diff --git a/tool/packer.cpp b/tool/packer.cpp index 381297e..0380ee9 100644 --- a/tool/packer.cpp +++ b/tool/packer.cpp @@ -14,8 +14,7 @@ using namespace Msp; Packer::Packer(DataTool &t): tool(t), - tmp_file(tempfile()), - dir_alloc(0) + tmp_file(tempfile()) { } IO::BufferedFile *Packer::tempfile() diff --git a/tool/packer.h b/tool/packer.h index 313ee03..b89f073 100644 --- a/tool/packer.h +++ b/tool/packer.h @@ -20,9 +20,9 @@ private: typedef std::list ObjectList; DataTool &tool; - Msp::IO::BufferedFile *tmp_file; + Msp::IO::BufferedFile *tmp_file = nullptr; std::list directory; - unsigned dir_alloc; + unsigned dir_alloc = 0; public: Packer(DataTool &); diff --git a/tool/tool.cpp b/tool/tool.cpp index 2f52724..cf34474 100644 --- a/tool/tool.cpp +++ b/tool/tool.cpp @@ -14,15 +14,7 @@ using namespace std; using namespace Msp; -DataTool::DataTool(int argc, char **argv): - out_fn("-"), - binary(false), - compile(false), - float_size(0), - compress(false), - pack(false), - unpack(false), - debug(false) +DataTool::DataTool(int argc, char **argv) { GetOpt getopt; getopt.add_option('b', "binary", binary, GetOpt::NO_ARG).set_help("Produce a binary datafile"); diff --git a/tool/tool.h b/tool/tool.h index 354456c..2012429 100644 --- a/tool/tool.h +++ b/tool/tool.h @@ -9,17 +9,17 @@ class DataTool: public Msp::RegisteredApplication { private: std::list in_fns; - std::string out_fn; - bool binary; - bool compile; - unsigned float_size; - bool compress; - bool pack; - bool unpack; - bool builtin; + std::string out_fn = "-"; + bool binary = false; + bool compile = false; + unsigned float_size = 0; + bool compress = false; + bool pack = false; + bool unpack = false; + bool builtin = false; std::string builtin_ns; std::string builtin_module; - bool debug; + bool debug = false; public: DataTool(int argc, char **argv);