Skip to content

Commit

Permalink
Fix warnings about misleading indentation
Browse files Browse the repository at this point in the history
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 <nyh@scylladb.com>

x

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Message-Id: <20210614062057.1998552-5-nyh@scylladb.com>
  • Loading branch information
nyh authored and wkozaczuk committed Jun 14, 2021
1 parent 9d5fe18 commit cdc136c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bsd/sys/net/if.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion bsd/sys/netinet/in_mcast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
3 changes: 2 additions & 1 deletion bsd/sys/netinet/tcp_syncache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit cdc136c

Please sign in to comment.