From: Guy McSwain Date: Fri, 10 Jan 2020 06:50:53 +0000 (-0600) Subject: setsockopt() with properly initialized option argument. Fixes issue #298 and possibly... X-Git-Tag: archive/raspbian/1.78-1+rpi1^2~4^2~9^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5c1f52215d083830802eff439e1f23d6c0c02651;p=pigpio.git setsockopt() with properly initialized option argument. Fixes issue #298 and possibly #274. --- diff --git a/pigpio.c b/pigpio.c index 24fe287..b8a7531 100644 --- a/pigpio.c +++ b/pigpio.c @@ -8292,7 +8292,7 @@ int initInitialise(void) } server6.sin6_port = htons(port); - int opt; + int opt = 1; setsockopt(fdSock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); if (bind(fdSock,(struct sockaddr *)&server6, sizeof(server6)) < 0) SOFT_ERROR(PI_INIT_FAILED, "bind to port %d failed (%m)", port); @@ -8307,7 +8307,7 @@ int initInitialise(void) SOFT_ERROR(PI_INIT_FAILED, "socket failed (%m)"); else { - int opt; + int opt = 1; setsockopt(fdSock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); } server.sin_family = AF_INET;