fix/TD-31891-remove-void-monitor2

This commit is contained in:
dmchen 2024-09-23 04:42:56 +00:00
parent d1e8b7bbd7
commit 160440a8e4
12 changed files with 147 additions and 80 deletions

View File

@ -30,7 +30,7 @@ taos_metric_formatter_t *taos_metric_formatter_new();
/** /**
* @brief API PRIVATE taos_metric_formatter destructor * @brief API PRIVATE taos_metric_formatter destructor
*/ */
int taos_metric_formatter_destroy(taos_metric_formatter_t *self); void taos_metric_formatter_destroy(taos_metric_formatter_t *self);
/** /**
* @brief API PRIVATE Loads the help text * @brief API PRIVATE Loads the help text

View File

@ -31,7 +31,7 @@ taos_string_builder_t *taos_string_builder_new(void);
* API PRIVATE * API PRIVATE
* @brief Destroys a taos_string_builder* * @brief Destroys a taos_string_builder*
*/ */
int taos_string_builder_destroy(taos_string_builder_t *self); void taos_string_builder_destroy(taos_string_builder_t *self);
/** /**
* API PRIVATE * API PRIVATE

View File

@ -23,6 +23,11 @@
if (!(i)) return 1; if (!(i)) return 1;
#define TAOS_TEST_PARA_NULL(i) \ #define TAOS_TEST_PARA_NULL(i) \
if (!(i)) return NULL; if (!(i)) return NULL;
#define TAOS_TEST_PARA_VOID(i) \
if (!(i)) { \
TAOS_LOG("parameter is NULL"); \
return; \
}
#endif // TAOS_TEST #endif // TAOS_TEST
#endif // TAOS_TEST_H #endif // TAOS_TEST_H

View File

@ -39,18 +39,24 @@ taos_collector_t *taos_collector_new(const char *name) {
self->name = taos_strdup(name); self->name = taos_strdup(name);
self->metrics = taos_map_new(); self->metrics = taos_map_new();
if (self->metrics == NULL) { if (self->metrics == NULL) {
(void)taos_collector_destroy(self); if (taos_collector_destroy(self) != 0) {
TAOS_LOG("taos_collector_destroy failed");
}
return NULL; return NULL;
} }
r = taos_map_set_free_value_fn(self->metrics, &taos_metric_free_generic); r = taos_map_set_free_value_fn(self->metrics, &taos_metric_free_generic);
if (r) { if (r) {
(void)taos_collector_destroy(self); if (taos_collector_destroy(self) != 0) {
TAOS_LOG("taos_collector_destroy failed");
}
return NULL; return NULL;
} }
self->collect_fn = &taos_collector_default_collect; self->collect_fn = &taos_collector_default_collect;
self->string_builder = taos_string_builder_new(); self->string_builder = taos_string_builder_new();
if (self->string_builder == NULL) { if (self->string_builder == NULL) {
(void)taos_collector_destroy(self); if (taos_collector_destroy(self) != 0) {
TAOS_LOG("taos_collector_destroy failed");
}
return NULL; return NULL;
} }
self->proc_limits_file_path = NULL; self->proc_limits_file_path = NULL;
@ -70,8 +76,7 @@ int taos_collector_destroy(taos_collector_t *self) {
self->metrics = NULL; self->metrics = NULL;
if(self->string_builder != NULL){ if(self->string_builder != NULL){
r = taos_string_builder_destroy(self->string_builder); taos_string_builder_destroy(self->string_builder);
if (r) ret = r;
self->string_builder = NULL; self->string_builder = NULL;
} }
@ -93,7 +98,9 @@ int taos_collector_destroy_generic(void *gen) {
void taos_collector_free_generic(void *gen) { void taos_collector_free_generic(void *gen) {
taos_collector_t *self = (taos_collector_t *)gen; taos_collector_t *self = (taos_collector_t *)gen;
(void)taos_collector_destroy(self); if (taos_collector_destroy(self) != 0) {
TAOS_LOG("taos_collector_destroy failed");
}
} }
int taos_collector_set_collect_fn(taos_collector_t *self, taos_collect_fn *fn) { int taos_collector_set_collect_fn(taos_collector_t *self, taos_collect_fn *fn) {

View File

@ -50,7 +50,7 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) {
self->name = taos_strdup(name); self->name = taos_strdup(name);
self->collectors = taos_map_new(); self->collectors = taos_map_new();
(void)taos_map_set_free_value_fn(self->collectors, &taos_collector_free_generic); if (taos_map_set_free_value_fn(self->collectors, &taos_collector_free_generic) != 0) return NULL;
if (taos_map_set(self->collectors, "default", taos_collector_new("default")) != 0) return NULL; if (taos_map_set(self->collectors, "default", taos_collector_new("default")) != 0) return NULL;
self->metric_formatter = taos_metric_formatter_new(); self->metric_formatter = taos_metric_formatter_new();
@ -86,17 +86,14 @@ int taos_collector_registry_destroy(taos_collector_registry_t *self) {
self->collectors = NULL; self->collectors = NULL;
if (r) ret = r; if (r) ret = r;
r = taos_metric_formatter_destroy(self->metric_formatter); taos_metric_formatter_destroy(self->metric_formatter);
self->metric_formatter = NULL; self->metric_formatter = NULL;
if (r) ret = r;
r = taos_string_builder_destroy(self->string_builder); taos_string_builder_destroy(self->string_builder);
self->string_builder = NULL; self->string_builder = NULL;
if (r) ret = r;
r = taos_string_builder_destroy(self->string_builder_batch); taos_string_builder_destroy(self->string_builder_batch);
self->string_builder_batch = NULL; self->string_builder_batch = NULL;
if (r) ret = r;
r = pthread_rwlock_destroy(self->lock); r = pthread_rwlock_destroy(self->lock);
taos_free(self->lock); taos_free(self->lock);
@ -241,13 +238,25 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self,
SJson* pJson = tjsonCreateArray(); SJson* pJson = tjsonCreateArray();
SJson* item = tjsonCreateObject(); SJson* item = tjsonCreateObject();
(void)tjsonAddItemToArray(pJson, item); if (tjsonAddItemToArray(pJson, item) != 0) {
(void)tjsonAddStringToObject(item, "ts", ts); tjsonDelete(pJson);
(void)tjsonAddDoubleToObject(item, "protocol", 2); return NULL;
SJson* array = tjsonCreateArray(); }
(void)tjsonAddItemToObject(item, "tables", array); if (tjsonAddStringToObject(item, "ts", ts) != 0) {
tjsonDelete(pJson);
return NULL;
}
if (tjsonAddDoubleToObject(item, "protocol", 2) != 0) {
tjsonDelete(pJson);
return NULL;
}
SJson *array = tjsonCreateArray();
if (tjsonAddItemToObject(item, "tables", array) != 0) {
tjsonDelete(pJson);
return NULL;
}
if(taos_metric_formatter_load_metrics_new(self->metric_formatter, self->collectors, ts, format, array) != 0){ if (taos_metric_formatter_load_metrics_new(self->metric_formatter, self->collectors, ts, format, array) != 0) {
TAOS_LOG("failed to load metrics"); TAOS_LOG("failed to load metrics");
tjsonDelete(pJson); tjsonDelete(pJson);
return NULL; return NULL;
@ -294,9 +303,8 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self,
r = taos_string_builder_clear(tmp_builder); r = taos_string_builder_clear(tmp_builder);
if (r) goto _OVER;; if (r) goto _OVER;;
r = taos_string_builder_destroy(tmp_builder); taos_string_builder_destroy(tmp_builder);
tmp_builder = NULL; tmp_builder = NULL;
if (r) goto _OVER;;
tjsonDelete(pJson); tjsonDelete(pJson);
return data; return data;
@ -304,7 +312,7 @@ const char *taos_collector_registry_bridge_new(taos_collector_registry_t *self,
_OVER: _OVER:
tjsonDelete(pJson); tjsonDelete(pJson);
if(tmp_builder != NULL){ if(tmp_builder != NULL){
(void)taos_string_builder_destroy(tmp_builder); taos_string_builder_destroy(tmp_builder);
} }
return NULL; return NULL;

View File

@ -45,21 +45,19 @@ taos_map_node_t *taos_map_node_new(const char *key, void *value, taos_map_node_f
return self; return self;
} }
int taos_map_node_destroy(taos_map_node_t *self) { void taos_map_node_destroy(taos_map_node_t *self) {
TAOS_TEST_PARA(self != NULL); TAOS_TEST_PARA_VOID(self != NULL);
if (self == NULL) return 0;
taos_free((void *)self->key); taos_free((void *)self->key);
self->key = NULL; self->key = NULL;
if (self->value != NULL) (*self->free_value_fn)(self->value); if (self->value != NULL) (*self->free_value_fn)(self->value);
self->value = NULL; self->value = NULL;
taos_free(self); taos_free(self);
self = NULL; self = NULL;
return 0;
} }
void taos_map_node_free(void *item) { void taos_map_node_free(void *item) {
taos_map_node_t *map_node = (taos_map_node_t *)item; taos_map_node_t *map_node = (taos_map_node_t *)item;
(void)taos_map_node_destroy(map_node); taos_map_node_destroy(map_node);
} }
taos_linked_list_compare_t taos_map_node_compare(void *item_a, void *item_b) { taos_linked_list_compare_t taos_map_node_compare(void *item_a, void *item_b) {
@ -87,7 +85,9 @@ taos_map_t *taos_map_new() {
// we will only have to deallocate each key once. That will happen on taos_map_node_destroy. // we will only have to deallocate each key once. That will happen on taos_map_node_destroy.
r = taos_linked_list_set_free_fn(self->keys, taos_linked_list_no_op_free); r = taos_linked_list_set_free_fn(self->keys, taos_linked_list_no_op_free);
if (r) { if (r) {
(void)taos_map_destroy(self); if (taos_map_destroy(self) != 0) {
TAOS_LOG("TAOS_MAP_DESTROY_ERROR");
}
return NULL; return NULL;
} }
@ -98,12 +98,16 @@ taos_map_t *taos_map_new() {
self->addrs[i] = taos_linked_list_new(); self->addrs[i] = taos_linked_list_new();
r = taos_linked_list_set_free_fn(self->addrs[i], taos_map_node_free); r = taos_linked_list_set_free_fn(self->addrs[i], taos_map_node_free);
if (r) { if (r) {
(void)taos_map_destroy(self); if (taos_map_destroy(self) != 0) {
TAOS_LOG("TAOS_MAP_DESTROY_ERROR");
}
return NULL; return NULL;
} }
r = taos_linked_list_set_compare_fn(self->addrs[i], taos_map_node_compare); r = taos_linked_list_set_compare_fn(self->addrs[i], taos_map_node_compare);
if (r) { if (r) {
(void)taos_map_destroy(self); if (taos_map_destroy(self) != 0) {
TAOS_LOG("TAOS_MAP_DESTROY_ERROR");
}
return NULL; return NULL;
} }
} }
@ -112,7 +116,9 @@ taos_map_t *taos_map_new() {
r = pthread_rwlock_init(self->rwlock, NULL); r = pthread_rwlock_init(self->rwlock, NULL);
if (r) { if (r) {
TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR); TAOS_LOG(TAOS_PTHREAD_RWLOCK_INIT_ERROR);
(void)taos_map_destroy(self); if (taos_map_destroy(self) != 0) {
TAOS_LOG("TAOS_MAP_DESTROY_ERROR");
}
return NULL; return NULL;
} }
@ -188,12 +194,12 @@ static void *taos_map_get_internal(const char *key, size_t *size, size_t *max_si
taos_map_node_t *current_map_node = (taos_map_node_t *)current_node->item; taos_map_node_t *current_map_node = (taos_map_node_t *)current_node->item;
taos_linked_list_compare_t result = taos_linked_list_compare(list, current_map_node, temp_map_node); taos_linked_list_compare_t result = taos_linked_list_compare(list, current_map_node, temp_map_node);
if (result == TAOS_EQUAL) { if (result == TAOS_EQUAL) {
(void)taos_map_node_destroy(temp_map_node); taos_map_node_destroy(temp_map_node);
temp_map_node = NULL; temp_map_node = NULL;
return current_map_node->value; return current_map_node->value;
} }
} }
(void)taos_map_node_destroy(temp_map_node); taos_map_node_destroy(temp_map_node);
temp_map_node = NULL; temp_map_node = NULL;
return NULL; return NULL;
} }
@ -388,7 +394,7 @@ static int taos_map_delete_internal(const char *key, size_t *size, size_t *max_s
break; break;
} }
} }
r = taos_map_node_destroy(temp_map_node); taos_map_node_destroy(temp_map_node);
temp_map_node = NULL; temp_map_node = NULL;
return r; return r;
} }

View File

@ -49,12 +49,12 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name,
for (int i = 0; i < label_key_count; i++) { for (int i = 0; i < label_key_count; i++) {
if (strcmp(label_keys[i], "le") == 0) { if (strcmp(label_keys[i], "le") == 0) {
TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME); TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME);
(void)taos_metric_destroy(self); if (taos_metric_destroy(self) != 0) return NULL;
return NULL; return NULL;
} }
if (strcmp(label_keys[i], "quantile") == 0) { if (strcmp(label_keys[i], "quantile") == 0) {
TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME); TAOS_LOG(TAOS_METRIC_INVALID_LABEL_NAME);
(void)taos_metric_destroy(self); if (taos_metric_destroy(self) != 0) return NULL;
return NULL; return NULL;
} }
k[i] = taos_strdup(label_keys[i]); k[i] = taos_strdup(label_keys[i]);
@ -68,14 +68,14 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name,
} else { } else {
r = taos_map_set_free_value_fn(self->samples, &taos_metric_sample_free_generic); r = taos_map_set_free_value_fn(self->samples, &taos_metric_sample_free_generic);
if (r) { if (r) {
(void)taos_metric_destroy(self); if (taos_metric_destroy(self) != 0) return NULL;
return NULL; return NULL;
} }
} }
self->formatter = taos_metric_formatter_new(); self->formatter = taos_metric_formatter_new();
if (self->formatter == NULL) { if (self->formatter == NULL) {
(void)taos_metric_destroy(self); if (taos_metric_destroy(self) != 0) return NULL;
return NULL; return NULL;
} }
self->rwlock = (pthread_rwlock_t *)taos_malloc(sizeof(pthread_rwlock_t)); self->rwlock = (pthread_rwlock_t *)taos_malloc(sizeof(pthread_rwlock_t));
@ -101,9 +101,8 @@ int taos_metric_destroy(taos_metric_t *self) {
if (r) ret = r; if (r) ret = r;
} }
r = taos_metric_formatter_destroy(self->formatter); taos_metric_formatter_destroy(self->formatter);
self->formatter = NULL; self->formatter = NULL;
if (r) ret = r;
r = pthread_rwlock_destroy(self->rwlock); r = pthread_rwlock_destroy(self->rwlock);
if (r) { if (r) {
@ -140,7 +139,9 @@ int taos_metric_destroy_generic(void *item) {
void taos_metric_free_generic(void *item) { void taos_metric_free_generic(void *item) {
taos_metric_t *self = (taos_metric_t *)item; taos_metric_t *self = (taos_metric_t *)item;
(void)taos_metric_destroy(self); if (taos_metric_destroy(self) != 0) {
TAOS_LOG("taos_metric_destroy failed");
}
} }
taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const char **label_values) { taos_metric_sample_t *taos_metric_sample_from_labels(taos_metric_t *self, const char **label_values) {

View File

@ -22,6 +22,7 @@
// Private // Private
#include "taos_collector_t.h" #include "taos_collector_t.h"
#include "taos_linked_list_t.h" #include "taos_linked_list_t.h"
#include "taos_log.h"
#include "taos_map_i.h" #include "taos_map_i.h"
#include "taos_metric_formatter_i.h" #include "taos_metric_formatter_i.h"
#include "taos_metric_sample_t.h" #include "taos_metric_sample_t.h"
@ -33,35 +34,28 @@ taos_metric_formatter_t *taos_metric_formatter_new() {
taos_metric_formatter_t *self = (taos_metric_formatter_t *)taos_malloc(sizeof(taos_metric_formatter_t)); taos_metric_formatter_t *self = (taos_metric_formatter_t *)taos_malloc(sizeof(taos_metric_formatter_t));
self->string_builder = taos_string_builder_new(); self->string_builder = taos_string_builder_new();
if (self->string_builder == NULL) { if (self->string_builder == NULL) {
(void)taos_metric_formatter_destroy(self); taos_metric_formatter_destroy(self);
return NULL; return NULL;
} }
self->err_builder = taos_string_builder_new(); self->err_builder = taos_string_builder_new();
if (self->err_builder == NULL) { if (self->err_builder == NULL) {
(void)taos_metric_formatter_destroy(self); taos_metric_formatter_destroy(self);
return NULL; return NULL;
} }
return self; return self;
} }
int taos_metric_formatter_destroy(taos_metric_formatter_t *self) { void taos_metric_formatter_destroy(taos_metric_formatter_t *self) {
TAOS_TEST_PARA(self != NULL); TAOS_TEST_PARA_VOID(self != NULL);
if (self == NULL) return 0;
int r = 0; taos_string_builder_destroy(self->string_builder);
int ret = 0;
r = taos_string_builder_destroy(self->string_builder);
self->string_builder = NULL; self->string_builder = NULL;
if (r) ret = r;
r = taos_string_builder_destroy(self->err_builder); taos_string_builder_destroy(self->err_builder);
self->err_builder = NULL; self->err_builder = NULL;
if (r) ret = r;
taos_free(self); taos_free(self);
self = NULL; self = NULL;
return ret;
} }
/* /*
int taos_metric_formatter_load_help(taos_metric_formatter_t *self, const char *name, const char *help) { int taos_metric_formatter_load_help(taos_metric_formatter_t *self, const char *name, const char *help) {

View File

@ -88,17 +88,47 @@ int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_me
char* value = *(pair + 1); char* value = *(pair + 1);
SJson* tag = tjsonCreateObject(); SJson* tag = tjsonCreateObject();
(void)tjsonAddStringToObject(tag, "name", key); if (tjsonAddStringToObject(tag, "name", key) != 0) {
(void)tjsonAddStringToObject(tag, "value", value); taosMemoryFreeClear(arr);
taosMemoryFreeClear(keyvalue);
taosMemoryFreeClear(keyvalues);
return 1;
}
if (tjsonAddStringToObject(tag, "value", value) != 0) {
taosMemoryFreeClear(arr);
taosMemoryFreeClear(keyvalue);
taosMemoryFreeClear(keyvalues);
return 1;
}
(void)tjsonAddItemToArray(arrayTag, tag); if (tjsonAddItemToArray(arrayTag, tag) != 0) {
taosMemoryFreeClear(arr);
taosMemoryFreeClear(keyvalue);
taosMemoryFreeClear(keyvalues);
return 1;
}
}
if (tjsonAddItemToObject(item, "tags", arrayTag) != 0) {
taosMemoryFreeClear(arr);
taosMemoryFreeClear(keyvalue);
taosMemoryFreeClear(keyvalues);
return 1;
} }
(void)tjsonAddItemToObject(item, "tags", arrayTag);
metrics = tjsonCreateArray(); metrics = tjsonCreateArray();
(void)tjsonAddItemToObject(item, "metrics", metrics); if (tjsonAddItemToObject(item, "metrics", metrics) != 0) {
taosMemoryFreeClear(arr);
taosMemoryFreeClear(keyvalue);
taosMemoryFreeClear(keyvalues);
return 1;
}
(void)tjsonAddItemToArray(arrayMetricGroups, item); if (tjsonAddItemToArray(arrayMetricGroups, item) != 0) {
taosMemoryFreeClear(arr);
taosMemoryFreeClear(keyvalue);
taosMemoryFreeClear(keyvalues);
return 1;
}
} }
else{ else{
metrics = tjsonGetObjectItem(item, "metrics"); metrics = tjsonGetObjectItem(item, "metrics");
@ -109,20 +139,20 @@ int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_me
taosMemoryFreeClear(keyvalues); taosMemoryFreeClear(keyvalues);
SJson* metric = tjsonCreateObject(); SJson* metric = tjsonCreateObject();
(void)tjsonAddStringToObject(metric, "name", metricName); if (tjsonAddStringToObject(metric, "name", metricName) != 0) return 1;
double old_value = 0; double old_value = 0;
#define USE_EXCHANGE #define USE_EXCHANGE
#ifdef USE_EXCHANGE #ifdef USE_EXCHANGE
(void)taos_metric_sample_exchange(sample, 0, &old_value); if (taos_metric_sample_exchange(sample, 0, &old_value) != 0) return 1;
#else #else
old_value = sample->r_value; old_value = sample->r_value;
taos_metric_sample_set(sample, 0); taos_metric_sample_set(sample, 0);
#endif #endif
(void)tjsonAddDoubleToObject(metric, "value", old_value); if (tjsonAddDoubleToObject(metric, "value", old_value) != 0) return 1;
(void)tjsonAddDoubleToObject(metric, "type", metric_type); if (tjsonAddDoubleToObject(metric, "type", metric_type) != 0) return 1;
(void)tjsonAddItemToArray(metrics, metric); if (tjsonAddItemToArray(metrics, metric) != 0) return 1;
return 0; return 0;
} }
@ -150,7 +180,11 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me
SJson* table = tjsonGetArrayItem(tableArray, i); SJson* table = tjsonGetArrayItem(tableArray, i);
char tableName[MONITOR_TABLENAME_LEN] = {0}; char tableName[MONITOR_TABLENAME_LEN] = {0};
(void)tjsonGetStringValue(table, "name", tableName); r = tjsonGetStringValue(table, "name", tableName);
if (r) {
taosMemoryFreeClear(name);
return r;
}
if(strcmp(tableName, arr[0]) == 0){ if(strcmp(tableName, arr[0]) == 0){
isFound = true; isFound = true;
arrayMetricGroups = tjsonGetObjectItem(table, "metric_groups"); arrayMetricGroups = tjsonGetObjectItem(table, "metric_groups");
@ -161,10 +195,18 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me
if(!isFound){ if(!isFound){
table = tjsonCreateObject(); table = tjsonCreateObject();
(void)tjsonAddStringToObject(table, "name", arr[0]); r = tjsonAddStringToObject(table, "name", arr[0]);
if (r) {
taosMemoryFreeClear(name);
return r;
}
arrayMetricGroups = tjsonCreateArray(); arrayMetricGroups = tjsonCreateArray();
(void)tjsonAddItemToObject(table, "metric_groups", arrayMetricGroups); r = tjsonAddItemToObject(table, "metric_groups", arrayMetricGroups);
if (r) {
taosMemoryFreeClear(name);
return r;
}
} }
int32_t sample_count = 0; int32_t sample_count = 0;
@ -183,7 +225,11 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me
} }
if(!isFound && sample_count > 0){ if(!isFound && sample_count > 0){
(void)tjsonAddItemToArray(tableArray, table); r = tjsonAddItemToArray(tableArray, table);
if (r) {
taosMemoryFreeClear(name);
return r;
}
} }
else{ else{
if(table != NULL) tjsonDelete(table); if(table != NULL) tjsonDelete(table);

View File

@ -44,7 +44,6 @@ taos_metric_sample_t *taos_metric_sample_new(taos_metric_type_t type, const char
int taos_metric_sample_destroy(taos_metric_sample_t *self) { int taos_metric_sample_destroy(taos_metric_sample_t *self) {
TAOS_TEST_PARA(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0;
taos_free((void *)self->l_value); taos_free((void *)self->l_value);
self->l_value = NULL; self->l_value = NULL;
taos_free((void *)self); taos_free((void *)self);
@ -63,7 +62,9 @@ int taos_metric_sample_destroy_generic(void *gen) {
void taos_metric_sample_free_generic(void *gen) { void taos_metric_sample_free_generic(void *gen) {
taos_metric_sample_t *self = (taos_metric_sample_t *)gen; taos_metric_sample_t *self = (taos_metric_sample_t *)gen;
(void)taos_metric_sample_destroy(self); if(taos_metric_sample_destroy(self) != 0) {
TAOS_LOG(TAOS_METRIC_SAMPLE_DESTROY_ERROR);
}
} }
int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) { int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) {

View File

@ -84,10 +84,10 @@ bool taos_monitor_is_match(const SJson* tags, char** pairs, int32_t count) {
SJson* item = tjsonGetArrayItem(tags, i); SJson* item = tjsonGetArrayItem(tags, i);
char item_name[MONITOR_TAG_NAME_LEN] = {0}; char item_name[MONITOR_TAG_NAME_LEN] = {0};
(void)tjsonGetStringValue(item, "name", item_name); if (tjsonGetStringValue(item, "name", item_name) != 0) return false;
char item_value[MONITOR_TAG_VALUE_LEN] = {0}; char item_value[MONITOR_TAG_VALUE_LEN] = {0};
(void)tjsonGetStringValue(item, "value", item_value); if (tjsonGetStringValue(item, "value", item_value) != 0) return false;
bool isfound = false; bool isfound = false;
for(int32_t j = 0; j < count; j++){ for(int32_t j = 0; j < count; j++){

View File

@ -20,6 +20,7 @@
#include "taos_alloc.h" #include "taos_alloc.h"
// Private // Private
#include "taos_log.h"
#include "taos_string_builder_i.h" #include "taos_string_builder_i.h"
#include "taos_string_builder_t.h" #include "taos_string_builder_t.h"
#include "taos_test.h" #include "taos_test.h"
@ -44,7 +45,7 @@ taos_string_builder_t *taos_string_builder_new(void) {
self->init_size = TAOS_STRING_BUILDER_INIT_SIZE; self->init_size = TAOS_STRING_BUILDER_INIT_SIZE;
r = taos_string_builder_init(self); r = taos_string_builder_init(self);
if (r) { if (r) {
(void)taos_string_builder_destroy(self); taos_string_builder_destroy(self);
return NULL; return NULL;
} }
@ -61,14 +62,12 @@ int taos_string_builder_init(taos_string_builder_t *self) {
return 0; return 0;
} }
int taos_string_builder_destroy(taos_string_builder_t *self) { void taos_string_builder_destroy(taos_string_builder_t *self) {
TAOS_TEST_PARA(self != NULL); TAOS_TEST_PARA_VOID(self != NULL);
if (self == NULL) return 0;
taos_free(self->str); taos_free(self->str);
self->str = NULL; self->str = NULL;
taos_free(self); taos_free(self);
self = NULL; self = NULL;
return 0;
} }
/** /**