mirror of
https://github.com/Zygo/bees.git
synced 2025-08-03 06:13:29 +02:00
lib: deprecate memset_zero template, use C99 compound literals instead
Sprinkle in some asserts to make sure compilers aren't getting creative. This may introduce a new compiler dependency, as I suspect older versions of GCC don't support this syntax. It definitely needs a new compiler flag to suppress a warning when some fields are not explicitly initialized. If we've omitted a field, it's because it's a field we don't know (or care) about, and we want that thing initialized to zero. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
12
lib/fd.cc
12
lib/fd.cc
@@ -477,9 +477,9 @@ namespace crucible {
|
||||
return pwrite_or_die(fd, text.data(), text.size(), offset);
|
||||
}
|
||||
|
||||
Stat::Stat()
|
||||
Stat::Stat() :
|
||||
stat( (stat) { } )
|
||||
{
|
||||
memset_zero<stat>(this);
|
||||
}
|
||||
|
||||
Stat &
|
||||
@@ -498,15 +498,15 @@ namespace crucible {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Stat::Stat(int fd)
|
||||
Stat::Stat(int fd) :
|
||||
stat( (stat) { } )
|
||||
{
|
||||
memset_zero<stat>(this);
|
||||
fstat(fd);
|
||||
}
|
||||
|
||||
Stat::Stat(const string &filename)
|
||||
Stat::Stat(const string &filename) :
|
||||
stat( (stat) { } )
|
||||
{
|
||||
memset_zero<stat>(this);
|
||||
lstat(filename);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user