Skip to content

Commit

Permalink
djgpp: Fix unused-but-set-variable warning
Browse files Browse the repository at this point in the history
I chose to just hide this behind '#ifndef __DJGPP__', instead of listing
all the macro combinations where it *is* used.  That would make quite a
mess.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19322)
  • Loading branch information
jwt27 authored and hlandau committed Nov 14, 2022
1 parent d8bcd64 commit b9179ae
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crypto/bio/bss_dgram.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,10 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
long ret = 1;
int *ip;
bio_dgram_data *data = NULL;
# ifndef __DJGPP__
/* There are currently no cases where this is used on djgpp/watt32. */
int sockopt_val = 0;
# endif
int d_errno;
# if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU))
socklen_t sockopt_len; /* assume that system supporting IP_MTU is
Expand Down Expand Up @@ -847,22 +850,22 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
break;
# endif
case BIO_CTRL_DGRAM_SET_DONT_FRAG:
sockopt_val = num ? 1 : 0;

switch (data->peer.sa.sa_family) {
case AF_INET:
# if defined(IP_DONTFRAG)
sockopt_val = num ? 1 : 0;
if ((ret = setsockopt(b->num, IPPROTO_IP, IP_DONTFRAG,
&sockopt_val, sizeof(sockopt_val))) < 0)
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
"calling setsockopt()");
# elif defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined (IP_PMTUDISC_PROBE)
if ((sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT),
(ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,
sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT;
if ((ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,
&sockopt_val, sizeof(sockopt_val))) < 0)
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
"calling setsockopt()");
# elif defined(OPENSSL_SYS_WINDOWS) && defined(IP_DONTFRAGMENT)
sockopt_val = num ? 1 : 0;
if ((ret = setsockopt(b->num, IPPROTO_IP, IP_DONTFRAGMENT,
(const char *)&sockopt_val,
sizeof(sockopt_val))) < 0)
Expand All @@ -875,15 +878,16 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
# if OPENSSL_USE_IPV6
case AF_INET6:
# if defined(IPV6_DONTFRAG)
sockopt_val = num ? 1 : 0;
if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_DONTFRAG,
(const void *)&sockopt_val,
sizeof(sockopt_val))) < 0)
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
"calling setsockopt()");

# elif defined(OPENSSL_SYS_LINUX) && defined(IPV6_MTUDISCOVER)
if ((sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT),
(ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT;
if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
&sockopt_val, sizeof(sockopt_val))) < 0)
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
"calling setsockopt()");
Expand Down

0 comments on commit b9179ae

Please sign in to comment.