mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
LibArchive: Default initialize member variables
Problem: - `memset` is used to initialize data instead of using default initialization. Solution: - Default initialize all member variables. - Eliminate use of `memset` in favor of C++ braced initialization.
This commit is contained in:
parent
847efd8aca
commit
deba345ca7
2 changed files with 18 additions and 20 deletions
|
@ -117,22 +117,22 @@ public:
|
||||||
void calculate_checksum();
|
void calculate_checksum();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char m_filename[100];
|
char m_filename[100] { 0 };
|
||||||
char m_mode[8];
|
char m_mode[8] { 0 };
|
||||||
char m_uid[8];
|
char m_uid[8] { 0 };
|
||||||
char m_gid[8];
|
char m_gid[8] { 0 };
|
||||||
char m_size[12];
|
char m_size[12] { 0 };
|
||||||
char m_timestamp[12];
|
char m_timestamp[12] { 0 };
|
||||||
char m_checksum[8]; // an uninitialized header's checksum is filled with spaces
|
char m_checksum[8] { 0 }; // an uninitialized header's checksum is filled with spaces
|
||||||
char m_type_flag;
|
char m_type_flag { 0 };
|
||||||
char m_link_name[100];
|
char m_link_name[100] { 0 };
|
||||||
char m_magic[6];
|
char m_magic[6] { 0 };
|
||||||
char m_version[2];
|
char m_version[2] { 0 };
|
||||||
char m_owner_name[32];
|
char m_owner_name[32] { 0 };
|
||||||
char m_group_name[32];
|
char m_group_name[32] { 0 };
|
||||||
char m_major[8];
|
char m_major[8] { 0 };
|
||||||
char m_minor[8];
|
char m_minor[8] { 0 };
|
||||||
char m_prefix[155]; // zero out the prefix for archiving
|
char m_prefix[155] { 0 }; // zero out the prefix for archiving
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,8 +131,7 @@ TarOutputStream::TarOutputStream(OutputStream& stream)
|
||||||
void TarOutputStream::add_directory(const String& path, mode_t mode)
|
void TarOutputStream::add_directory(const String& path, mode_t mode)
|
||||||
{
|
{
|
||||||
VERIFY(!m_finished);
|
VERIFY(!m_finished);
|
||||||
TarFileHeader header;
|
TarFileHeader header {};
|
||||||
memset(&header, 0, sizeof(header));
|
|
||||||
header.set_size(0);
|
header.set_size(0);
|
||||||
header.set_filename(String::formatted("{}/", path)); // Old tar implementations assume directory names end with a /
|
header.set_filename(String::formatted("{}/", path)); // Old tar implementations assume directory names end with a /
|
||||||
header.set_type_flag(TarFileType::Directory);
|
header.set_type_flag(TarFileType::Directory);
|
||||||
|
@ -148,8 +147,7 @@ void TarOutputStream::add_directory(const String& path, mode_t mode)
|
||||||
void TarOutputStream::add_file(const String& path, mode_t mode, ReadonlyBytes bytes)
|
void TarOutputStream::add_file(const String& path, mode_t mode, ReadonlyBytes bytes)
|
||||||
{
|
{
|
||||||
VERIFY(!m_finished);
|
VERIFY(!m_finished);
|
||||||
TarFileHeader header;
|
TarFileHeader header {};
|
||||||
memset(&header, 0, sizeof(header));
|
|
||||||
header.set_size(bytes.size());
|
header.set_size(bytes.size());
|
||||||
header.set_filename(path);
|
header.set_filename(path);
|
||||||
header.set_type_flag(TarFileType::NormalFile);
|
header.set_type_flag(TarFileType::NormalFile);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue