serialize: use a temporary for SerializeException Exception must always use temporary...
authorLoïc Blot <loic.blot@unix-experience.fr>
Mon, 21 Aug 2017 14:07:39 +0000 (16:07 +0200)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:31:59 +0000 (17:31 +0200)
src/util/serialize.cpp
src/util/serialize.h

index 61d369bc487f3a5ae8099c228cb09568237bc47d..a1e6790f4a2c0a80a706e04e538fc03fa67d220d 100644 (file)
@@ -28,8 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <iomanip>
 #include <vector>
 
-SerializationError eof_ser_err("Attempted read past end of data");
-
 ////
 //// BufReader
 ////
index e224341918480ed1531ab1acaa31068fcea5ea36..a864d21abc8acaa7a0aa9646ad33254516fc3882 100644 (file)
@@ -429,8 +429,6 @@ bool deSerializeStringToStruct(std::string valstr,
 //// BufReader
 ////
 
-extern SerializationError eof_ser_err;
-
 #define MAKE_BUFREADER_GETNOEX_FXN(T, N, S) \
        inline bool get ## N ## NoEx(T *val)    \
        {                                       \
@@ -446,7 +444,7 @@ extern SerializationError eof_ser_err;
        {                                \
                T val;                       \
                if (!get ## N ## NoEx(&val)) \
-                       throw eof_ser_err;       \
+                       throw SerializationError("Attempted read past end of data"); \
                return val;                  \
        }
 
@@ -504,7 +502,7 @@ public:
        inline void getRawData(void *val, size_t len)
        {
                if (!getRawDataNoEx(val, len))
-                       throw eof_ser_err;
+                       throw SerializationError("Attempted read past end of data");
        }
 
        inline size_t remaining()