Add some asserts

This commit is contained in:
Sebastian Meßmer 2015-04-08 14:15:11 +02:00
parent f1a992d187
commit 354de197ff
3 changed files with 8 additions and 1 deletions

View File

@ -28,7 +28,9 @@ CryFile::~CryFile() {
}
unique_ptr<fspp::OpenFile> CryFile::open(int flags) const {
return make_unique<CryOpenFile>(make_unique<FileBlob>(_device->LoadBlob(_key)));
auto blob = _device->LoadBlob(_key);
assert(blob.get() != nullptr);
return make_unique<CryOpenFile>(make_unique<FileBlob>(std::move(blob)));
}
void CryFile::stat(struct ::stat *result) const {

View File

@ -2,6 +2,7 @@
#include "MagicNumbers.h"
#include <messmer/blockstore/utils/Key.h>
#include <cassert>
using std::unique_ptr;
using std::make_unique;
@ -17,6 +18,7 @@ FileBlob::~FileBlob() {
}
unique_ptr<FileBlob> FileBlob::InitializeEmptyFile(unique_ptr<Blob> blob) {
assert(blob.get() != nullptr);
blob->resize(1);
unsigned char magicNumber = MagicNumbers::FILE;
blob->write(&magicNumber, 0, 1);

View File

@ -1,4 +1,6 @@
#include <messmer/blockstore/implementations/ondisk/OnDiskBlockStore.h>
#include <messmer/blockstore/implementations/inmemory/InMemoryBlockStore.h>
#include <messmer/blockstore/implementations/inmemory/InMemoryBlock.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
@ -10,6 +12,7 @@
namespace bf = boost::filesystem;
using blockstore::ondisk::OnDiskBlockStore;
using blockstore::inmemory::InMemoryBlockStore;
using std::make_unique;