ssnprintf(cb_name, sizeof(cb_name), "snmp-%s", hd->name);
- user_data_t ud = {.data = hd, .free_func = csnmp_host_definition_destroy};
-
- status =
- plugin_register_complex_read(/* group = */ NULL, cb_name, csnmp_read_host,
- hd->interval, /* user_data = */ &ud);
+ status = plugin_register_complex_read(
+ /* group = */ NULL, cb_name, csnmp_read_host, hd->interval,
+ &(user_data_t){
+ .data = hd, .free_func = csnmp_host_definition_destroy,
+ });
if (status != 0) {
ERROR("snmp plugin: Registering complex read function failed.");
csnmp_host_definition_destroy(hd);
if (oid_list_todo_num == 0) {
/* The request is still empty - so we are finished */
DEBUG("snmp plugin: all variables have left their subtree");
+ snmp_free_pdu(req);
status = 0;
break;
}
res = NULL;
status = snmp_sess_synch_response(host->sess_handle, req, &res);
+
+ /* snmp_sess_synch_response always frees our req PDU */
+ req = NULL;
+
if ((status != STAT_SUCCESS) || (res == NULL)) {
char *errstr = NULL;
snmp_free_pdu(res);
res = NULL;
- /* snmp_synch_response already freed our PDU */
- req = NULL;
sfree(errstr);
csnmp_host_close_session(host);
for (vb = res->variables, i = 0; (vb != NULL);
vb = vb->next_variable, i++) {
/* Calculate value index from todo list */
- while ((i < oid_list_len) && !oid_list_todo[i])
+ while ((i < oid_list_len) && !oid_list_todo[i]) {
i++;
+ }
+ if (i >= oid_list_len) {
+ break;
+ }
/* An instance is configured and the res variable we process is the
* instance value (last index) */
snmp_free_pdu(res);
res = NULL;
- if (req != NULL)
- snmp_free_pdu(req);
- req = NULL;
-
if (status == 0)
csnmp_dispatch_table(host, data, instance_list_head, value_list_head);