Skip to content

Commit

Permalink
libmbbootimg: Make constructors, destructors, and comparison operator…
Browse files Browse the repository at this point in the history
…s noexcept where possible

Signed-off-by: Andrew Gunnerson <[email protected]>
  • Loading branch information
chenxiaolong committed Nov 28, 2018
1 parent 9c0f73f commit 268979b
Show file tree
Hide file tree
Showing 30 changed files with 68 additions and 68 deletions.
8 changes: 4 additions & 4 deletions libmbbootimg/include/mbbootimg/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ MB_DECLARE_OPERATORS_FOR_FLAGS(EntryTypes)
class MB_EXPORT Entry
{
public:
Entry(EntryType type);
~Entry();
Entry(EntryType type) noexcept;
~Entry() noexcept;

MB_DEFAULT_COPY_CONSTRUCT_AND_ASSIGN(Entry)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(Entry)

bool operator==(const Entry &rhs) const;
bool operator!=(const Entry &rhs) const;
bool operator==(const Entry &rhs) const noexcept;
bool operator!=(const Entry &rhs) const noexcept;

EntryType type() const;

Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/android_reader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace mb::bootimg::android
class AndroidFormatReader : public detail::FormatReader
{
public:
AndroidFormatReader(bool is_bump);
virtual ~AndroidFormatReader();
AndroidFormatReader(bool is_bump) noexcept;
virtual ~AndroidFormatReader() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(AndroidFormatReader)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(AndroidFormatReader)
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/android_writer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace mb::bootimg::android
class AndroidFormatWriter : public detail::FormatWriter
{
public:
AndroidFormatWriter(bool is_bump);
virtual ~AndroidFormatWriter();
AndroidFormatWriter(bool is_bump) noexcept;
virtual ~AndroidFormatWriter() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(AndroidFormatWriter)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(AndroidFormatWriter)
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/loki_reader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ struct ReadHeaderResult
class LokiFormatReader : public detail::FormatReader
{
public:
LokiFormatReader();
virtual ~LokiFormatReader();
LokiFormatReader() noexcept;
virtual ~LokiFormatReader() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(LokiFormatReader)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(LokiFormatReader)
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/loki_writer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace mb::bootimg::loki
class LokiFormatWriter : public detail::FormatWriter
{
public:
LokiFormatWriter();
virtual ~LokiFormatWriter();
LokiFormatWriter() noexcept;
virtual ~LokiFormatWriter() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(LokiFormatWriter)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(LokiFormatWriter)
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/mtk_reader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace mb::bootimg::mtk
class MtkFormatReader : public detail::FormatReader
{
public:
MtkFormatReader();
virtual ~MtkFormatReader();
MtkFormatReader() noexcept;
virtual ~MtkFormatReader() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(MtkFormatReader)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(MtkFormatReader)
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/mtk_writer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace mb::bootimg::mtk
class MtkFormatWriter : public detail::FormatWriter
{
public:
MtkFormatWriter();
virtual ~MtkFormatWriter();
MtkFormatWriter() noexcept;
virtual ~MtkFormatWriter() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(MtkFormatWriter)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(MtkFormatWriter)
Expand Down
2 changes: 1 addition & 1 deletion libmbbootimg/include/mbbootimg/format/segment_reader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct SegmentReaderEntry
class SegmentReader
{
public:
SegmentReader();
SegmentReader() noexcept;

const std::vector<SegmentReaderEntry> & entries() const;
oc::result<void> set_entries(std::vector<SegmentReaderEntry> entries);
Expand Down
2 changes: 1 addition & 1 deletion libmbbootimg/include/mbbootimg/format/segment_writer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct SegmentWriterEntry
struct SegmentWriter
{
public:
SegmentWriter();
SegmentWriter() noexcept;

const std::vector<SegmentWriterEntry> & entries() const;
oc::result<void> set_entries(std::vector<SegmentWriterEntry> entries);
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/sony_elf_reader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ namespace mb::bootimg::sonyelf
class SonyElfFormatReader : public detail::FormatReader
{
public:
SonyElfFormatReader();
virtual ~SonyElfFormatReader();
SonyElfFormatReader() noexcept;
virtual ~SonyElfFormatReader() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(SonyElfFormatReader)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(SonyElfFormatReader)
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/format/sony_elf_writer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace mb::bootimg::sonyelf
class SonyElfFormatWriter : public detail::FormatWriter
{
public:
SonyElfFormatWriter();
virtual ~SonyElfFormatWriter();
SonyElfFormatWriter() noexcept;
virtual ~SonyElfFormatWriter() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(SonyElfFormatWriter)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(SonyElfFormatWriter)
Expand Down
8 changes: 4 additions & 4 deletions libmbbootimg/include/mbbootimg/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ constexpr HeaderFields ALL_FIELDS =
class MB_EXPORT Header
{
public:
Header();
~Header();
Header() noexcept;
~Header() noexcept;

MB_DEFAULT_COPY_CONSTRUCT_AND_ASSIGN(Header)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(Header)

bool operator==(const Header &rhs) const;
bool operator!=(const Header &rhs) const;
bool operator==(const Header &rhs) const noexcept;
bool operator!=(const Header &rhs) const noexcept;

HeaderFields supported_fields() const;
void set_supported_fields(HeaderFields fields);
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ namespace bootimg
class MB_EXPORT Reader
{
public:
Reader();
~Reader();
Reader() noexcept;
~Reader() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(Reader)

Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/reader_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace bootimg::detail
class FormatReader
{
public:
FormatReader();
virtual ~FormatReader();
FormatReader() noexcept;
virtual ~FormatReader() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(FormatReader)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(FormatReader)
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ namespace bootimg
class MB_EXPORT Writer
{
public:
Writer();
~Writer();
Writer() noexcept;
~Writer() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(Writer)

Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/include/mbbootimg/writer_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ namespace bootimg::detail
class FormatWriter
{
public:
FormatWriter();
virtual ~FormatWriter();
FormatWriter() noexcept;
virtual ~FormatWriter() noexcept;

MB_DISABLE_COPY_CONSTRUCT_AND_ASSIGN(FormatWriter)
MB_DEFAULT_MOVE_CONSTRUCT_AND_ASSIGN(FormatWriter)
Expand Down
8 changes: 4 additions & 4 deletions libmbbootimg/src/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@
namespace mb::bootimg
{

Entry::Entry(EntryType type)
Entry::Entry(EntryType type) noexcept
: m_type(type)
{
}

Entry::~Entry() = default;
Entry::~Entry() noexcept = default;

bool Entry::operator==(const Entry &rhs) const
bool Entry::operator==(const Entry &rhs) const noexcept
{
return m_type == rhs.m_type
&& m_size == rhs.m_size;
}

bool Entry::operator!=(const Entry &rhs) const
bool Entry::operator!=(const Entry &rhs) const noexcept
{
return !(*this == rhs);
}
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/android_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace std2 = std::experimental;
namespace std2 = std;
#endif

AndroidFormatReader::AndroidFormatReader(bool is_bump)
AndroidFormatReader::AndroidFormatReader(bool is_bump) noexcept
: FormatReader()
, m_is_bump(is_bump)
, m_hdr()
Expand All @@ -63,7 +63,7 @@ AndroidFormatReader::AndroidFormatReader(bool is_bump)
{
}

AndroidFormatReader::~AndroidFormatReader() = default;
AndroidFormatReader::~AndroidFormatReader() noexcept = default;

Format AndroidFormatReader::type()
{
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/android_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
namespace mb::bootimg::android
{

AndroidFormatWriter::AndroidFormatWriter(bool is_bump)
AndroidFormatWriter::AndroidFormatWriter(bool is_bump) noexcept
: FormatWriter()
, m_is_bump(is_bump)
, m_hdr()
, m_sha_ctx()
{
}

AndroidFormatWriter::~AndroidFormatWriter() = default;
AndroidFormatWriter::~AndroidFormatWriter() noexcept = default;

Format AndroidFormatWriter::type()
{
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/loki_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
namespace mb::bootimg::loki
{

LokiFormatReader::LokiFormatReader()
LokiFormatReader::LokiFormatReader() noexcept
: FormatReader()
, m_ahdr()
, m_lhdr()
{
}

LokiFormatReader::~LokiFormatReader() = default;
LokiFormatReader::~LokiFormatReader() noexcept = default;

Format LokiFormatReader::type()
{
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/loki_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ namespace mb::bootimg::loki

constexpr size_t MAX_ABOOT_SIZE = 2 * 1024 * 1024;

LokiFormatWriter::LokiFormatWriter()
LokiFormatWriter::LokiFormatWriter() noexcept
: FormatWriter()
, m_hdr()
, m_sha_ctx()
{
}

LokiFormatWriter::~LokiFormatWriter() = default;
LokiFormatWriter::~LokiFormatWriter() noexcept = default;

Format LokiFormatWriter::type()
{
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/mtk_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ find_mtk_headers(File &file, const android::AndroidHeader &ahdr)
};
}

MtkFormatReader::MtkFormatReader()
MtkFormatReader::MtkFormatReader() noexcept
: FormatReader()
, m_hdr()
, m_mtk_kernel_hdr()
, m_mtk_ramdisk_hdr()
{
}

MtkFormatReader::~MtkFormatReader() = default;
MtkFormatReader::~MtkFormatReader() noexcept = default;

Format MtkFormatReader::type()
{
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/mtk_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,13 @@ _mtk_compute_sha1(SegmentWriter &seg, File &file,
return oc::success();
}

MtkFormatWriter::MtkFormatWriter()
MtkFormatWriter::MtkFormatWriter() noexcept
: FormatWriter()
, m_hdr()
{
}

MtkFormatWriter::~MtkFormatWriter() = default;
MtkFormatWriter::~MtkFormatWriter() noexcept = default;

Format MtkFormatWriter::type()
{
Expand Down
2 changes: 1 addition & 1 deletion libmbbootimg/src/format/segment_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
namespace mb::bootimg
{

SegmentReader::SegmentReader()
SegmentReader::SegmentReader() noexcept
: m_state(SegmentReaderState::Begin)
, m_entries()
, m_entry(m_entries.end())
Expand Down
2 changes: 1 addition & 1 deletion libmbbootimg/src/format/segment_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
namespace mb::bootimg
{

SegmentWriter::SegmentWriter()
SegmentWriter::SegmentWriter() noexcept
: m_state(SegmentWriterState::Begin)
, m_entries()
, m_entry()
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/sony_elf_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
namespace mb::bootimg::sonyelf
{

SonyElfFormatReader::SonyElfFormatReader()
SonyElfFormatReader::SonyElfFormatReader() noexcept
: FormatReader()
, m_hdr()
{
}

SonyElfFormatReader::~SonyElfFormatReader() = default;
SonyElfFormatReader::~SonyElfFormatReader() noexcept = default;

Format SonyElfFormatReader::type()
{
Expand Down
4 changes: 2 additions & 2 deletions libmbbootimg/src/format/sony_elf_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
namespace mb::bootimg::sonyelf
{

SonyElfFormatWriter::SonyElfFormatWriter()
SonyElfFormatWriter::SonyElfFormatWriter() noexcept
: FormatWriter()
, m_hdr()
, m_hdr_kernel()
Expand All @@ -53,7 +53,7 @@ SonyElfFormatWriter::SonyElfFormatWriter()
{
}

SonyElfFormatWriter::~SonyElfFormatWriter() = default;
SonyElfFormatWriter::~SonyElfFormatWriter() noexcept = default;

Format SonyElfFormatWriter::type()
{
Expand Down
8 changes: 4 additions & 4 deletions libmbbootimg/src/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
namespace mb::bootimg
{

Header::Header()
Header::Header() noexcept
: m_fields_supported(ALL_FIELDS)
{
}

Header::~Header() = default;
Header::~Header() noexcept = default;

bool Header::operator==(const Header &rhs) const
bool Header::operator==(const Header &rhs) const noexcept
{
return m_kernel_addr == rhs.m_kernel_addr
&& m_ramdisk_addr == rhs.m_ramdisk_addr
Expand Down Expand Up @@ -72,7 +72,7 @@ bool Header::operator==(const Header &rhs) const
&& m_hdr_entrypoint == rhs.m_hdr_entrypoint;
}

bool Header::operator!=(const Header &rhs) const
bool Header::operator!=(const Header &rhs) const noexcept
{
return !(*this == rhs);
}
Expand Down
Loading

0 comments on commit 268979b

Please sign in to comment.