Gcc 11 found several places where the code has indentation which may
hint of a bug. For example:

        if (something)
                onething;
                anotherthing;

In such code, the indentation suggests that the programmer indented
for both things to be done only if something is true - and yet the
lack of braces mean just onething is under the condition, and
anotherhing is run unconditionally!

I fixed the indentation or the code, as it seems to me the intention
was. In some cases it seems gcc found real bugs in the code (however,
these bugs seem in very obscure cases).

This issue reminds us why OSv's coding conventions require that "if"
must always use braces - even for a single statement (most of the
involved code predates this coding convention).

Signed-off-by: Nadav Har'El <[email protected]>

x

Signed-off-by: Nadav Har'El <[email protected]>
---
 bsd/sys/net/if.cc               | 4 ++--
 bsd/sys/netinet/in_mcast.cc     | 3 ++-
 bsd/sys/netinet/tcp_syncache.cc | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/bsd/sys/net/if.cc b/bsd/sys/net/if.cc
index 2f2e4cbb..f717da37 100644
--- a/bsd/sys/net/if.cc
+++ b/bsd/sys/net/if.cc
@@ -2624,8 +2624,8 @@ if_allocmulti(struct ifnet *ifp, struct bsd_sockaddr *sa, 
struct bsd_sockaddr *l
                free(ifma);
                return (NULL);
        }
-    if (mflags & M_ZERO)
-        bzero(dupsa, sa->sa_len);
+       if (mflags & M_ZERO)
+               bzero(dupsa, sa->sa_len);
        bcopy(llsa, dupsa, llsa->sa_len);
        ifma->ifma_lladdr = dupsa;
 
diff --git a/bsd/sys/netinet/in_mcast.cc b/bsd/sys/netinet/in_mcast.cc
index d34bf43f..aadd04b0 100644
--- a/bsd/sys/netinet/in_mcast.cc
+++ b/bsd/sys/netinet/in_mcast.cc
@@ -1001,9 +1001,10 @@ inm_merge(struct in_multi *inm, /*const*/ struct 
in_mfilter *imf)
        /* Decrement ASM listener count on transition out of ASM mode. */
        if (imf->imf_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
                if ((imf->imf_st[1] != MCAST_EXCLUDE) ||
-                   (imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0))
+                   (imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0)) {
                        CTR1(KTR_IGMPV3, "%s: --asm on inm at t1", __func__);
                        --inm->inm_st[1].iss_asm;
+               }
        }
 
        /* Increment ASM listener count on transition to ASM mode. */
diff --git a/bsd/sys/netinet/tcp_syncache.cc b/bsd/sys/netinet/tcp_syncache.cc
index b1fb17c2..16c4fc19 100644
--- a/bsd/sys/netinet/tcp_syncache.cc
+++ b/bsd/sys/netinet/tcp_syncache.cc
@@ -920,10 +920,11 @@ int syncache_expand(struct in_conninfo *inc, struct 
tcpopt *to,
         */
        if ((to->to_flags & TOF_TS) && to->to_tsecr != sc->sc_ts&&
        !TOEPCB_ISSET(sc)) {if
-(              (s = tcp_log_addrs(inc, th, NULL, NULL)))
+(              (s = tcp_log_addrs(inc, th, NULL, NULL))) {
                bsd_log(LOG_DEBUG, "%s; %s: TSECR %u != TS %u, "
                "segment rejected\n",
                s, __func__, to->to_tsecr, sc->sc_ts);
+               }
                goto failed;
        }
 
-- 
2.31.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20210614062057.1998552-5-nyh%40scylladb.com.

Reply via email to