]> git.tdb.fi Git - libs/datafile.git/commitdiff
Use default member initializers in datatool
authorMikko Rasa <tdb@tdb.fi>
Fri, 15 Sep 2023 21:03:21 +0000 (00:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 15 Sep 2023 21:03:21 +0000 (00:03 +0300)
This also fixes one uninitialized flag.

tool/compiler.cpp
tool/compiler.h
tool/packer.cpp
tool/packer.h
tool/tool.cpp
tool/tool.h

index b7f310c9c556d0deb3b0dac2b803049fa7868875..cae7f83b23da90ba51e466a6b1f32bdf64053ea4 100644 (file)
@@ -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);
index 046209929c336e14a62153ee9352693739c2a889..5092cd3cfdbbe35d3370f6d17d83479fb51710a3 100644 (file)
@@ -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 &);
index 381297ea4f75608b23304bdac9fb6cee30bd3205..0380ee9ccf4661fc6825c23b15dd04414d7578a5 100644 (file)
@@ -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()
index 313ee033216969b9d8931435098848e26d6c9b54..b89f073fb902813ad3356477c522d3460e5d37f6 100644 (file)
@@ -20,9 +20,9 @@ private:
        typedef std::list<Object> ObjectList;
 
        DataTool &tool;
-       Msp::IO::BufferedFile *tmp_file;
+       Msp::IO::BufferedFile *tmp_file = nullptr;
        std::list<Msp::DataFile::Statement> directory;
-       unsigned dir_alloc;
+       unsigned dir_alloc = 0;
 
 public:
        Packer(DataTool &);
index 2f52724f75543546ebd4b494448550696ad69bdc..cf34474338e5c63fe7ae07139e0822ebdd3e0c68 100644 (file)
 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");
index 354456ccab4a51276a3176c1a99be92cef0f00f2..2012429714b311d1f45ac72ad0a3788fd20bfcf0 100644 (file)
@@ -9,17 +9,17 @@ class DataTool: public Msp::RegisteredApplication<DataTool>
 {
 private:
        std::list<std::string> 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);