From 1662776d6b3aba14fde091ec30f1ab53768d67ba Mon Sep 17 00:00:00 2001 From: Ahurac Date: Sun, 10 Dec 2023 15:30:36 +0100 Subject: [PATCH] =?UTF-8?q?first-free-port=20:=20suppression=20param=C3=A8?= =?UTF-8?q?tre=20inutile=20`get=5Flistening=5Fports`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/first-free-port.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/first-free-port.c b/src/first-free-port.c index 35005dc..320b14e 100644 --- a/src/first-free-port.c +++ b/src/first-free-port.c @@ -23,7 +23,8 @@ static void print_error(char *name, const char *message) { /** * Get all the listening TCP ports */ -static unsigned short *get_listening_ports(unsigned short *listening_ports, FILE *tcp_table_fptr) { +static unsigned short *get_listening_ports(FILE *tcp_table_fptr) { + unsigned short *listening_ports = malloc(BLOCKS_TO_ALLOC * sizeof(short)); char line[TCP_TABLE_LINE_LENGTH]; char delimiter[] = " "; unsigned short len = 0; @@ -99,8 +100,7 @@ int main(int argc, char *argv[]) { return errno; } - unsigned short *listening_ports = malloc(PORTS_BLOCKS_TO_ALLOW * sizeof(unsigned short)); - listening_ports = get_listening_ports(listening_ports, tcp_table_fptr); + unsigned short *listening_ports = get_listening_ports(tcp_table_fptr); if (fclose(tcp_table_fptr) != 0) { print_error(argv[0], "can't close the TCP table.");