Commit 11598d152d883b673b3d3f5f072bdde02cd03c89

Authored by Josh Klontz
1 parent c5828971

cleanup matFormat

Showing 1 changed file with 6 additions and 11 deletions
openbr/plugins/format.cpp
... ... @@ -316,8 +316,8 @@ class matFormat : public Format
316 316 Element(QDataStream &stream)
317 317 : type(0), bytes(0)
318 318 {
319   - bool error = false;
320   - error |= (stream.readRawData((char*)&type, 4) != 4);
  319 + if (stream.readRawData((char*)&type, 4) != 4)
  320 + qFatal("Unexpected end of file.");
321 321  
322 322 if (type >= 1 << 16) {
323 323 // Small data format
... ... @@ -326,22 +326,17 @@ class matFormat : public Format
326 326 bytes = bytes >> 16;
327 327 } else {
328 328 // Regular format
329   - error |= (stream.readRawData((char*)&bytes, 4) != 4);
  329 + if (stream.readRawData((char*)&bytes, 4) != 4)
  330 + qFatal("Unexpected end of file.");
330 331 }
331 332  
332 333 data.resize(bytes);
333   - error |= (int(bytes) != stream.readRawData(data.data(), bytes));
  334 + if (int(bytes) != stream.readRawData(data.data(), bytes))
  335 + qFatal("Unexpected end of file.");
334 336  
335 337 // Alignment
336 338 int skipBytes = (bytes < 4) ? (4 - bytes) : (8 - bytes%8)%8;
337 339 if (skipBytes != 0) stream.skipRawData(skipBytes);
338   -
339   - if (error) qFatal("Unexpected end of file.");
340   - }
341   -
342   - void print() const
343   - {
344   - qDebug() << "matFormat::Element" << type << bytes << data.size();
345 340 }
346 341 };
347 342  
... ...