mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Fix get_config_uint64() to read a 64-bit value not a 32-bit one.
This commit is contained in:
parent
7c03887b7a
commit
19eb95f72f
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.25 -
|
Version 2.02.25 -
|
||||||
=================================
|
=================================
|
||||||
|
Fix get_config_uint64() to read a 64-bit value not a 32-bit one.
|
||||||
Add -Wformat-security and change one fprintf() to fputs().
|
Add -Wformat-security and change one fprintf() to fputs().
|
||||||
Move regex functions into libdevmapper.
|
Move regex functions into libdevmapper.
|
||||||
Change some #include lines to search only standard system directories.
|
Change some #include lines to search only standard system directories.
|
||||||
|
@ -357,7 +357,7 @@ static void _write_value(FILE *fp, struct config_value *v)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CFG_INT:
|
case CFG_INT:
|
||||||
fprintf(fp, "%d", v->v.i);
|
fprintf(fp, "%" PRId64, v->v.i);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CFG_EMPTY_ARRAY:
|
case CFG_EMPTY_ARRAY:
|
||||||
@ -568,7 +568,7 @@ static struct config_value *_type(struct parser *p)
|
|||||||
switch (p->t) {
|
switch (p->t) {
|
||||||
case TOK_INT:
|
case TOK_INT:
|
||||||
v->type = CFG_INT;
|
v->type = CFG_INT;
|
||||||
v->v.i = strtol(p->tb, NULL, 0); /* FIXME: check error */
|
v->v.i = strtoll(p->tb, NULL, 0); /* FIXME: check error */
|
||||||
match(TOK_INT);
|
match(TOK_INT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -871,25 +871,26 @@ const char *find_config_str(const struct config_node *cn,
|
|||||||
return _find_config_str(cn, NULL, path, fail);
|
return _find_config_str(cn, NULL, path, fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _find_config_int(const struct config_node *cn1,
|
static int64_t _find_config_int64(const struct config_node *cn1,
|
||||||
const struct config_node *cn2,
|
const struct config_node *cn2,
|
||||||
const char *path, int fail)
|
const char *path, int64_t fail)
|
||||||
{
|
{
|
||||||
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
|
const struct config_node *n = _find_first_config_node(cn1, cn2, path);
|
||||||
|
|
||||||
if (n && n->v && n->v->type == CFG_INT) {
|
if (n && n->v && n->v->type == CFG_INT) {
|
||||||
log_very_verbose("Setting %s to %d", path, n->v->v.i);
|
log_very_verbose("Setting %s to %" PRId64, path, n->v->v.i);
|
||||||
return n->v->v.i;
|
return n->v->v.i;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_very_verbose("%s not found in config: defaulting to %d",
|
log_very_verbose("%s not found in config: defaulting to %" PRId64,
|
||||||
path, fail);
|
path, fail);
|
||||||
return fail;
|
return fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
int find_config_int(const struct config_node *cn, const char *path, int fail)
|
int find_config_int(const struct config_node *cn, const char *path, int fail)
|
||||||
{
|
{
|
||||||
return _find_config_int(cn, NULL, path, fail);
|
/* FIXME Add log_error message on overflow */
|
||||||
|
return (int) _find_config_int64(cn, NULL, path, (int64_t) fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float _find_config_float(const struct config_node *cn1,
|
static float _find_config_float(const struct config_node *cn1,
|
||||||
@ -931,7 +932,8 @@ const char *find_config_tree_str(struct cmd_context *cmd,
|
|||||||
int find_config_tree_int(struct cmd_context *cmd, const char *path,
|
int find_config_tree_int(struct cmd_context *cmd, const char *path,
|
||||||
int fail)
|
int fail)
|
||||||
{
|
{
|
||||||
return _find_config_int(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, fail);
|
/* FIXME Add log_error message on overflow */
|
||||||
|
return (int) _find_config_int64(cmd->cft_override ? cmd->cft_override->root : NULL, cmd->cft->root, path, (int64_t) fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
float find_config_tree_float(struct cmd_context *cmd, const char *path,
|
float find_config_tree_float(struct cmd_context *cmd, const char *path,
|
||||||
@ -1023,7 +1025,6 @@ int get_config_uint64(const struct config_node *cn, const char *path,
|
|||||||
if (!n || !n->v || n->v->type != CFG_INT)
|
if (!n || !n->v || n->v->type != CFG_INT)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* FIXME Support 64-bit value! */
|
|
||||||
*result = (uint64_t) n->v->v.i;
|
*result = (uint64_t) n->v->v.i;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ enum {
|
|||||||
struct config_value {
|
struct config_value {
|
||||||
int type;
|
int type;
|
||||||
union {
|
union {
|
||||||
int i;
|
int64_t i;
|
||||||
float r;
|
float r;
|
||||||
char *str;
|
char *str;
|
||||||
} v;
|
} v;
|
||||||
|
Loading…
Reference in New Issue
Block a user