[clang-tidy] use default member init

Found with modernize-use-default-member-init

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-03-17 20:52:46 -07:00 committed by Max Kellermann
parent d2115e908a
commit 7fe49cf24d
7 changed files with 13 additions and 16 deletions

View File

@ -31,11 +31,11 @@
#include <map> #include <map>
struct SearchStats { struct SearchStats {
unsigned n_songs; unsigned n_songs{0};
std::chrono::duration<std::uint64_t, SongTime::period> total_duration; std::chrono::duration<std::uint64_t, SongTime::period> total_duration;
constexpr SearchStats() constexpr SearchStats()
:n_songs(0), total_duration(0) {} : total_duration(0) {}
}; };
class TagCountMap : public std::map<std::string, SearchStats> { class TagCountMap : public std::map<std::string, SearchStats> {

View File

@ -79,8 +79,8 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path,
#ifdef ENABLE_ZLIB #ifdef ENABLE_ZLIB
compress(_compress), compress(_compress),
#endif #endif
cache_path(nullptr), cache_path(nullptr)
prefixed_light_song(nullptr) { {
} }
DatabasePtr DatabasePtr

View File

@ -56,9 +56,9 @@ class PasswdEntry
passwd pw; passwd pw;
#endif #endif
passwd *result; passwd *result{nullptr};
public: public:
PasswdEntry() : result(nullptr) { } PasswdEntry() = default;
bool ReadByName(const char *name) { bool ReadByName(const char *name) {
#ifdef HAVE_GETPWNAM_R #ifdef HAVE_GETPWNAM_R

View File

@ -40,7 +40,7 @@ struct AsxParser {
*/ */
enum { enum {
ROOT, ENTRY, ROOT, ENTRY,
} state; } state{ROOT};
/** /**
* The current tag within the "entry" element. This is only * The current tag within the "entry" element. This is only
@ -56,8 +56,7 @@ struct AsxParser {
TagBuilder tag_builder; TagBuilder tag_builder;
AsxParser() AsxParser() = default;
:state(ROOT) {}
}; };

View File

@ -57,9 +57,9 @@ ParsePls(TextInputStream &is, std::forward_list<DetachedSong> &songs)
struct Entry { struct Entry {
std::string file, title; std::string file, title;
int length; int length{-1};
Entry():length(-1) {} Entry() = default;
}; };
static constexpr unsigned MAX_ENTRIES = 65536; static constexpr unsigned MAX_ENTRIES = 65536;

View File

@ -40,7 +40,7 @@ struct RssParser {
*/ */
enum { enum {
ROOT, ITEM, ROOT, ITEM,
} state; } state{ROOT};
/** /**
* The current tag within the "entry" element. This is only * The current tag within the "entry" element. This is only
@ -57,8 +57,7 @@ struct RssParser {
TagBuilder tag_builder; TagBuilder tag_builder;
RssParser() RssParser() = default;
:state(ROOT) {}
}; };
static void XMLCALL static void XMLCALL

View File

@ -42,8 +42,7 @@ Tag::Clear() noexcept
Tag::Tag(const Tag &other) noexcept Tag::Tag(const Tag &other) noexcept
:duration(other.duration), has_playlist(other.has_playlist), :duration(other.duration), has_playlist(other.has_playlist),
num_items(other.num_items), num_items(other.num_items)
items(nullptr)
{ {
if (num_items > 0) { if (num_items > 0) {
items = new TagItem *[num_items]; items = new TagItem *[num_items];