mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cleanup: convert set of strncat into a single printf
Use single snprintf for better control of used bufsize, and also increased buffer to 128char to ensure all chars will always fit.
This commit is contained in:
parent
4e1ac7faf1
commit
4eb8db26ac
@ -337,34 +337,22 @@ int config_def_get_path(char *buf, size_t buf_size, int id)
|
|||||||
|
|
||||||
static void _get_type_name(char *buf, size_t buf_size, cfg_def_type_t type)
|
static void _get_type_name(char *buf, size_t buf_size, cfg_def_type_t type)
|
||||||
{
|
{
|
||||||
buf[0] = '\0';
|
(void) dm_snprintf(buf, buf_size, "%s%s%s%s%s%s",
|
||||||
|
(type & CFG_TYPE_ARRAY) ?
|
||||||
if (type & CFG_TYPE_ARRAY) {
|
((type & ~CFG_TYPE_ARRAY) ?
|
||||||
if (type & ~CFG_TYPE_ARRAY)
|
" array with values of type:" : " array") : "",
|
||||||
strncat(buf, " array with values of type:", buf_size);
|
(type & CFG_TYPE_SECTION) ? " section" : "",
|
||||||
else {
|
(type & CFG_TYPE_BOOL) ? " boolean" : "",
|
||||||
strncat(buf, " array", buf_size);
|
(type & CFG_TYPE_INT) ? " integer" : "",
|
||||||
return;
|
(type & CFG_TYPE_FLOAT) ? " float" : "",
|
||||||
}
|
(type & CFG_TYPE_STRING) ? " string" : "");
|
||||||
}
|
|
||||||
|
|
||||||
if (type & CFG_TYPE_SECTION)
|
|
||||||
strncat(buf, " section", buf_size);
|
|
||||||
if (type & CFG_TYPE_BOOL)
|
|
||||||
strncat(buf, " boolean", buf_size);
|
|
||||||
if (type & CFG_TYPE_INT)
|
|
||||||
strncat(buf, " integer", buf_size);
|
|
||||||
if (type & CFG_TYPE_FLOAT)
|
|
||||||
strncat(buf, " float", buf_size);
|
|
||||||
if (type & CFG_TYPE_STRING)
|
|
||||||
strncat(buf, " string", buf_size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _log_type_error(const char *path, cfg_def_type_t actual,
|
static void _log_type_error(const char *path, cfg_def_type_t actual,
|
||||||
cfg_def_type_t expected, int suppress_messages)
|
cfg_def_type_t expected, int suppress_messages)
|
||||||
{
|
{
|
||||||
static char actual_type_name[64];
|
static char actual_type_name[128];
|
||||||
static char expected_type_name[64];
|
static char expected_type_name[128];
|
||||||
|
|
||||||
_get_type_name(actual_type_name, sizeof(actual_type_name), actual);
|
_get_type_name(actual_type_name, sizeof(actual_type_name), actual);
|
||||||
_get_type_name(expected_type_name, sizeof(expected_type_name), expected);
|
_get_type_name(expected_type_name, sizeof(expected_type_name), expected);
|
||||||
|
Loading…
Reference in New Issue
Block a user