* [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix
@ 2013-09-21 15:51 Wei Liu
2013-09-25 13:36 ` Ian Campbell
2013-10-11 11:35 ` Ian Jackson
0 siblings, 2 replies; 5+ messages in thread
From: Wei Liu @ 2013-09-21 15:51 UTC (permalink / raw)
To: xen-devel; +Cc: Ian Jackson, Wei Liu, Ian Campbell
Modify lexer to special-case memory size string. Introduce
xlu_cfg_get_memsize to parse memroy size strings.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
tools/libxl/libxlu_cfg.c | 46 ++++++++++++
tools/libxl/libxlu_cfg_l.c | 176 ++++++++++++++++++++++++--------------------
tools/libxl/libxlu_cfg_l.h | 8 +-
tools/libxl/libxlu_cfg_l.l | 4 +
tools/libxl/libxlutil.h | 2 +
tools/libxl/xl_cmdimpl.c | 8 +-
6 files changed, 158 insertions(+), 86 deletions(-)
diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c
index 22adcb0..4f53418 100644
--- a/tools/libxl/libxlu_cfg.c
+++ b/tools/libxl/libxlu_cfg.c
@@ -237,6 +237,52 @@ int xlu_cfg_get_long(const XLU_Config *cfg, const char *n,
return 0;
}
+int xlu_cfg_get_memsize(const XLU_Config *cfg, const char *n,
+ long *value_r, int dont_warn) {
+ long l;
+ XLU_ConfigSetting *set;
+ int e;
+ char *ep;
+
+ e= find_atom(cfg,n,&set,dont_warn); if (e) return e;
+ errno= 0; l= strtol(set->values[0], &ep, 0);
+ e= errno;
+ if (errno) {
+ e= errno;
+ assert(e==EINVAL || e==ERANGE);
+ if (!dont_warn)
+ fprintf(cfg->report,
+ "%s:%d: warning: parameter `%s' could not be parsed"
+ " as memory size: %s\n",
+ cfg->config_source, set->lineno, n, strerror(e));
+ return e;
+ }
+ if ((*ep!='M' && *ep!='m' && *ep!='G' && *ep!='g') ||
+ ep==set->values[0]) {
+ if (!dont_warn)
+ fprintf(cfg->report,
+ "%s:%d: warning: parameter `%s' is not a valid"
+ " memory size *ep=%c\n",
+ cfg->config_source, set->lineno, n, *ep);
+ return EINVAL;
+ }
+
+ /* Nothing to do if the suffix is [Mm]. */
+
+ if (*ep=='G' || *ep=='g') {
+ if (l >= INT_MAX / 1024 && !dont_warn) {
+ fprintf(cfg->report,
+ "%s:%d: warning: parameter `%s' overflows\n",
+ cfg->config_source, set->lineno, n);
+ return ERANGE;
+ } else
+ l*= 1024;
+ }
+
+ *value_r= l;
+ return 0;
+}
+
int xlu_cfg_get_defbool(const XLU_Config *cfg, const char *n, libxl_defbool *b,
int dont_warn)
{
diff --git a/tools/libxl/libxlu_cfg_l.c b/tools/libxl/libxlu_cfg_l.c
index df352aa..191b816 100644
--- a/tools/libxl/libxlu_cfg_l.c
+++ b/tools/libxl/libxlu_cfg_l.c
@@ -370,8 +370,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 16
-#define YY_END_OF_BUFFER 17
+#define YY_NUM_RULES 17
+#define YY_END_OF_BUFFER 18
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -379,12 +379,12 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[35] =
+static yyconst flex_int16_t yy_accept[36] =
{ 0,
- 0, 0, 14, 14, 17, 13, 3, 9, 13, 13,
- 13, 12, 4, 2, 8, 7, 5, 6, 1, 14,
- 14, 15, 0, 11, 0, 0, 9, 0, 10, 0,
- 2, 1, 14, 0
+ 0, 0, 15, 15, 18, 14, 4, 10, 14, 14,
+ 14, 13, 5, 2, 9, 8, 6, 7, 1, 15,
+ 15, 16, 0, 12, 0, 0, 10, 0, 11, 0,
+ 2, 3, 1, 15, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -396,13 +396,13 @@ static yyconst flex_int32_t yy_ec[256] =
7, 1, 7, 8, 7, 9, 1, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 7, 11, 1,
12, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 13, 1, 1, 1, 1, 1, 13, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 13, 14, 15, 1, 16, 1, 17, 17, 17, 17,
+ 14, 15, 16, 1, 17, 1, 18, 18, 18, 18,
- 17, 17, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 17,
- 18, 18, 1, 1, 1, 1, 1, 1, 1, 1,
+ 18, 18, 19, 20, 20, 20, 20, 20, 19, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 18,
+ 20, 20, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -419,56 +419,60 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst flex_int32_t yy_meta[19] =
+static yyconst flex_int32_t yy_meta[21] =
{ 0,
1, 2, 3, 1, 1, 1, 1, 1, 4, 4,
- 1, 1, 1, 1, 1, 4, 4, 4
+ 1, 1, 1, 1, 1, 1, 4, 4, 4, 4
} ;
-static yyconst flex_int16_t yy_base[41] =
+static yyconst flex_int16_t yy_base[42] =
{ 0,
- 0, 0, 17, 19, 44, 58, 58, 58, 19, 28,
- 18, 58, 58, 17, 58, 58, 58, 58, 0, 0,
- 58, 58, 21, 58, 0, 26, 58, 22, 58, 0,
- 20, 0, 0, 58, 37, 41, 45, 49, 22, 53
+ 0, 0, 19, 21, 32, 67, 67, 67, 21, 28,
+ 20, 67, 67, 27, 67, 67, 67, 67, 0, 0,
+ 67, 67, 23, 67, 0, 26, 67, 24, 67, 0,
+ 0, 67, 0, 0, 67, 46, 50, 54, 58, 24,
+ 62
} ;
-static yyconst flex_int16_t yy_def[41] =
+static yyconst flex_int16_t yy_def[42] =
{ 0,
- 34, 1, 35, 35, 34, 34, 34, 34, 36, 37,
- 38, 34, 34, 34, 34, 34, 34, 34, 39, 40,
- 34, 34, 36, 34, 36, 37, 34, 38, 34, 38,
- 34, 39, 40, 0, 34, 34, 34, 34, 34, 34
+ 35, 1, 36, 36, 35, 35, 35, 35, 37, 38,
+ 39, 35, 35, 35, 35, 35, 35, 35, 40, 41,
+ 35, 35, 37, 35, 37, 38, 35, 39, 35, 39,
+ 14, 35, 40, 41, 0, 35, 35, 35, 35, 35,
+ 35
} ;
-static yyconst flex_int16_t yy_nxt[77] =
+static yyconst flex_int16_t yy_nxt[88] =
{ 0,
6, 7, 8, 9, 10, 11, 12, 13, 12, 14,
- 15, 16, 17, 6, 18, 6, 19, 19, 21, 22,
- 21, 22, 24, 29, 24, 32, 31, 29, 27, 31,
- 27, 30, 25, 31, 25, 30, 31, 20, 20, 20,
- 20, 23, 23, 34, 23, 26, 26, 26, 26, 28,
- 28, 34, 28, 33, 34, 34, 33, 5, 34, 34,
- 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
- 34, 34, 34, 34, 34, 34
+ 15, 16, 6, 17, 6, 18, 6, 19, 19, 19,
+ 21, 22, 21, 22, 24, 29, 24, 33, 27, 29,
+ 27, 35, 35, 35, 30, 25, 31, 25, 30, 32,
+ 35, 35, 35, 35, 31, 32, 20, 20, 20, 20,
+ 23, 23, 35, 23, 26, 26, 26, 26, 28, 28,
+ 35, 28, 34, 35, 35, 34, 5, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35
} ;
-static yyconst flex_int16_t yy_chk[77] =
+static yyconst flex_int16_t yy_chk[88] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 3, 3,
- 4, 4, 9, 11, 23, 39, 14, 28, 26, 31,
- 10, 11, 9, 14, 23, 28, 31, 35, 35, 35,
- 35, 36, 36, 5, 36, 37, 37, 37, 37, 38,
- 38, 0, 38, 40, 0, 0, 40, 34, 34, 34,
- 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
- 34, 34, 34, 34, 34, 34
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 3, 3, 4, 4, 9, 11, 23, 40, 26, 28,
+ 10, 5, 0, 0, 11, 9, 14, 23, 28, 14,
+ 0, 0, 0, 0, 14, 14, 36, 36, 36, 36,
+ 37, 37, 0, 37, 38, 38, 38, 38, 39, 39,
+ 0, 39, 41, 0, 0, 41, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35
} ;
/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[17] =
+static yyconst flex_int32_t yy_rule_can_match_eol[18] =
{ 0,
-0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, };
+0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
@@ -514,7 +518,7 @@ int xlu__cfg_yyget_column(yyscan_t yyscanner);
void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner);
-#line 518 "libxlu_cfg_l.c"
+#line 522 "libxlu_cfg_l.c"
#define INITIAL 0
#define lexerr 1
@@ -610,6 +614,10 @@ int xlu__cfg_yyget_lineno (yyscan_t yyscanner );
void xlu__cfg_yyset_lineno (int line_number ,yyscan_t yyscanner );
+int xlu__cfg_yyget_column (yyscan_t yyscanner );
+
+void xlu__cfg_yyset_column (int column_no ,yyscan_t yyscanner );
+
YYSTYPE * xlu__cfg_yyget_lval (yyscan_t yyscanner );
void xlu__cfg_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
@@ -762,7 +770,7 @@ YY_DECL
#line 53 "libxlu_cfg_l.l"
-#line 766 "libxlu_cfg_l.c"
+#line 774 "libxlu_cfg_l.c"
yylval = yylval_param;
@@ -825,13 +833,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 35 )
+ if ( yy_current_state >= 36 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_current_state != 34 );
+ while ( yy_current_state != 35 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
@@ -881,97 +889,105 @@ YY_RULE_SETUP
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 64 "libxlu_cfg_l.l"
-
+#line 63 "libxlu_cfg_l.l"
+{
+ yylval->string= xlu__cfgl_strdup(ctx,yytext);
+ GOT(STRING);
+ }
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 66 "libxlu_cfg_l.l"
-{ GOT(','); }
+#line 68 "libxlu_cfg_l.l"
+
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 67 "libxlu_cfg_l.l"
-{ GOT('['); }
+#line 70 "libxlu_cfg_l.l"
+{ GOT(','); }
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 68 "libxlu_cfg_l.l"
-{ GOT(']'); }
+#line 71 "libxlu_cfg_l.l"
+{ GOT('['); }
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 69 "libxlu_cfg_l.l"
-{ GOT('='); }
+#line 72 "libxlu_cfg_l.l"
+{ GOT(']'); }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 70 "libxlu_cfg_l.l"
-{ GOT(';'); }
+#line 73 "libxlu_cfg_l.l"
+{ GOT('='); }
YY_BREAK
case 9:
-/* rule 9 can match eol */
YY_RULE_SETUP
-#line 72 "libxlu_cfg_l.l"
-{ yylloc->first_line= yylineno-1; return NEWLINE; }
+#line 74 "libxlu_cfg_l.l"
+{ GOT(';'); }
YY_BREAK
case 10:
+/* rule 10 can match eol */
YY_RULE_SETUP
-#line 74 "libxlu_cfg_l.l"
+#line 76 "libxlu_cfg_l.l"
+{ yylloc->first_line= yylineno-1; return NEWLINE; }
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 78 "libxlu_cfg_l.l"
{
yylval->string= xlu__cfgl_dequote(ctx,yytext);
GOT(STRING);
}
YY_BREAK
-case 11:
+case 12:
YY_RULE_SETUP
-#line 78 "libxlu_cfg_l.l"
+#line 82 "libxlu_cfg_l.l"
{
yylval->string= xlu__cfgl_dequote(ctx,yytext);
GOT(STRING);
}
YY_BREAK
-case 12:
+case 13:
YY_RULE_SETUP
-#line 83 "libxlu_cfg_l.l"
+#line 87 "libxlu_cfg_l.l"
{
ctx->likely_python= 1;
BEGIN(lexerr);
yymore();
}
YY_BREAK
-case 13:
+case 14:
YY_RULE_SETUP
-#line 89 "libxlu_cfg_l.l"
+#line 93 "libxlu_cfg_l.l"
{
BEGIN(lexerr);
yymore();
}
YY_BREAK
-case 14:
+case 15:
YY_RULE_SETUP
-#line 94 "libxlu_cfg_l.l"
+#line 98 "libxlu_cfg_l.l"
{
xlu__cfgl_lexicalerror(ctx,"lexical error");
BEGIN(0);
}
YY_BREAK
-case 15:
-/* rule 15 can match eol */
+case 16:
+/* rule 16 can match eol */
YY_RULE_SETUP
-#line 99 "libxlu_cfg_l.l"
+#line 103 "libxlu_cfg_l.l"
{
xlu__cfgl_lexicalerror(ctx,"lexical error");
BEGIN(0);
GOT(NEWLINE);
}
YY_BREAK
-case 16:
+case 17:
YY_RULE_SETUP
-#line 104 "libxlu_cfg_l.l"
+#line 108 "libxlu_cfg_l.l"
YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK
-#line 975 "libxlu_cfg_l.c"
+#line 991 "libxlu_cfg_l.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(lexerr):
yyterminate();
@@ -1267,7 +1283,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 35 )
+ if ( yy_current_state >= 36 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1296,11 +1312,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 35 )
+ if ( yy_current_state >= 36 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 34);
+ yy_is_jam = (yy_current_state == 35);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -2121,4 +2137,4 @@ void xlu__cfg_yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
-#line 104 "libxlu_cfg_l.l"
+#line 108 "libxlu_cfg_l.l"
diff --git a/tools/libxl/libxlu_cfg_l.h b/tools/libxl/libxlu_cfg_l.h
index 4078302..c104172 100644
--- a/tools/libxl/libxlu_cfg_l.h
+++ b/tools/libxl/libxlu_cfg_l.h
@@ -276,6 +276,10 @@ int xlu__cfg_yyget_lineno (yyscan_t yyscanner );
void xlu__cfg_yyset_lineno (int line_number ,yyscan_t yyscanner );
+int xlu__cfg_yyget_column (yyscan_t yyscanner );
+
+void xlu__cfg_yyset_column (int column_no ,yyscan_t yyscanner );
+
YYSTYPE * xlu__cfg_yyget_lval (yyscan_t yyscanner );
void xlu__cfg_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
@@ -350,8 +354,8 @@ extern int xlu__cfg_yylex \
#undef YY_DECL
#endif
-#line 104 "libxlu_cfg_l.l"
+#line 108 "libxlu_cfg_l.l"
-#line 356 "libxlu_cfg_l.h"
+#line 360 "libxlu_cfg_l.h"
#undef xlu__cfg_yyIN_HEADER
#endif /* xlu__cfg_yyHEADER_H */
diff --git a/tools/libxl/libxlu_cfg_l.l b/tools/libxl/libxlu_cfg_l.l
index e0ea8cf..0b1f299 100644
--- a/tools/libxl/libxlu_cfg_l.l
+++ b/tools/libxl/libxlu_cfg_l.l
@@ -60,6 +60,10 @@ void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner);
yylval->string= xlu__cfgl_strdup(ctx,yytext);
GOT(NUMBER);
}
+[0-9][0-9a-fx]*[MmGg] {
+ yylval->string= xlu__cfgl_strdup(ctx,yytext);
+ GOT(STRING);
+ }
[ \t]
diff --git a/tools/libxl/libxlutil.h b/tools/libxl/libxlutil.h
index 0333e55..7531016 100644
--- a/tools/libxl/libxlutil.h
+++ b/tools/libxl/libxlutil.h
@@ -54,6 +54,8 @@ int xlu_cfg_get_long(const XLU_Config*, const char *n, long *value_r,
int dont_warn);
int xlu_cfg_get_defbool(const XLU_Config*, const char *n, libxl_defbool *b,
int dont_warn);
+int xlu_cfg_get_memsize(const XLU_Config*, const char *n, long *value_r,
+ int dont_warn);
int xlu_cfg_get_list(const XLU_Config*, const char *n,
XLU_ConfigList **list_r /* may be 0 */,
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 3d7eaad..4e53ac5 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -726,12 +726,12 @@ static void parse_config_data(const char *config_source,
libxl_defbool_set(&b_info->numa_placement, false);
}
- if (!xlu_cfg_get_long (config, "memory", &l, 0)) {
+ if (!xlu_cfg_get_memsize (config, "memory", &l, 0)) {
b_info->max_memkb = l * 1024;
b_info->target_memkb = b_info->max_memkb;
}
- if (!xlu_cfg_get_long (config, "maxmem", &l, 0))
+ if (!xlu_cfg_get_memsize (config, "maxmem", &l, 0))
b_info->max_memkb = l * 1024;
libxl_defbool_set(&b_info->claim_mode, claim_mode);
@@ -768,7 +768,7 @@ static void parse_config_data(const char *config_source,
/* libxl_get_required_shadow_memory() must be called after final values
* (default or specified) for vcpus and memory are set, because the
* calculation depends on those values. */
- b_info->shadow_memkb = !xlu_cfg_get_long(config, "shadow_memory", &l, 0)
+ b_info->shadow_memkb = !xlu_cfg_get_memsize(config, "shadow_memory", &l, 0)
? l * 1024
: libxl_get_required_shadow_memory(b_info->max_memkb,
b_info->max_vcpus);
@@ -810,7 +810,7 @@ static void parse_config_data(const char *config_source,
xlu_cfg_get_defbool(config, "localtime", &b_info->localtime, 0);
- if (!xlu_cfg_get_long (config, "videoram", &l, 0))
+ if (!xlu_cfg_get_memsize (config, "videoram", &l, 0))
b_info->video_memkb = l * 1024;
switch(b_info->type) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix
2013-09-21 15:51 [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix Wei Liu
@ 2013-09-25 13:36 ` Ian Campbell
2013-09-25 13:48 ` Wei Liu
2013-10-11 11:35 ` Ian Jackson
1 sibling, 1 reply; 5+ messages in thread
From: Ian Campbell @ 2013-09-25 13:36 UTC (permalink / raw)
To: Wei Liu; +Cc: Ian Jackson, xen-devel
On Sat, 2013-09-21 at 16:51 +0100, Wei Liu wrote:
> diff --git a/tools/libxl/libxlu_cfg_l.l b/tools/libxl/libxlu_cfg_l.l
> index e0ea8cf..0b1f299 100644
> --- a/tools/libxl/libxlu_cfg_l.l
> +++ b/tools/libxl/libxlu_cfg_l.l
This will need Ian J's review when he gets back.
> @@ -60,6 +60,10 @@ void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner);
> yylval->string= xlu__cfgl_strdup(ctx,yytext);
> GOT(NUMBER);
> }
> +[0-9][0-9a-fx]*[MmGg] {
You copied this from above but "[0-9][0-9a-fx]*" looks odd to me. I
think it is intended to accept decimals and hex 0xNNN but it actually
ends up accepting 1111xxxxx99999ddddd and nonsensical things like that,
doesn't it?
I suppose we will reject such things later.
> + yylval->string= xlu__cfgl_strdup(ctx,yytext);
> + GOT(STRING);
This sort of subtle semantic change GOT(NUMBER)=>(STRING) is what needs
Ian's thoughts...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix
2013-09-25 13:36 ` Ian Campbell
@ 2013-09-25 13:48 ` Wei Liu
0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2013-09-25 13:48 UTC (permalink / raw)
To: Ian Campbell; +Cc: Ian Jackson, Wei Liu, xen-devel
On Wed, Sep 25, 2013 at 02:36:04PM +0100, Ian Campbell wrote:
> On Sat, 2013-09-21 at 16:51 +0100, Wei Liu wrote:
> > diff --git a/tools/libxl/libxlu_cfg_l.l b/tools/libxl/libxlu_cfg_l.l
> > index e0ea8cf..0b1f299 100644
> > --- a/tools/libxl/libxlu_cfg_l.l
> > +++ b/tools/libxl/libxlu_cfg_l.l
>
> This will need Ian J's review when he gets back.
>
> > @@ -60,6 +60,10 @@ void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner);
> > yylval->string= xlu__cfgl_strdup(ctx,yytext);
> > GOT(NUMBER);
> > }
> > +[0-9][0-9a-fx]*[MmGg] {
>
> You copied this from above but "[0-9][0-9a-fx]*" looks odd to me. I
> think it is intended to accept decimals and hex 0xNNN but it actually
> ends up accepting 1111xxxxx99999ddddd and nonsensical things like that,
> doesn't it?
>
I had the same impression. However strtol() accepts up to base 36 which
makes 1111xxxxx99999dddd sensible...
> I suppose we will reject such things later.
>
> > + yylval->string= xlu__cfgl_strdup(ctx,yytext);
> > + GOT(STRING);
>
> This sort of subtle semantic change GOT(NUMBER)=>(STRING) is what needs
> Ian's thoughts...
>
Right. I haven't figure out what's the best way to handle this.
Wei.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix
2013-09-21 15:51 [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix Wei Liu
2013-09-25 13:36 ` Ian Campbell
@ 2013-10-11 11:35 ` Ian Jackson
2013-10-21 14:14 ` Wei Liu
1 sibling, 1 reply; 5+ messages in thread
From: Ian Jackson @ 2013-10-11 11:35 UTC (permalink / raw)
To: Wei Liu; +Cc: Ian Campbell, xen-devel
Wei Liu writes ("[PATCH RFC] libxl: support for using 'MmGg' as memory size suffix"):
> Modify lexer to special-case memory size string. Introduce
> xlu_cfg_get_memsize to parse memroy size strings.
Urgh, this is really quite an ugly special case.
Perhaps a better approach might be to just permit unquoted strings
when the string is vaguely like a token, and return the token type
STRING from the lexer in that case.
> + if ((*ep!='M' && *ep!='m' && *ep!='G' && *ep!='g') ||
...
> + if (*ep=='G' || *ep=='g') {
Surely this should be done with switch().
Ian.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix
2013-10-11 11:35 ` Ian Jackson
@ 2013-10-21 14:14 ` Wei Liu
0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2013-10-21 14:14 UTC (permalink / raw)
To: Ian Jackson; +Cc: Wei Liu, Ian Campbell, xen-devel
On Fri, Oct 11, 2013 at 12:35:56PM +0100, Ian Jackson wrote:
> Wei Liu writes ("[PATCH RFC] libxl: support for using 'MmGg' as memory size suffix"):
> > Modify lexer to special-case memory size string. Introduce
> > xlu_cfg_get_memsize to parse memroy size strings.
>
> Urgh, this is really quite an ugly special case.
>
> Perhaps a better approach might be to just permit unquoted strings
> when the string is vaguely like a token, and return the token type
"vaguely" is too vague I'm afraid...
Wei.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-21 14:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-21 15:51 [PATCH RFC] libxl: support for using 'MmGg' as memory size suffix Wei Liu
2013-09-25 13:36 ` Ian Campbell
2013-09-25 13:48 ` Wei Liu
2013-10-11 11:35 ` Ian Jackson
2013-10-21 14:14 ` Wei Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).