diff options
| author | chenzizhan <[email protected]> | 2023-08-17 14:50:38 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2023-08-17 14:50:38 +0800 |
| commit | be084b74a2fcedefef7612479d33c99822a2a53e (patch) | |
| tree | 0ff8f3be6c40af7a5ced958006896e7d5dc792d9 /src/fieldstat.c | |
| parent | 07271b245d3c6b3c16467dced67d76cf60da9ed7 (diff) | |
assert null instance firstv4.1.0a
Diffstat (limited to 'src/fieldstat.c')
| -rw-r--r-- | src/fieldstat.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/fieldstat.c b/src/fieldstat.c index 9c450cb..75e34b1 100644 --- a/src/fieldstat.c +++ b/src/fieldstat.c @@ -497,9 +497,6 @@ static struct metric *fieldstat_find_metric(const struct fieldstat *instance, in int fieldstat_general_check(struct fieldstat *instance, int cube_id, int metric_id, int cell_id, enum metric_type metric_type) { - if (instance == NULL) { - return -1; - } if (cube_id < 0 || cube_id >= instance->valid_cube_arr_length) { return -1; } @@ -523,6 +520,10 @@ int fieldstat_general_check(struct fieldstat *instance, int cube_id, int metric_ int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric_id, int cell_id, long long increment) { + if (instance == NULL) { + return -1; + } + pthread_mutex_lock(&(instance->mutex_lock)); int ret = fieldstat_general_check(instance, cube_id, metric_id, cell_id, METRIC_TYPE_COUNTER); @@ -540,6 +541,10 @@ int fieldstat_counter_incrby(struct fieldstat *instance, int cube_id, int metric int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id, int cell_id, long long value) { + if (instance == NULL) { + return -1; + } + pthread_mutex_lock(&(instance->mutex_lock)); int ret = fieldstat_general_check(instance, cube_id, metric_id, cell_id, METRIC_TYPE_COUNTER); @@ -560,6 +565,9 @@ int fieldstat_counter_set(struct fieldstat *instance, int cube_id, int metric_id int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, int cell_id, const char *key, size_t key_len) { + if (instance == NULL) { + return -1; + } pthread_mutex_lock(&(instance->mutex_lock)); int ret = fieldstat_general_check(instance, cube_id, metric_id, cell_id, METRIC_TYPE_HLL); if (ret < 0) { @@ -576,6 +584,9 @@ int fieldstat_hll_add(struct fieldstat *instance, int cube_id, int metric_id, in int fieldstat_hist_record(struct fieldstat *instance, int cube_id, int metric_id, int cell_id, long long value) { + if (instance == NULL) { + return -1; + } pthread_mutex_lock(&(instance->mutex_lock)); int ret = fieldstat_general_check(instance, cube_id, metric_id, cell_id, METRIC_TYPE_HISTOGRAM); |
