Skip to content

Commit

Permalink
snmp: remove handling of varbind->prev because it is never used
Browse files Browse the repository at this point in the history
No code in snmp traverses varbinds backwards so prev is never used.
This also fixes false positive dangling pointer detection by GCC.
  • Loading branch information
j123b567 committed Nov 27, 2024
1 parent d274279 commit 55e4e2d
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/apps/snmp/snmp_traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
u16_t tot_len = 0;
err_t err = ERR_OK;
u32_t timestamp = 0;
struct snmp_varbind *original_varbinds = varbinds;
struct snmp_varbind *original_prev = NULL;
struct snmp_obj_id snmp_trap_oid = { 0 }; /* used for converting SNMPv1 generic/specific trap parameter to SNMPv2 snmpTrapOID */
struct snmp_varbind snmp_v2_special_varbinds[] = {
/* First varbind is used to store sysUpTime */
Expand Down Expand Up @@ -384,7 +382,6 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
LWIP_ASSERT_SNMP_LOCKED();

snmp_v2_special_varbinds[0].next = &snmp_v2_special_varbinds[1];
snmp_v2_special_varbinds[1].prev = &snmp_v2_special_varbinds[0];

snmp_v2_special_varbinds[0].value = &timestamp;

Expand All @@ -396,10 +393,6 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
if (err == ERR_OK) {
snmp_v2_special_varbinds[1].value_len = snmp_trap_oid.len * sizeof(snmp_trap_oid.id[0]);
snmp_v2_special_varbinds[1].value = snmp_trap_oid.id;
if (varbinds != NULL) {
original_prev = varbinds->prev;
varbinds->prev = &snmp_v2_special_varbinds[1];
}
varbinds = snmp_v2_special_varbinds; /* After inserting two varbinds at the beginning of the list, make sure that pointer is pointing to the first element */
}
}
Expand All @@ -422,9 +415,6 @@ snmp_send_trap_or_notification_or_inform_generic(struct snmp_msg_trap *trap_msg,
}
}
}
if ((trap_msg->snmp_version == SNMP_VERSION_2c) && (original_varbinds != NULL)) {
original_varbinds->prev = original_prev;
}
req_id++;
return err;
}
Expand Down

0 comments on commit 55e4e2d

Please sign in to comment.