0002-fix-maybe-uninitialized-errors.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 0c23224e926463b1097414979367655a27fa6d60 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Thu, 7 Apr 2022 18:27:58 +0200
  4. Subject: [PATCH] fix maybe-uninitialized errors
  5. Set {listen,server}_sock to -1 when needed as already done in
  6. src/manager.c by commit ecf1fcc84594b09ed2d61e3677cd8e62bd897ccb to
  7. avoid the following build failure:
  8. local.c: In function 'create_and_bind':
  9. local.c:218:12: error: 'listen_sock' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  10. 218 | return listen_sock;
  11. | ^~~~~~~~~~~
  12. Fixes:
  13. - http://autobuild.buildroot.org/results/27471a878ff52a972ac087d534e44fb0c50808f6
  14. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  15. [Retrieved from:
  16. https://github.com/shadowsocks/shadowsocks-libev/commit/0c23224e926463b1097414979367655a27fa6d60]
  17. ---
  18. src/local.c | 2 +-
  19. src/redir.c | 2 +-
  20. src/server.c | 2 +-
  21. src/tunnel.c | 2 +-
  22. src/udprelay.c | 2 +-
  23. 5 files changed, 5 insertions(+), 5 deletions(-)
  24. diff --git a/src/local.c b/src/local.c
  25. index b1ab040bb..47d634ce5 100644
  26. --- a/src/local.c
  27. +++ b/src/local.c
  28. @@ -168,7 +168,7 @@ create_and_bind(const char *addr, const char *port)
  29. {
  30. struct addrinfo hints;
  31. struct addrinfo *result, *rp;
  32. - int s, listen_sock;
  33. + int s, listen_sock = -1;
  34. memset(&hints, 0, sizeof(struct addrinfo));
  35. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  36. diff --git a/src/redir.c b/src/redir.c
  37. index 4a5a489f0..e60bd4870 100644
  38. --- a/src/redir.c
  39. +++ b/src/redir.c
  40. @@ -147,7 +147,7 @@ create_and_bind(const char *addr, const char *port)
  41. {
  42. struct addrinfo hints;
  43. struct addrinfo *result, *rp;
  44. - int s, listen_sock;
  45. + int s, listen_sock = -1;
  46. memset(&hints, 0, sizeof(struct addrinfo));
  47. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  48. diff --git a/src/server.c b/src/server.c
  49. index e9cdc2619..073e38b22 100644
  50. --- a/src/server.c
  51. +++ b/src/server.c
  52. @@ -550,7 +550,7 @@ create_and_bind(const char *host, const char *port, int mptcp)
  53. {
  54. struct addrinfo hints;
  55. struct addrinfo *result, *rp, *ipv4v6bindall;
  56. - int s, listen_sock;
  57. + int s, listen_sock = -1;
  58. memset(&hints, 0, sizeof(struct addrinfo));
  59. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  60. diff --git a/src/tunnel.c b/src/tunnel.c
  61. index e0886bdb9..6641fe62a 100644
  62. --- a/src/tunnel.c
  63. +++ b/src/tunnel.c
  64. @@ -129,7 +129,7 @@ create_and_bind(const char *addr, const char *port)
  65. {
  66. struct addrinfo hints;
  67. struct addrinfo *result, *rp;
  68. - int s, listen_sock;
  69. + int s, listen_sock = -1;
  70. memset(&hints, 0, sizeof(struct addrinfo));
  71. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  72. diff --git a/src/udprelay.c b/src/udprelay.c
  73. index 23a042497..580ad4bd8 100644
  74. --- a/src/udprelay.c
  75. +++ b/src/udprelay.c
  76. @@ -446,7 +446,7 @@ create_server_socket(const char *host, const char *port)
  77. {
  78. struct addrinfo hints;
  79. struct addrinfo *result, *rp, *ipv4v6bindall;
  80. - int s, server_sock;
  81. + int s, server_sock = -1;
  82. memset(&hints, 0, sizeof(struct addrinfo));
  83. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */