diff options
author | Amar Tumballi <amarts@redhat.com> | 2019-04-12 07:55:04 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2019-05-06 13:57:44 +0000 |
commit | db9c31fcf57024abfdc7b35825409166f17d5aac (patch) | |
tree | 85a51adf6ec9289599475fb8d01a7badd46c8d91 /libglusterfs | |
parent | e0dadeb3242a10827c6142f609c87d860b3ce546 (diff) |
tests: validate volfile grammar - strings in volfile
* libglusterfs/graph-print: remove unused code
updates: bz#1693692
Change-Id: Iae81bb6a3af5911c3da07ab8f1d8f58f27e06905
Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/glusterfs/graph-utils.h | 4 | ||||
-rw-r--r-- | libglusterfs/src/graph-print.c | 59 | ||||
-rw-r--r-- | libglusterfs/src/graph.l | 38 | ||||
-rw-r--r-- | libglusterfs/src/graph.y | 1 |
4 files changed, 17 insertions, 85 deletions
diff --git a/libglusterfs/src/glusterfs/graph-utils.h b/libglusterfs/src/glusterfs/graph-utils.h index c0e87268c5c..247f1a55d5a 100644 --- a/libglusterfs/src/glusterfs/graph-utils.h +++ b/libglusterfs/src/glusterfs/graph-utils.h @@ -13,10 +13,6 @@ int glusterfs_graph_print_file(FILE *file, glusterfs_graph_t *graph); - -char * -glusterfs_graph_print_buf(glusterfs_graph_t *graph); - int glusterfs_xlator_link(xlator_t *pxl, xlator_t *cxl); void diff --git a/libglusterfs/src/graph-print.c b/libglusterfs/src/graph-print.c index 6531308c659..595d74330a1 100644 --- a/libglusterfs/src/graph-print.c +++ b/libglusterfs/src/graph-print.c @@ -36,25 +36,6 @@ gp_write_file(struct gf_printer *gp, char *buf, size_t len) return len; } -static ssize_t -gp_write_buf(struct gf_printer *gp, char *buf, size_t len) -{ - struct iovec *iov = gp->priv; - - if (iov->iov_len < len) { - gf_msg("graph-print", GF_LOG_ERROR, 0, LG_MSG_BUFFER_FULL, - "buffer full"); - - return -1; - } - - memcpy(iov->iov_base, buf, len); - iov->iov_base += len; - iov->iov_len -= len; - - return len; -} - static int gpprintf(struct gf_printer *gp, const char *format, ...) { @@ -152,43 +133,3 @@ glusterfs_graph_print_file(FILE *file, glusterfs_graph_t *graph) return glusterfs_graph_print(&gp, graph); } - -char * -glusterfs_graph_print_buf(glusterfs_graph_t *graph) -{ - FILE *f = NULL; - struct iovec iov = { - 0, - }; - int len = 0; - char *buf = NULL; - struct gf_printer gp = {.write = gp_write_buf, .priv = &iov}; - - f = fopen("/dev/null", "a"); - if (!f) { - gf_msg("graph-print", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, - "cannot open /dev/null"); - - return NULL; - } - len = glusterfs_graph_print_file(f, graph); - fclose(f); - if (len == -1) - return NULL; - - buf = GF_CALLOC(1, len + 1, gf_common_mt_graph_buf); - if (!buf) { - return NULL; - } - iov.iov_base = buf; - iov.iov_len = len; - - len = glusterfs_graph_print(&gp, graph); - if (len == -1) { - GF_FREE(buf); - - return NULL; - } - - return buf; -} diff --git a/libglusterfs/src/graph.l b/libglusterfs/src/graph.l index 4447191ac73..b9d4b2b6828 100644 --- a/libglusterfs/src/graph.l +++ b/libglusterfs/src/graph.l @@ -17,32 +17,24 @@ #include "glusterfs/xlator.h" #include "y.tab.h" #include <string.h> -#define START_STRSIZE 32 static char *text; -static int text_asize; static int text_size; void append_string(const char *str, int size) { - int new_size = text_size + size + 1; - if (new_size > text_asize) { - new_size += START_STRSIZE - 1; - new_size &= -START_STRSIZE; - if (!text) { - text = GF_CALLOC (1, new_size, - gf_common_mt_char); - } else { - text = GF_REALLOC (text, new_size); - } - if (!text) { - return; - } - text_asize = new_size; - } - memcpy(text + text_size, str, size); - text_size += size; - text[text_size] = 0; + int new_size = text_size + size + 1; + if (!text) { + text = GF_CALLOC (1, new_size, gf_common_mt_char); + } else { + text = GF_REALLOC (text, new_size); + } + if (!text) { + return; + } + memcpy(text + text_size, str, size); + text_size += size; + text[text_size] = 0; } %} @@ -65,12 +57,14 @@ TYPE [t][y][p][e] \\. { append_string (yytext + 1, yyleng - 1); } \" { if (0) { - yyunput (0, NULL); + yyunput (0, NULL); } BEGIN (INITIAL); graphyylval = text; + text = NULL; + text_size = 0; return STRING_TOK; - } + } } [^ \t\r\n\"\\]+ { graphyylval = gf_strdup (yytext) ; return ID; } [ \t\r\n]+ ; diff --git a/libglusterfs/src/graph.y b/libglusterfs/src/graph.y index c60ff388b2a..56cab044266 100644 --- a/libglusterfs/src/graph.y +++ b/libglusterfs/src/graph.y @@ -164,6 +164,7 @@ new_volume (char *name) goto out; } + INIT_LIST_HEAD(&curr->volume_options); curr->options = dict_new (); if (!curr->options) { |