blob: 68b686346017af86d7dff9898ecbebdf5599a32f [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 3e5a0cb440c788e2383e40ab23ac1cf01d96961b Mon Sep 17 00:00:00 2001
2From: Mingli Yu <mingli.yu@windriver.com>
3Date: Tue, 24 Jul 2018 01:30:25 -0700
4Subject: [PATCH] src/tcp.c: fix jump-misses-init error
5
6Fix below jump-misses-init error
7
8| In file included from ../../git/src/tcp.c:51:
9| ../../git/src/tcp.c: In function 'relpTcpConnect':
10| ../../git/src/relp.h:220:3: error: jump skips variable initialization [-Werror=jump-misses-init]
11| goto finalize_it; \
12| ^~~~
13| ../../git/src/tcp.c:1951:3: note: in expansion of macro 'ABORT_FINALIZE'
14| ABORT_FINALIZE(RELP_RET_IO_ERR);
15| ^~~~~~~~~~~~~~
16| ../../git/src/tcp.c:2005:1: note: label 'finalize_it' defined here
17| finalize_it:
18| ^~~~~~~~~~~
19| ../../git/src/tcp.c:1991:6: note: 'r' declared here
20| int r = getsockopt(pThis->sock, SOL_SOCKET, SO_ERROR, &so_error, &len);
21| ^
22| In file included from ../../git/src/tcp.c:51:
23| ../../git/src/relp.h:220:3: error: jump skips variable initialization [-Werror=jump-misses-init]
24| goto finalize_it; \
25| ^~~~
26| ../../git/src/tcp.c:1951:3: note: in expansion of macro 'ABORT_FINALIZE'
27| ABORT_FINALIZE(RELP_RET_IO_ERR);
28| ^~~~~~~~~~~~~~
29| ../../git/src/tcp.c:2005:1: note: label 'finalize_it' defined here
30| finalize_it:
31| ^~~~~~~~~~~
32| ../../git/src/tcp.c:1989:12: note: 'len' declared here
33| socklen_t len = sizeof so_error;
34| ^~~
35
36Upstream-Status: Submitted[https://github.com/rsyslog/librelp/pull/117]
37
38Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
39---
40 src/tcp.c | 7 ++++---
41 1 file changed, 4 insertions(+), 3 deletions(-)
42
43diff --git a/src/tcp.c b/src/tcp.c
44index f35eb84..fb34dc7 100644
45--- a/src/tcp.c
46+++ b/src/tcp.c
47@@ -1936,6 +1936,9 @@ relpTcpConnect(relpTcp_t *const pThis,
48 struct addrinfo hints;
49 struct addrinfo *reslocal = NULL;
50 struct pollfd pfd;
51+ int so_error;
52+ socklen_t len = sizeof so_error;
53+ int r;
54
55 ENTER_RELPFUNC;
56 RELPOBJ_assert(pThis, Tcp);
57@@ -1985,10 +1988,8 @@ relpTcpConnect(relpTcp_t *const pThis,
58 ABORT_FINALIZE(RELP_RET_TIMED_OUT);
59 }
60
61- int so_error;
62- socklen_t len = sizeof so_error;
63
64- int r = getsockopt(pThis->sock, SOL_SOCKET, SO_ERROR, &so_error, &len);
65+ r = getsockopt(pThis->sock, SOL_SOCKET, SO_ERROR, &so_error, &len);
66 if (r == -1 || so_error != 0) {
67 pThis->pEngine->dbgprint("socket has an error %d\n", so_error);
68 ABORT_FINALIZE(RELP_RET_IO_ERR);
69--
702.17.1
71