Skip to content
Snippets Groups Projects
Commit a9fb8c63 authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

Task #5291: Fixed obscure bug in FastFileStream. Obscure in the sense that the...

Task #5291: Fixed obscure bug in FastFileStream. Obscure in the sense that the code was plain wrong, but for reasons beyond my comprehension, the old GCC compiler generated correct(?) code.
parent 26b46131
No related branches found
No related tags found
No related merge requests found
......@@ -80,13 +80,14 @@ namespace LOFAR
{
if (remainder) {
// pad with zeroes
size_t nrpadbytes = alignment - remainder;
ensureBuffer(alignment);
memset(buffer.get() + remainder, 0, alignment - remainder);
memset(buffer.get() + remainder, 0, nrpadbytes);
forceWrite(buffer, alignment);
remainder = 0;
return alignment;
return nrpadbytes;
}
return 0;
......@@ -176,7 +177,7 @@ namespace LOFAR
// get rid of the old remainder first
if (bytes + remainder >= alignment) {
bytes -= (writeRemainder() - remainder);
bytes -= writeRemainder();
if (bytes >= alignment ) {
// skip whole number of blocks
......
......@@ -43,9 +43,9 @@ namespace LOFAR
virtual size_t size();
// formally, the required alignment for O_DIRECT is determined by the file system
static const unsigned alignment = 512;
static const size_t alignment = 512;
private:
// writes the remainder, padded with zeros if needed. Returns the number of bytes written.
// writes the remainder, padded with zeros if needed. Returns the number of zero-pad bytes written.
size_t writeRemainder();
// we only support writing
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment