From ee4f78bacec4d5a0b0df574a9bc0e549af33cbd7 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 1 Sep 2016 10:41:05 +1000 Subject: [PATCH] ckdb - add a field name for the get_intransient error message --- src/ckdb.c | 8 ++++++-- src/ckdb.h | 14 ++++++++------ src/ckdb_data.c | 17 +++++++++-------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 4e58a238..adde4b43 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -4181,7 +4181,9 @@ static enum cmd_values breakdown(K_ITEM **ml_item, char *buf, tv_t *now, intrans = true; // This will affect 'was' if JSON_END is missing *(next + siz) = '\0'; - transfer->intransient = get_intransient_siz(next, siz+1); + transfer->intransient = + get_intransient_siz(transfer->name, + next, siz+1); transfer->mvalue = transfer->intransient->str; break; } @@ -4244,7 +4246,9 @@ static enum cmd_values breakdown(K_ITEM **ml_item, char *buf, tv_t *now, if (strcmp(transfer->name, intransient_fields[i]) == 0) { intrans = true; - transfer->intransient = get_intransient_siz(eq, siz); + transfer->intransient = + get_intransient_siz(transfer->name, + eq, siz); transfer->mvalue = transfer->intransient->str; break; } diff --git a/src/ckdb.h b/src/ckdb.h index 1136c632..7a34a3d4 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -58,7 +58,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.440" +#define CKDB_VERSION DB_VERSION"-2.441" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -1153,7 +1153,7 @@ typedef struct intransient { } INTRANSIENT; /* Items never to be deleted and list never to be culled - * They are all created by the db load functions and breakdown */ + * They are all created by breakdown */ #define ALLOC_INTRANSIENT 1024 #define LIMIT_INTRANSIENT 0 #define INIT_INTRANSIENT(_item) INIT_GENERIC(_item, intransient) @@ -3111,10 +3111,12 @@ extern char *_hms_to_buf(time_t *data, char *buf, size_t siz, WHERE_FFL_ARGS); extern char *_ms_to_buf(time_t *data, char *buf, size_t siz, WHERE_FFL_ARGS); extern cmp_t cmp_intransient(K_ITEM *a, K_ITEM *b); -#define get_intransient(_name) _get_intransient(_name, 0, WHERE_FFL_HERE) -#define get_intransient_siz(_name, _siz) \ - _get_intransient(_name, _siz, WHERE_FFL_HERE) -extern INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS); +#define get_intransient(_fld, _val) \ + _get_intransient(_fld, _val, 0, WHERE_FFL_HERE) +#define get_intransient_siz(_fld, _val, _siz) \ + _get_intransient(_fld, _val , _siz, WHERE_FFL_HERE) +extern INTRANSIENT *_get_intransient(char *fldnam, char *value, size_t siz, + WHERE_FFL_ARGS); extern char *_transfer_data(K_ITEM *item, WHERE_FFL_ARGS); extern void dsp_transfer(K_ITEM *item, FILE *stream); extern cmp_t cmp_transfer(K_ITEM *a, K_ITEM *b); diff --git a/src/ckdb_data.c b/src/ckdb_data.c index c3531eb1..88e81cd8 100644 --- a/src/ckdb_data.c +++ b/src/ckdb_data.c @@ -715,7 +715,7 @@ cmp_t cmp_intransient(K_ITEM *a, K_ITEM *b) return CMP_STR(ia->str, ib->str); } -INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS) +INTRANSIENT *_get_intransient(char *fldnam, char *value, size_t siz, WHERE_FFL_ARGS) { INTRANSIENT intransient, *in = NULL; K_ITEM look, *i_item, *n_item; @@ -725,18 +725,19 @@ INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS) bool new; if (siz == 0) - siz = strlen(name) + 1; + siz = strlen(value) + 1; if (siz > sizeof(nameram->rem)) { char *st = NULL; - LOGEMERG("%s() ERR '%10s...' discarded - siz %d>%d" WHERE_FFL, - __func__, st = safe_text_nonull(name), (int)siz, - (int)sizeof(nameram->rem), WHERE_FFL_PASS); - name = EMPTY; + LOGEMERG("%s() ERR %s='%10s...' discarded - siz %d>%d" + WHERE_FFL, + __func__, fldnam, st = safe_text_nonull(value), + (int)siz, (int)sizeof(nameram->rem), WHERE_FFL_PASS); + value = EMPTY; siz = 1; } - intransient.str = name; + intransient.str = value; INIT_INTRANSIENT(&look); look.data = (void *)(&intransient); K_RLOCK(intransient_free); @@ -779,7 +780,7 @@ INTRANSIENT *_get_intransient(char *name, size_t siz, WHERE_FFL_ARGS) nameram->next += siz; nameram->left -= siz; K_WUNLOCK(nameram_free); - strcpy(buf, name); + strcpy(buf, value); i_item = k_unlink_head(intransient_free); DATA_INTRANSIENT(in, i_item); in->str = buf;