1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-08 00:35:33 +02:00

Treat port numbers as unsigned

Port numbers are unsigned values, but we're storing them in (signed) int
variables in some places.  This isn't actually harmful, because int is
large enough to hold the entire range of ports.  However in places we don't
want to use an in_port_t (usually to avoid overflow on the last iteration
of a loop) it makes more conceptual sense to use an unsigned int. This will
also avoid some problems with later cleanups.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2022-09-24 19:08:21 +10:00 committed by Stefano Brivio
parent 0d1886dca0
commit 3ede07aac9
3 changed files with 9 additions and 8 deletions

4
tcp.c
View file

@ -3182,7 +3182,7 @@ void tcp_sock_init(const struct ctx *c, int ns, sa_family_t af,
static int tcp_sock_init_ns(void *arg)
{
struct ctx *c = (struct ctx *)arg;
int port;
unsigned port;
ns_enter(c);
@ -3381,7 +3381,7 @@ struct tcp_port_rebind_arg {
static int tcp_port_rebind(void *arg)
{
struct tcp_port_rebind_arg *a = (struct tcp_port_rebind_arg *)arg;
int port;
unsigned port;
if (a->bind_in_ns) {
ns_enter(a->c);