Skip to content

Commit 26549da

Browse files
Li Zetaokuba-moo
authored andcommitted
ipv6: mcast: use min() to simplify the code
When coping sockaddr in ip6_mc_msfget(), the time of copies depends on the minimum value between sl_count and gf_numsrc. Using min() here is very semantic. Signed-off-by: Li Zetao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b4985aa commit 26549da

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/ipv6/mcast.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
586586
const struct in6_addr *group;
587587
struct ipv6_mc_socklist *pmc;
588588
struct ip6_sf_socklist *psl;
589-
int i, count, copycount;
589+
unsigned int count;
590+
int i, copycount;
590591

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

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

613-
copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc;
614+
copycount = min(count, gsf->gf_numsrc);
614615
gsf->gf_numsrc = count;
615616
for (i = 0; i < copycount; i++) {
616617
struct sockaddr_in6 *psin6;

0 commit comments

Comments
 (0)