From ad148587dcf5244c2d2011dba339786c765c54c4 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 16:19:54 +0100 Subject: Make Lint Happy --- src/serialization.cpp | 180 +++++++++++++++++++++++--------------------------- 1 file changed, 81 insertions(+), 99 deletions(-) (limited to 'src/serialization.cpp') diff --git a/src/serialization.cpp b/src/serialization.cpp index 310604f54..64d5cefcc 100644 --- a/src/serialization.cpp +++ b/src/serialization.cpp @@ -26,29 +26,29 @@ with this program; if not, write to the Free Software Foundation, Inc., /* report a zlib or i/o error */ void zerr(int ret) { - dstream<<"zerr: "; - switch (ret) { - case Z_ERRNO: - if (ferror(stdin)) - dstream<<"error reading stdin"< &data, std::ostream &os, u8 version) { - if(version >= 11) - { - compressZlib(*data ,data.getSize(), os); + if (version >= 11) { + compressZlib(*data, data.getSize(), os); return; } - if(data.getSize() == 0) + if (data.getSize() == 0) return; // Write length (u32) u8 tmp[4]; writeU32(tmp, data.getSize()); - os.write((char*)tmp, 4); + os.write((char *)tmp, 4); // We will be writing 8-bit pairs of more_count and byte u8 more_count = 0; u8 current_byte = data[0]; - for(u32 i=1; i= 11) - { + if (version >= 11) { decompressZlib(is, os); return; } @@ -251,31 +236,28 @@ void decompress(std::istream &is, std::ostream &os, u8 version) // Read length (u32) u8 tmp[4]; - is.read((char*)tmp, 4); + is.read((char *)tmp, 4); u32 len = readU32(tmp); // We will be reading 8-bit pairs of more_count and byte u32 count = 0; - for(;;) - { - u8 more_count=0; - u8 byte=0; + for (;;) { + u8 more_count = 0; + u8 byte = 0; - is.read((char*)&more_count, 1); + is.read((char *)&more_count, 1); - is.read((char*)&byte, 1); + is.read((char *)&byte, 1); - if(is.eof()) + if (is.eof()) throw SerializationError("decompress: stream ended halfway"); - for(s32 i=0; i<(u16)more_count+1; i++) - os.write((char*)&byte, 1); + for (s32 i = 0; i < (u16)more_count + 1; i++) + os.write((char *)&byte, 1); - count += (u16)more_count+1; + count += (u16)more_count + 1; - if(count == len) + if (count == len) break; } } - - -- cgit v1.2.3