Skip to content

Commit c263e9d

Browse files
committed
exception: Make err string consistently "const std::string&"
Coverity complains (for every occurence of the macros...) "C++ string which is never changed is passed by value rather than by reference" Signed-off-by: Frank Lichtenheld <[email protected]>
1 parent 90b28a9 commit c263e9d

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

openvpn/common/exception.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ class Exception : public std::exception
9696
}
9797

9898
// define a custom exception class that allows extra info
99-
#define OPENVPN_EXCEPTION(C) \
100-
class C : public openvpn::Exception \
101-
{ \
102-
public: \
103-
C() : openvpn::Exception(#C OPENVPN_FILE_LINE) \
104-
{ \
105-
} \
106-
C(const std::string err) : openvpn::Exception(#C OPENVPN_FILE_LINE ": " + err) \
107-
{ \
108-
} \
99+
#define OPENVPN_EXCEPTION(C) \
100+
class C : public openvpn::Exception \
101+
{ \
102+
public: \
103+
C() : openvpn::Exception(#C OPENVPN_FILE_LINE) \
104+
{ \
105+
} \
106+
C(const std::string &err) : openvpn::Exception(#C OPENVPN_FILE_LINE ": " + err) \
107+
{ \
108+
} \
109109
}
110110

111111
// define a custom exception class that allows extra info with error code
@@ -130,26 +130,26 @@ class Exception : public std::exception
130130
static std::string code2string(C##_##code code); \
131131
}
132132
// define a custom exception class that allows extra info, but does not emit a tag
133-
#define OPENVPN_UNTAGGED_EXCEPTION(C) \
134-
class C : public openvpn::Exception \
135-
{ \
136-
public: \
137-
C(const std::string err) : openvpn::Exception(err) \
138-
{ \
139-
} \
133+
#define OPENVPN_UNTAGGED_EXCEPTION(C) \
134+
class C : public openvpn::Exception \
135+
{ \
136+
public: \
137+
C(const std::string &err) : openvpn::Exception(err) \
138+
{ \
139+
} \
140140
}
141141

142142
// define a custom exception class that allows extra info, and inherits from a custom base
143-
#define OPENVPN_EXCEPTION_INHERIT(B, C) \
144-
class C : public B \
145-
{ \
146-
public: \
147-
C() : B(#C OPENVPN_FILE_LINE) \
148-
{ \
149-
} \
150-
C(const std::string err) : B(#C OPENVPN_FILE_LINE ": " + err) \
151-
{ \
152-
} \
143+
#define OPENVPN_EXCEPTION_INHERIT(B, C) \
144+
class C : public B \
145+
{ \
146+
public: \
147+
C() : B(#C OPENVPN_FILE_LINE) \
148+
{ \
149+
} \
150+
C(const std::string &err) : B(#C OPENVPN_FILE_LINE ": " + err) \
151+
{ \
152+
} \
153153
}
154154

155155
// define a custom exception class that allows extra info, and inherits from a custom base,

0 commit comments

Comments
 (0)