From c914000971063a4500cfb34f4141dfc3c943368d Mon Sep 17 00:00:00 2001 From: "[anp/hsw]" Date: Sat, 13 Mar 2021 18:43:15 +0700 Subject: Fix some errors and warnings found by cppcheck [accel-pppd/ctrl/ipoe/ipoe.c:4054]: (style) A pointer can not be negative so it is either pointless or an error to check if it is not. [accel-pppd/logs/log_syslog.c:148]: (error) Array 'facility_name[9]' accessed at index 35, which is out of bounds. [accel-pppd/lua/session.c:274]: (error) Common realloc mistake: 'mods' nulled but not freed upon failure [accel-pppd/extra/ippool.c:114]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:114]: (warning) %u in format string (no. 2) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:114]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:114]: (warning) %u in format string (no. 4) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:114]: (warning) %u in format string (no. 5) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:141]: (warning) %u in format string (no. 1) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:141]: (warning) %u in format string (no. 2) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:141]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:141]: (warning) %u in format string (no. 4) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/extra/ippool.c:141]: (warning) %u in format string (no. 5) requires 'unsigned int *' but the argument type is 'int *'. [accel-pppd/main.c:97]: (warning) %d in format string (no. 1) requires 'int *' but the argument type is 'unsigned int *'. [accel-pppd/radius/radius.c:687] -> [accel-pppd/radius/radius.c:690]: (warning) Possible null pointer dereference: rpd - otherwise it is redundant to check it against null. [accel-pppd/radius/serv.c:805] -> [accel-pppd/radius/serv.c:829]: (warning) Possible null pointer dereference: ptr2 - otherwise it is redundant to check it against null. [accel-pppd/radius/serv.c:813] -> [accel-pppd/radius/serv.c:829]: (warning) Possible null pointer dereference: ptr2 - otherwise it is redundant to check it against null. [accel-pppd/radius/serv.c:823] -> [accel-pppd/radius/serv.c:829]: (warning) Possible null pointer dereference: ptr2 - otherwise it is redundant to check it against null. --- accel-pppd/ctrl/ipoe/ipoe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'accel-pppd/ctrl') diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index d91596ae..0649e9c8 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -4051,7 +4051,7 @@ static void load_config(void) opt = conf_get_opt("ipoe", "check-ip"); if (!opt) opt = conf_get_opt("common", "check-ip"); - if (opt && opt >= 0) + if (opt) conf_check_exists = atoi(opt) > 0; #ifdef RADIUS -- cgit v1.2.3 From 6c2fb7f07692ec8d9aad971b177dbb8718bf391a Mon Sep 17 00:00:00 2001 From: "[anp/hsw]" Date: Sat, 13 Mar 2021 20:22:05 +0700 Subject: Fix another errors found by cppcheck [accel-pppd/cli/tcp.c:305]: (error) Uninitialized variable: cln [accel-pppd/cli/telnet.c:642]: (error) Uninitialized variable: cln [accel-pppd/ctrl/l2tp/l2tp.c:4302]: (error) Uninitialized variable: msg_attr [accel-pppd/ctrl/l2tp/l2tp.c:4484]: (error) Uninitialized variable: msg_type [accel-pppd/ctrl/pppoe/disc.c:169]: (error) Uninitialized variable: n [accel-pppd/ctrl/pppoe/pppoe.c:1588]: (error) Uninitialized variable: pado --- accel-pppd/cli/tcp.c | 2 +- accel-pppd/cli/telnet.c | 2 +- accel-pppd/ctrl/l2tp/l2tp.c | 4 ++-- accel-pppd/ctrl/pppoe/disc.c | 2 +- accel-pppd/ctrl/pppoe/pppoe.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'accel-pppd/ctrl') diff --git a/accel-pppd/cli/tcp.c b/accel-pppd/cli/tcp.c index 270d8cbf..87633cbe 100644 --- a/accel-pppd/cli/tcp.c +++ b/accel-pppd/cli/tcp.c @@ -298,7 +298,7 @@ static int serv_read(struct triton_md_handler_t *h) static void serv_close(struct triton_context_t *ctx) { - struct tcp_client_t *cln; + struct tcp_client_t *cln = NULL; while (!list_empty(&clients)) { cln = list_entry(clients.next, typeof(*cln), entry); diff --git a/accel-pppd/cli/telnet.c b/accel-pppd/cli/telnet.c index 4b5f63ba..4ea18391 100644 --- a/accel-pppd/cli/telnet.c +++ b/accel-pppd/cli/telnet.c @@ -635,7 +635,7 @@ static int serv_read(struct triton_md_handler_t *h) } static void serv_close(struct triton_context_t *ctx) { - struct telnet_client_t *cln; + struct telnet_client_t *cln = NULL; while (!list_empty(&clients)) { cln = list_entry(clients.next, typeof(*cln), entry); diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 2467189f..8567027d 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -4224,7 +4224,7 @@ static int l2tp_tunnel_store_msg(struct l2tp_conn_t *conn, static int l2tp_tunnel_reply(struct l2tp_conn_t *conn, int need_ack) { - const struct l2tp_attr_t *msg_attr; + const struct l2tp_attr_t *msg_attr = NULL; struct l2tp_packet_t *pack; struct l2tp_sess_t *sess; uint16_t msg_sid; @@ -4430,7 +4430,7 @@ static int l2tp_udp_read(struct triton_md_handler_t *h) { struct l2tp_serv_t *serv = container_of(h, typeof(*serv), hnd); struct l2tp_packet_t *pack; - const struct l2tp_attr_t *msg_type; + const struct l2tp_attr_t *msg_type = NULL; struct in_pktinfo pkt_info; char src_addr[17]; diff --git a/accel-pppd/ctrl/pppoe/disc.c b/accel-pppd/ctrl/pppoe/disc.c index a0a21751..b1119eb1 100644 --- a/accel-pppd/ctrl/pppoe/disc.c +++ b/accel-pppd/ctrl/pppoe/disc.c @@ -139,7 +139,7 @@ int pppoe_disc_start(struct pppoe_serv_t *serv) struct rb_node **p, *parent = NULL; struct tree *t; int ifindex = serv->ifindex, i; - struct pppoe_serv_t *n; + struct pppoe_serv_t *n = NULL; if (!net) { pthread_mutex_lock(&nets_lock); diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index 045a638e..6d876495 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -1577,7 +1577,7 @@ void _server_stop(struct pppoe_serv_t *serv) void pppoe_server_free(struct pppoe_serv_t *serv) { - struct delayed_pado_t *pado; + struct delayed_pado_t *pado = NULL; pthread_rwlock_wrlock(&serv_lock); list_del(&serv->entry); -- cgit v1.2.3