X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fsnmp_agent.c;h=b213adb14a1caf815936c213a1d9ff99625521e2;hp=6a1968581abb09df32c0b251eaeb5e3e53663105;hb=77ca1a45bab2f6adf9301723d0db68e5813a6d98;hpb=d83bdb92ce4dbda05dcb7112c4e9fea1a17a3e22 diff --git a/src/snmp_agent.c b/src/snmp_agent.c index 6a196858..b213adb1 100644 --- a/src/snmp_agent.c +++ b/src/snmp_agent.c @@ -124,7 +124,7 @@ static int snmp_agent_oid_to_string(char *buf, size_t buf_size, char *oid_str_ptr[MAX_OID_LEN]; for (size_t i = 0; i < o->oid_len; i++) { - ssnprintf(oid_str[i], sizeof(oid_str[i]), "%lu", (unsigned long)o->oid[i]); + snprintf(oid_str[i], sizeof(oid_str[i]), "%lu", (unsigned long)o->oid[i]); oid_str_ptr[i] = oid_str[i]; } @@ -166,7 +166,7 @@ static void snmp_agent_dump_data(void) { DEBUG(PLUGIN_NAME ": TypeInstance: %s", dd->type_instance); for (size_t i = 0; i < dd->oids_len; i++) { snmp_agent_oid_to_string(oid_str, sizeof(oid_str), &dd->oids[i]); - DEBUG(PLUGIN_NAME ": OID[%zu]: %s", i, oid_str); + DEBUG(PLUGIN_NAME ": OID[%" PRIsz "]: %s", i, oid_str); } DEBUG(PLUGIN_NAME ": Scale: %g", dd->scale); DEBUG(PLUGIN_NAME ": Shift: %g", dd->shift); @@ -190,7 +190,7 @@ static void snmp_agent_dump_data(void) { DEBUG(PLUGIN_NAME ": TypeInstance: %s", dd->type_instance); for (size_t i = 0; i < dd->oids_len; i++) { snmp_agent_oid_to_string(oid_str, sizeof(oid_str), &dd->oids[i]); - DEBUG(PLUGIN_NAME ": OID[%zu]: %s", i, oid_str); + DEBUG(PLUGIN_NAME ": OID[%" PRIsz "]: %s", i, oid_str); } DEBUG(PLUGIN_NAME ": Scale: %g", dd->scale); DEBUG(PLUGIN_NAME ": Shift: %g", dd->shift); @@ -283,7 +283,8 @@ static int snmp_agent_validate_data(void) { return 0; } -static void snmp_agent_generate_oid2string(oid_t *oid, size_t offset, char *key) { +static void snmp_agent_generate_oid2string(oid_t *oid, size_t offset, + char *key) { int key_len = oid->oid[offset]; int i; @@ -369,9 +370,9 @@ static int snmp_agent_table_row_remove(table_definition_t *td, .severity = NOTIF_WARNING, .time = cdtime(), .plugin = PLUGIN_NAME}; sstrncpy(n.host, hostname_g, sizeof(n.host)); sstrncpy(n.plugin_instance, ins, sizeof(n.plugin_instance)); - ssnprintf(n.message, sizeof(n.message), - "Removed data row from table %s instance %s index %d", td->name, - ins, (index != NULL) ? *index : -1); + snprintf(n.message, sizeof(n.message), + "Removed data row from table %s instance %s index %d", td->name, ins, + (index != NULL) ? *index : -1); plugin_dispatch_notification(&n); if (td->index_oid.oid_len) { @@ -629,9 +630,9 @@ snmp_agent_table_oid_handler(struct netsnmp_mib_handler_s *handler, if (dd->is_instance) { requests->requestvb->type = ASN_OCTET_STR; - snmp_set_var_typed_value(requests->requestvb, - requests->requestvb->type, (const u_char *)instance, - strlen((instance))); + snmp_set_var_typed_value( + requests->requestvb, requests->requestvb->type, + (const u_char *)instance, strlen((instance))); pthread_mutex_unlock(&g_agent->lock); @@ -1116,12 +1117,6 @@ static int snmp_agent_config_table(oconfig_item_t *ci) { } } - llentry_t *entry = llentry_create(td->name, td); - if (entry == NULL) { - snmp_agent_free_table(&td); - return -ENOMEM; - } - td->instance_index = c_avl_create((int (*)(const void *, const void *))strcmp); if (td->instance_index == NULL) { @@ -1136,6 +1131,11 @@ static int snmp_agent_config_table(oconfig_item_t *ci) { return -ENOMEM; } + llentry_t *entry = llentry_create(td->name, td); + if (entry == NULL) { + snmp_agent_free_table(&td); + return -ENOMEM; + } llist_append(g_agent->tables, entry); return 0; @@ -1318,9 +1318,9 @@ static int snmp_agent_update_index(table_definition_t *td, .severity = NOTIF_OKAY, .time = cdtime(), .plugin = PLUGIN_NAME}; sstrncpy(n.host, hostname_g, sizeof(n.host)); sstrncpy(n.plugin_instance, ins, sizeof(n.plugin_instance)); - ssnprintf(n.message, sizeof(n.message), - "Data row added to table %s instance %s index %d", td->name, ins, - (index != NULL) ? *index : -1); + snprintf(n.message, sizeof(n.message), + "Data row added to table %s instance %s index %d", td->name, ins, + (index != NULL) ? *index : -1); plugin_dispatch_notification(&n); return 0;