mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
cleanup: simplify pv name size estimation
Reuse buffer with size of 2 * PATH_MAX to handle worst case escape and avoid extra calculation of espaced len.
This commit is contained in:
parent
3fda296da6
commit
0499e87ace
@ -450,8 +450,7 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
|||||||
{
|
{
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
char buffer[4096];
|
char buffer[PATH_MAX * 2];
|
||||||
char *buf;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
outf(f, "physical_volumes {");
|
outf(f, "physical_volumes {");
|
||||||
@ -472,14 +471,13 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
|||||||
|
|
||||||
outf(f, "id = \"%s\"", buffer);
|
outf(f, "id = \"%s\"", buffer);
|
||||||
|
|
||||||
if (!(buf = alloca(dm_escaped_len(pv_dev_name(pv))))) {
|
if (strlen(pv_dev_name(pv)) >= PATH_MAX) {
|
||||||
log_error("temporary stack allocation for device name"
|
log_error("pv device name size is out of bounds.");
|
||||||
"string failed");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
outhint(f, "device = \"%s\"",
|
outhint(f, "device = \"%s\"",
|
||||||
dm_escape_double_quotes(buf, pv_dev_name(pv)));
|
dm_escape_double_quotes(buffer, pv_dev_name(pv)));
|
||||||
outnl(f);
|
outnl(f);
|
||||||
|
|
||||||
if (!_print_flag_config(f, pv->status, PV_FLAGS))
|
if (!_print_flag_config(f, pv->status, PV_FLAGS))
|
||||||
|
Loading…
Reference in New Issue
Block a user