fix/TD-31542-monitorfw-rename-assert

This commit is contained in:
dmchen 2024-08-22 09:23:02 +00:00
parent bebf552506
commit f85f96d862
12 changed files with 74 additions and 75 deletions

View File

@ -16,16 +16,15 @@
#include <assert.h> #include <assert.h>
#ifndef TAOS_ASSERT_H #ifndef TAOS_TEST_H
#define TAOS_ASSERT_H #define TAOS_TEST_H
#ifdef TAOS_ASSERT_ENABLE #ifdef TAOS_TEST_PARA_ENABLE
#define TAOS_ASSERT(i) assert(i);
#else #else
#define TAOS_ASSERT(i) \ #define TAOS_TEST_PARA(i) \
if (!(i)) return 1; if (!(i)) return 1;
#define TAOS_ASSERT_NULL(i) \ #define TAOS_TEST_PARA_NULL(i) \
if (!(i)) return NULL; if (!(i)) return NULL;
#endif // TAOS_TEST #endif // TAOS_TEST
#endif // TAOS_ASSERT_H #endif // TAOS_TEST_H

View File

@ -59,7 +59,7 @@ taos_collector_t *taos_collector_new(const char *name) {
} }
int taos_collector_destroy(taos_collector_t *self) { int taos_collector_destroy(taos_collector_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0; if (self == NULL) return 0;
int r = 0; int r = 0;
@ -97,14 +97,14 @@ void taos_collector_free_generic(void *gen) {
} }
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) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
self->collect_fn = fn; self->collect_fn = fn;
return 0; return 0;
} }
int taos_collector_add_metric(taos_collector_t *self, taos_metric_t *metric) { int taos_collector_add_metric(taos_collector_t *self, taos_metric_t *metric) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (taos_map_get(self->metrics, metric->name) != NULL) { if (taos_map_get(self->metrics, metric->name) != NULL) {
TAOS_LOG("metric already found in collector"); TAOS_LOG("metric already found in collector");
@ -114,13 +114,13 @@ int taos_collector_add_metric(taos_collector_t *self, taos_metric_t *metric) {
} }
int taos_collector_remove_metric(taos_collector_t *self, const char* key){ int taos_collector_remove_metric(taos_collector_t *self, const char* key){
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
return taos_map_delete(self->metrics, key); return taos_map_delete(self->metrics, key);
} }
taos_metric_t* taos_collector_get_metric(taos_collector_t *self, char *metric_name){ taos_metric_t* taos_collector_get_metric(taos_collector_t *self, char *metric_name){
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
if (self == NULL) return NULL; if (self == NULL) return NULL;
return taos_map_get(self->metrics, metric_name); return taos_map_get(self->metrics, metric_name);
} }

View File

@ -113,7 +113,7 @@ int taos_collector_registry_destroy(taos_collector_registry_t *self) {
} }
int taos_collector_registry_register_metric(taos_metric_t *metric) { int taos_collector_registry_register_metric(taos_metric_t *metric) {
TAOS_ASSERT(metric != NULL); TAOS_TEST_PARA(metric != NULL);
taos_collector_t *default_collector = taos_collector_t *default_collector =
(taos_collector_t *)taos_map_get(TAOS_COLLECTOR_REGISTRY_DEFAULT->collectors, "default"); (taos_collector_t *)taos_map_get(TAOS_COLLECTOR_REGISTRY_DEFAULT->collectors, "default");
@ -126,7 +126,7 @@ int taos_collector_registry_register_metric(taos_metric_t *metric) {
} }
int taos_collector_registry_deregister_metric(const char *key) { int taos_collector_registry_deregister_metric(const char *key) {
TAOS_ASSERT(key != NULL); TAOS_TEST_PARA(key != NULL);
taos_collector_t *default_collector = taos_collector_t *default_collector =
(taos_collector_t *)taos_map_get(TAOS_COLLECTOR_REGISTRY_DEFAULT->collectors, "default"); (taos_collector_t *)taos_map_get(TAOS_COLLECTOR_REGISTRY_DEFAULT->collectors, "default");
@ -139,7 +139,7 @@ int taos_collector_registry_deregister_metric(const char *key) {
} }
taos_metric_t *taos_collector_registry_get_metric(char* metric_name){ taos_metric_t *taos_collector_registry_get_metric(char* metric_name){
TAOS_ASSERT_NULL(metric_name != NULL); TAOS_TEST_PARA_NULL(metric_name != NULL);
taos_collector_t *default_collector = taos_collector_t *default_collector =
(taos_collector_t *)taos_map_get(TAOS_COLLECTOR_REGISTRY_DEFAULT->collectors, "default"); (taos_collector_t *)taos_map_get(TAOS_COLLECTOR_REGISTRY_DEFAULT->collectors, "default");
@ -161,7 +161,7 @@ taos_metric_t *taos_collector_registry_must_register_metric(taos_metric_t *metri
} }
int taos_collector_registry_register_collector(taos_collector_registry_t *self, taos_collector_t *collector) { int taos_collector_registry_register_collector(taos_collector_registry_t *self, taos_collector_t *collector) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;

View File

@ -33,7 +33,7 @@ taos_counter_t *taos_counter_new(const char *name, const char *help, size_t labe
} }
int taos_counter_destroy(taos_counter_t *self) { int taos_counter_destroy(taos_counter_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0; if (self == NULL) return 0;
int r = 0; int r = 0;
r = taos_metric_destroy(self); r = taos_metric_destroy(self);
@ -42,7 +42,7 @@ int taos_counter_destroy(taos_counter_t *self) {
} }
int taos_counter_inc(taos_counter_t *self, const char **label_values) { int taos_counter_inc(taos_counter_t *self, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (self->type != TAOS_COUNTER) { if (self->type != TAOS_COUNTER) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
@ -54,7 +54,7 @@ int taos_counter_inc(taos_counter_t *self, const char **label_values) {
} }
int taos_counter_add(taos_counter_t *self, double r_value, const char **label_values) { int taos_counter_add(taos_counter_t *self, double r_value, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (self->type != TAOS_COUNTER) { if (self->type != TAOS_COUNTER) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);

View File

@ -33,7 +33,7 @@ taos_gauge_t *taos_gauge_new(const char *name, const char *help, size_t label_ke
} }
int taos_gauge_destroy(taos_gauge_t *self) { int taos_gauge_destroy(taos_gauge_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
r = taos_metric_destroy(self); r = taos_metric_destroy(self);
self = NULL; self = NULL;
@ -41,7 +41,7 @@ int taos_gauge_destroy(taos_gauge_t *self) {
} }
/* /*
int taos_gauge_inc(taos_gauge_t *self, const char **label_values) { int taos_gauge_inc(taos_gauge_t *self, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (self->type != TAOS_GAUGE) { if (self->type != TAOS_GAUGE) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
@ -53,7 +53,7 @@ int taos_gauge_inc(taos_gauge_t *self, const char **label_values) {
} }
int taos_gauge_dec(taos_gauge_t *self, const char **label_values) { int taos_gauge_dec(taos_gauge_t *self, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (self->type != TAOS_GAUGE) { if (self->type != TAOS_GAUGE) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
@ -65,7 +65,7 @@ int taos_gauge_dec(taos_gauge_t *self, const char **label_values) {
} }
int taos_gauge_add(taos_gauge_t *self, double r_value, const char **label_values) { int taos_gauge_add(taos_gauge_t *self, double r_value, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (self->type != TAOS_GAUGE) { if (self->type != TAOS_GAUGE) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
@ -77,7 +77,7 @@ int taos_gauge_add(taos_gauge_t *self, double r_value, const char **label_values
} }
int taos_gauge_sub(taos_gauge_t *self, double r_value, const char **label_values) { int taos_gauge_sub(taos_gauge_t *self, double r_value, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (self->type != TAOS_GAUGE) { if (self->type != TAOS_GAUGE) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
@ -89,7 +89,7 @@ int taos_gauge_sub(taos_gauge_t *self, double r_value, const char **label_values
} }
*/ */
int taos_gauge_set(taos_gauge_t *self, double r_value, const char **label_values) { int taos_gauge_set(taos_gauge_t *self, double r_value, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (self->type != TAOS_GAUGE) { if (self->type != TAOS_GAUGE) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);

View File

@ -34,7 +34,7 @@ taos_linked_list_t *taos_linked_list_new(void) {
} }
int taos_linked_list_purge(taos_linked_list_t *self) { int taos_linked_list_purge(taos_linked_list_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
taos_linked_list_node_t *node = self->head; taos_linked_list_node_t *node = self->head;
while (node != NULL) { while (node != NULL) {
taos_linked_list_node_t *next = node->next; taos_linked_list_node_t *next = node->next;
@ -56,7 +56,7 @@ int taos_linked_list_purge(taos_linked_list_t *self) {
} }
int taos_linked_list_destroy(taos_linked_list_t *self) { int taos_linked_list_destroy(taos_linked_list_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
int ret = 0; int ret = 0;
@ -68,7 +68,7 @@ int taos_linked_list_destroy(taos_linked_list_t *self) {
} }
void *taos_linked_list_first(taos_linked_list_t *self) { void *taos_linked_list_first(taos_linked_list_t *self) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
if (self->head) { if (self->head) {
return self->head->item; return self->head->item;
} else { } else {
@ -77,7 +77,7 @@ void *taos_linked_list_first(taos_linked_list_t *self) {
} }
void *taos_linked_list_last(taos_linked_list_t *self) { void *taos_linked_list_last(taos_linked_list_t *self) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
if (self->tail) { if (self->tail) {
return self->tail->item; return self->tail->item;
} else { } else {
@ -86,7 +86,7 @@ void *taos_linked_list_last(taos_linked_list_t *self) {
} }
int taos_linked_list_append(taos_linked_list_t *self, void *item) { int taos_linked_list_append(taos_linked_list_t *self, void *item) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
taos_linked_list_node_t *node = (taos_linked_list_node_t *)taos_malloc(sizeof(taos_linked_list_node_t)); taos_linked_list_node_t *node = (taos_linked_list_node_t *)taos_malloc(sizeof(taos_linked_list_node_t));
node->item = item; node->item = item;
@ -102,7 +102,7 @@ int taos_linked_list_append(taos_linked_list_t *self, void *item) {
} }
int taos_linked_list_push(taos_linked_list_t *self, void *item) { int taos_linked_list_push(taos_linked_list_t *self, void *item) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
taos_linked_list_node_t *node = (taos_linked_list_node_t *)taos_malloc(sizeof(taos_linked_list_node_t)); taos_linked_list_node_t *node = (taos_linked_list_node_t *)taos_malloc(sizeof(taos_linked_list_node_t));
node->item = item; node->item = item;
@ -117,7 +117,7 @@ int taos_linked_list_push(taos_linked_list_t *self, void *item) {
/* /*
void *taos_linked_list_pop(taos_linked_list_t *self) { void *taos_linked_list_pop(taos_linked_list_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return NULL; if (self == NULL) return NULL;
taos_linked_list_node_t *node = self->head; taos_linked_list_node_t *node = self->head;
void *item = NULL; void *item = NULL;
@ -143,7 +143,7 @@ void *taos_linked_list_pop(taos_linked_list_t *self) {
*/ */
int taos_linked_list_remove(taos_linked_list_t *self, void *item) { int taos_linked_list_remove(taos_linked_list_t *self, void *item) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
taos_linked_list_node_t *node; taos_linked_list_node_t *node;
taos_linked_list_node_t *prev_node = NULL; taos_linked_list_node_t *prev_node = NULL;
#ifdef TAOS_LOG_ENABLE #ifdef TAOS_LOG_ENABLE
@ -221,7 +221,7 @@ int taos_linked_list_remove(taos_linked_list_t *self, void *item) {
} }
taos_linked_list_compare_t taos_linked_list_compare(taos_linked_list_t *self, void *item_a, void *item_b) { taos_linked_list_compare_t taos_linked_list_compare(taos_linked_list_t *self, void *item_a, void *item_b) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self->compare_fn) { if (self->compare_fn) {
return (*self->compare_fn)(item_a, item_b); return (*self->compare_fn)(item_a, item_b);
} else { } else {
@ -230,18 +230,18 @@ taos_linked_list_compare_t taos_linked_list_compare(taos_linked_list_t *self, vo
} }
size_t taos_linked_list_size(taos_linked_list_t *self) { size_t taos_linked_list_size(taos_linked_list_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
return self->size; return self->size;
} }
int taos_linked_list_set_free_fn(taos_linked_list_t *self, taos_linked_list_free_item_fn free_fn) { int taos_linked_list_set_free_fn(taos_linked_list_t *self, taos_linked_list_free_item_fn free_fn) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
self->free_fn = free_fn; self->free_fn = free_fn;
return 0; return 0;
} }
int taos_linked_list_set_compare_fn(taos_linked_list_t *self, taos_linked_list_compare_item_fn compare_fn) { int taos_linked_list_set_compare_fn(taos_linked_list_t *self, taos_linked_list_compare_item_fn compare_fn) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
self->compare_fn = compare_fn; self->compare_fn = compare_fn;
return 0; return 0;
} }

View File

@ -46,7 +46,7 @@ taos_map_node_t *taos_map_node_new(const char *key, void *value, taos_map_node_f
} }
int taos_map_node_destroy(taos_map_node_t *self) { int taos_map_node_destroy(taos_map_node_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0; if (self == NULL) return 0;
taos_free((void *)self->key); taos_free((void *)self->key);
self->key = NULL; self->key = NULL;
@ -120,7 +120,7 @@ taos_map_t *taos_map_new() {
} }
int taos_map_destroy(taos_map_t *self) { int taos_map_destroy(taos_map_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
int ret = 0; int ret = 0;
@ -199,7 +199,7 @@ static void *taos_map_get_internal(const char *key, size_t *size, size_t *max_si
} }
void *taos_map_get(taos_map_t *self, const char *key) { void *taos_map_get(taos_map_t *self, const char *key) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
int r = 0; int r = 0;
r = pthread_rwlock_wrlock(self->rwlock); r = pthread_rwlock_wrlock(self->rwlock);
if (r) { if (r) {
@ -217,7 +217,7 @@ void *taos_map_get(taos_map_t *self, const char *key) {
} }
void *taos_map_get_withoutlock(taos_map_t *self, const char *key) { void *taos_map_get_withoutlock(taos_map_t *self, const char *key) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
int r = 0; int r = 0;
void *payload = void *payload =
taos_map_get_internal(key, &self->size, &self->max_size, self->keys, self->addrs, self->free_value_fn); taos_map_get_internal(key, &self->size, &self->max_size, self->keys, self->addrs, self->free_value_fn);
@ -255,7 +255,7 @@ static int taos_map_set_internal(const char *key, void *value, size_t *size, siz
} }
int taos_map_ensure_space(taos_map_t *self) { int taos_map_ensure_space(taos_map_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
if (self->size <= self->max_size / 2) { if (self->size <= self->max_size / 2) {
@ -329,7 +329,7 @@ int taos_map_ensure_space(taos_map_t *self) {
} }
int taos_map_set(taos_map_t *self, const char *key, void *value) { int taos_map_set(taos_map_t *self, const char *key, void *value) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
r = pthread_rwlock_wrlock(self->rwlock); r = pthread_rwlock_wrlock(self->rwlock);
if (r) { if (r) {
@ -394,7 +394,7 @@ static int taos_map_delete_internal(const char *key, size_t *size, size_t *max_s
} }
int taos_map_delete(taos_map_t *self, const char *key) { int taos_map_delete(taos_map_t *self, const char *key) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
int ret = 0; int ret = 0;
r = pthread_rwlock_wrlock(self->rwlock); r = pthread_rwlock_wrlock(self->rwlock);
@ -413,12 +413,12 @@ int taos_map_delete(taos_map_t *self, const char *key) {
} }
int taos_map_set_free_value_fn(taos_map_t *self, taos_map_node_free_value_fn free_value_fn) { int taos_map_set_free_value_fn(taos_map_t *self, taos_map_node_free_value_fn free_value_fn) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
self->free_value_fn = free_value_fn; self->free_value_fn = free_value_fn;
return 0; return 0;
} }
size_t taos_map_size(taos_map_t *self) { size_t taos_map_size(taos_map_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
return self->size; return self->size;
} }

View File

@ -89,7 +89,7 @@ taos_metric_t *taos_metric_new(taos_metric_type_t metric_type, const char *name,
} }
int taos_metric_destroy(taos_metric_t *self) { int taos_metric_destroy(taos_metric_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0; if (self == NULL) return 0;
int r = 0; int r = 0;
@ -144,7 +144,7 @@ void taos_metric_free_generic(void *item) {
} }
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) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
int r = 0; int r = 0;
r = pthread_rwlock_wrlock(self->rwlock); r = pthread_rwlock_wrlock(self->rwlock);
if (r) { if (r) {

View File

@ -46,7 +46,7 @@ taos_metric_formatter_t *taos_metric_formatter_new() {
} }
int taos_metric_formatter_destroy(taos_metric_formatter_t *self) { int taos_metric_formatter_destroy(taos_metric_formatter_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0; if (self == NULL) return 0;
int r = 0; int r = 0;
@ -66,7 +66,7 @@ int taos_metric_formatter_destroy(taos_metric_formatter_t *self) {
} }
/* /*
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) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;
@ -87,7 +87,7 @@ int taos_metric_formatter_load_help(taos_metric_formatter_t *self, const char *n
} }
int taos_metric_formatter_load_type(taos_metric_formatter_t *self, const char *name, taos_metric_type_t metric_type) { int taos_metric_formatter_load_type(taos_metric_formatter_t *self, const char *name, taos_metric_type_t metric_type) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;
@ -109,7 +109,7 @@ int taos_metric_formatter_load_type(taos_metric_formatter_t *self, const char *n
*/ */
int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char *name, const char *suffix, int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char *name, const char *suffix,
size_t label_count, const char **label_keys, const char **label_values) { size_t label_count, const char **label_keys, const char **label_values) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;
@ -158,9 +158,9 @@ int taos_metric_formatter_load_l_value(taos_metric_formatter_t *self, const char
return 0; return 0;
} }
/* /*
int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample, int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric_sample_t *sample,
char *ts, char *format) { char *ts, char *format) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;
@ -188,12 +188,12 @@ int taos_metric_formatter_load_sample(taos_metric_formatter_t *self, taos_metric
} }
*/ */
int taos_metric_formatter_clear(taos_metric_formatter_t *self) { int taos_metric_formatter_clear(taos_metric_formatter_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
return taos_string_builder_clear(self->string_builder); return taos_string_builder_clear(self->string_builder);
} }
char *taos_metric_formatter_dump(taos_metric_formatter_t *self) { char *taos_metric_formatter_dump(taos_metric_formatter_t *self) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
int r = 0; int r = 0;
if (self == NULL) return NULL; if (self == NULL) return NULL;
char *data = taos_string_builder_dump(self->string_builder); char *data = taos_string_builder_dump(self->string_builder);
@ -207,7 +207,7 @@ char *taos_metric_formatter_dump(taos_metric_formatter_t *self) {
} }
/* /*
int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format) { int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;
@ -234,7 +234,7 @@ int taos_metric_formatter_load_metric(taos_metric_formatter_t *self, taos_metric
} }
int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts, char *format) { int taos_metric_formatter_load_metrics(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts, char *format) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
for (taos_linked_list_node_t *current_node = collectors->keys->head; current_node != NULL; for (taos_linked_list_node_t *current_node = collectors->keys->head; current_node != NULL;
current_node = current_node->next) { current_node = current_node->next) {

View File

@ -29,7 +29,7 @@
int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_metric_sample_t *sample, int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_metric_sample_t *sample,
char *ts, char *format, char *metricName, int32_t metric_type, char *ts, char *format, char *metricName, int32_t metric_type,
SJson *arrayMetricGroups) { SJson *arrayMetricGroups) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;
@ -129,7 +129,7 @@ int taos_metric_formatter_load_sample_new(taos_metric_formatter_t *self, taos_me
int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format, int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_metric_t *metric, char *ts, char *format,
SJson* tableArray) { SJson* tableArray) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
int r = 0; int r = 0;
@ -195,7 +195,7 @@ int taos_metric_formatter_load_metric_new(taos_metric_formatter_t *self, taos_me
int taos_metric_formatter_load_metrics_new(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts, int taos_metric_formatter_load_metrics_new(taos_metric_formatter_t *self, taos_map_t *collectors, char *ts,
char *format, SJson* tableArray) { char *format, SJson* tableArray) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
for (taos_linked_list_node_t *current_node = collectors->keys->head; current_node != NULL; for (taos_linked_list_node_t *current_node = collectors->keys->head; current_node != NULL;

View File

@ -43,7 +43,7 @@ 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_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0; 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;
@ -67,7 +67,7 @@ void taos_metric_sample_free_generic(void *gen) {
} }
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) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (r_value < 0) { if (r_value < 0) {
return 1; return 1;
} }
@ -94,14 +94,14 @@ int taos_metric_sample_add(taos_metric_sample_t *self, double r_value) {
/* /*
int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) { int taos_metric_sample_sub(taos_metric_sample_t *self, double r_value) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self->type != TAOS_GAUGE) { if (self->type != TAOS_GAUGE) {
TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE); TAOS_LOG(TAOS_METRIC_INCORRECT_TYPE);
return 1; return 1;
} }
#ifdef C11_ATOMIC #ifdef C11_ATOMIC
///_Atomic/ ///_Atomic/
double old = atomic_load(&self->r_value); double old = atomic_load(&self->r_value);
for (;;) { for (;;) {
_Atomic double new = ATOMIC_VAR_INIT(old - r_value); _Atomic double new = ATOMIC_VAR_INIT(old - r_value);

View File

@ -52,7 +52,7 @@ taos_string_builder_t *taos_string_builder_new(void) {
} }
int taos_string_builder_init(taos_string_builder_t *self) { int taos_string_builder_init(taos_string_builder_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
self->str = (char *)taos_malloc(self->init_size); self->str = (char *)taos_malloc(self->init_size);
*self->str = '\0'; *self->str = '\0';
@ -62,7 +62,7 @@ int taos_string_builder_init(taos_string_builder_t *self) {
} }
int taos_string_builder_destroy(taos_string_builder_t *self) { int taos_string_builder_destroy(taos_string_builder_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 0; if (self == NULL) return 0;
taos_free(self->str); taos_free(self->str);
self->str = NULL; self->str = NULL;
@ -78,7 +78,7 @@ int taos_string_builder_destroy(taos_string_builder_t *self) {
* is called in methods that need to add one or more characters to the underlying string. * is called in methods that need to add one or more characters to the underlying string.
*/ */
static int taos_string_builder_ensure_space(taos_string_builder_t *self, size_t add_len) { static int taos_string_builder_ensure_space(taos_string_builder_t *self, size_t add_len) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (add_len == 0 || self->allocated >= self->len + add_len + 1) return 0; if (add_len == 0 || self->allocated >= self->len + add_len + 1) return 0;
while (self->allocated < self->len + add_len + 1) self->allocated <<= 1; while (self->allocated < self->len + add_len + 1) self->allocated <<= 1;
@ -87,7 +87,7 @@ static int taos_string_builder_ensure_space(taos_string_builder_t *self, size_t
} }
int taos_string_builder_add_str(taos_string_builder_t *self, const char *str) { int taos_string_builder_add_str(taos_string_builder_t *self, const char *str) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
if (self == NULL) return 1; if (self == NULL) return 1;
@ -104,7 +104,7 @@ int taos_string_builder_add_str(taos_string_builder_t *self, const char *str) {
} }
int taos_string_builder_add_char(taos_string_builder_t *self, char c) { int taos_string_builder_add_char(taos_string_builder_t *self, char c) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
int r = 0; int r = 0;
if (self == NULL) return 1; if (self == NULL) return 1;
@ -118,7 +118,7 @@ int taos_string_builder_add_char(taos_string_builder_t *self, char c) {
} }
int taos_string_builder_truncate(taos_string_builder_t *self, size_t len) { int taos_string_builder_truncate(taos_string_builder_t *self, size_t len) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
if (self == NULL) return 1; if (self == NULL) return 1;
if (len >= self->len) return 0; if (len >= self->len) return 0;
@ -128,19 +128,19 @@ int taos_string_builder_truncate(taos_string_builder_t *self, size_t len) {
} }
int taos_string_builder_clear(taos_string_builder_t *self) { int taos_string_builder_clear(taos_string_builder_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
taos_free(self->str); taos_free(self->str);
self->str = NULL; self->str = NULL;
return taos_string_builder_init(self); return taos_string_builder_init(self);
} }
size_t taos_string_builder_len(taos_string_builder_t *self) { size_t taos_string_builder_len(taos_string_builder_t *self) {
TAOS_ASSERT(self != NULL); TAOS_TEST_PARA(self != NULL);
return self->len; return self->len;
} }
char *taos_string_builder_dump(taos_string_builder_t *self) { char *taos_string_builder_dump(taos_string_builder_t *self) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
// +1 to accommodate \0 // +1 to accommodate \0
char *out = (char *)taos_malloc((self->len + 1) * sizeof(char)); char *out = (char *)taos_malloc((self->len + 1) * sizeof(char));
memcpy(out, self->str, self->len + 1); memcpy(out, self->str, self->len + 1);
@ -148,6 +148,6 @@ char *taos_string_builder_dump(taos_string_builder_t *self) {
} }
char *taos_string_builder_str(taos_string_builder_t *self) { char *taos_string_builder_str(taos_string_builder_t *self) {
TAOS_ASSERT_NULL(self != NULL); TAOS_TEST_PARA_NULL(self != NULL);
return self->str; return self->str;
} }