Skip to content

Commit 5844609

Browse files
[net] Avoid initialization to a value that is never read
Prior to this commit the value stored to `s` at initialization was never read (in the case of STRERROR_R_CHAR_P).
1 parent 7e2a221 commit 5844609

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/netbase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,14 @@ std::string NetworkErrorString(int err)
672672
std::string NetworkErrorString(int err)
673673
{
674674
char buf[256];
675-
const char *s = buf;
676675
buf[0] = 0;
677676
/* Too bad there are two incompatible implementations of the
678677
* thread-safe strerror. */
678+
const char *s;
679679
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
680680
s = strerror_r(err, buf, sizeof(buf));
681681
#else /* POSIX variant always returns message in buffer */
682+
s = buf;
682683
if (strerror_r(err, buf, sizeof(buf)))
683684
buf[0] = 0;
684685
#endif

0 commit comments

Comments
 (0)