Workaround GCC bug.

This commit is contained in:
John Preston 2018-08-29 23:29:59 +03:00
parent 2001d3c617
commit 2bcdf27b03
5 changed files with 22 additions and 8 deletions

View File

@ -38,7 +38,7 @@ base::optional<BasicHeader> BinlogWrapper::ReadHeader(
return {}; return {};
} else if (binlog.read(bytes::object_as_span(&result)) != sizeof(result)) { } else if (binlog.read(bytes::object_as_span(&result)) != sizeof(result)) {
return {}; return {};
} else if (result.format != Format::Format_0) { } else if (result.getFormat() != Format::Format_0) {
return {}; return {};
} else if (settings.trackEstimatedTime } else if (settings.trackEstimatedTime
!= !!(result.flags & result.kTrackEstimatedTime)) { != !!(result.flags & result.kTrackEstimatedTime)) {

View File

@ -321,7 +321,7 @@ bool DatabaseObject::startDelayedPruning() {
const auto seconds = int64(_minimalEntryTime - before); const auto seconds = int64(_minimalEntryTime - before);
if (!_pruneTimer.isActive()) { if (!_pruneTimer.isActive()) {
_pruneTimer.callOnce(std::min( _pruneTimer.callOnce(std::min(
seconds * crl::time_type(1000), crl::time_type(seconds * 1000),
_settings.maxPruneCheckTimeout)); _settings.maxPruneCheckTimeout));
} }
} }
@ -963,8 +963,8 @@ QByteArray DatabaseObject::readValueData(PlaceId place, size_type size) const {
} }
return result; return result;
} break; } break;
default: Unexpected("Result in DatabaseObject::get.");
} }
Unexpected("Result in DatabaseObject::get.");
} }
void DatabaseObject::recordEntryAccess(const Key &key) { void DatabaseObject::recordEntryAccess(const Key &key) {

View File

@ -88,7 +88,7 @@ bool WriteVersionValue(const QString &base, Version value) {
} }
BasicHeader::BasicHeader() BasicHeader::BasicHeader()
: format(Format::Format_0) : format(static_cast<uint32>(Format::Format_0))
, flags(0) { , flags(0) {
} }

View File

@ -118,7 +118,14 @@ struct BasicHeader {
static constexpr auto kTrackEstimatedTime = 0x01U; static constexpr auto kTrackEstimatedTime = 0x01U;
Format format : 8; Format getFormat() const {
return static_cast<Format>(format);
}
void setFormat(Format format) {
this->format = static_cast<uint32>(format);
}
uint32 format : 8;
uint32 flags : 24; uint32 flags : 24;
uint32 systemTime = 0; uint32 systemTime = 0;
uint32 reserved1 = 0; uint32 reserved1 = 0;

View File

@ -21,8 +21,15 @@ enum class Format : uint32 {
struct BasicHeader { struct BasicHeader {
BasicHeader(); BasicHeader();
void setFormat(Format format) {
this->format = static_cast<uint32>(format);
}
Format getFormat() const {
return static_cast<Format>(format);
}
bytes::array<kSaltSize> salt = { { bytes::type() } }; bytes::array<kSaltSize> salt = { { bytes::type() } };
Format format : 8; uint32 format : 8;
uint32 reserved1 : 24; uint32 reserved1 : 24;
uint32 reserved2 = 0; uint32 reserved2 = 0;
uint64 applicationVersion = 0; uint64 applicationVersion = 0;
@ -30,7 +37,7 @@ struct BasicHeader {
}; };
BasicHeader::BasicHeader() BasicHeader::BasicHeader()
: format(Format::Format_0) : format(static_cast<uint32>(Format::Format_0))
, reserved1(0) { , reserved1(0) {
} }
@ -150,7 +157,7 @@ File::Result File::readHeader(const EncryptionKey &key) {
headerBytes.subspan(0, checkSize)); headerBytes.subspan(0, checkSize));
if (bytes::compare(header.checksum, checksum) != 0) { if (bytes::compare(header.checksum, checksum) != 0) {
return Result::WrongKey; return Result::WrongKey;
} else if (header.format != Format::Format_0) { } else if (header.getFormat() != Format::Format_0) {
return Result::Failed; return Result::Failed;
} }
_dataSize = _data.size() _dataSize = _data.size()