Commit 5efc9623 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'some-modifications-to-optimize-code-readability'

Li Zetao says:

====================
Some modifications to optimize code readability

This patchset is mainly optimized for readability in contexts where size
needs to be determined. By using min() or max(), or even directly
removing redundant judgments (such as the 5th patch), the code is more
consistent with the context.
====================

Link: https://patch.msgid.link/20240822133908.1042240-1-lizetao1@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 77f0caec a1830862
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -298,10 +298,8 @@ struct cfpkt *cfpkt_append(struct cfpkt *dstpkt,
	if (unlikely(is_erronous(dstpkt) || is_erronous(addpkt))) {
		return dstpkt;
	}
	if (expectlen > addlen)
		neededtailspace = expectlen;
	else
		neededtailspace = addlen;

	neededtailspace = max(expectlen, addlen);

	if (dst->tail + neededtailspace > dst->end) {
		/* Create a dumplicate of 'dst' with more tail space */
+3 −2
Original line number Diff line number Diff line
@@ -586,7 +586,8 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
	const struct in6_addr *group;
	struct ipv6_mc_socklist *pmc;
	struct ip6_sf_socklist *psl;
	int i, count, copycount;
	unsigned int count;
	int i, copycount;

	group = &((struct sockaddr_in6 *)&gsf->gf_group)->sin6_addr;

@@ -610,7 +611,7 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
	psl = sock_dereference(pmc->sflist, sk);
	count = psl ? psl->sl_count : 0;

	copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc;
	copycount = min(count, gsf->gf_numsrc);
	gsf->gf_numsrc = count;
	for (i = 0; i < copycount; i++) {
		struct sockaddr_in6 *psin6;
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ static int dom_size(int peers)

	while ((i * i) < peers)
		i++;
	return i < MAX_MON_DOMAIN ? i : MAX_MON_DOMAIN;
	return min(i, MAX_MON_DOMAIN);
}

static void map_set(u64 *up_map, int i, unsigned int v)