mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
command: Skip some memory zeroing.
commands[] is in bss, its content wouldn't change if reinitialised and unregister has no memory to free so don't bother.
This commit is contained in:
parent
e4e2abc8bc
commit
da37cbd24f
@ -1356,13 +1356,11 @@ static void _create_opt_names_alpha(void)
|
|||||||
qsort(opt_names_alpha, ARG_COUNT, sizeof(long), _long_name_compare);
|
qsort(opt_names_alpha, ARG_COUNT, sizeof(long), _long_name_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _copy_line(char *line, int max_line, int *position)
|
static int _copy_line(char *line, int max_line, int *position, int *len)
|
||||||
{
|
{
|
||||||
int p = *position;
|
int p = *position;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
memset(line, 0, max_line);
|
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
line[i] = _command_input[p];
|
line[i] = _command_input[p];
|
||||||
i++;
|
i++;
|
||||||
@ -1376,7 +1374,9 @@ static int _copy_line(char *line, int max_line, int *position)
|
|||||||
if (i == (max_line - 1))
|
if (i == (max_line - 1))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
line[i] = '\0';
|
||||||
*position = p;
|
*position = p;
|
||||||
|
*len = i + 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1394,6 +1394,7 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
|
|||||||
int prev_was_oo = 0;
|
int prev_was_oo = 0;
|
||||||
int prev_was_op = 0;
|
int prev_was_op = 0;
|
||||||
int copy_pos = 0;
|
int copy_pos = 0;
|
||||||
|
int copy_len = 0;
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1404,14 +1405,14 @@ int define_commands(struct cmd_context *cmdtool, const char *run_name)
|
|||||||
|
|
||||||
/* Process each line of command-lines-input.h (from command-lines.in) */
|
/* Process each line of command-lines-input.h (from command-lines.in) */
|
||||||
|
|
||||||
while (_copy_line(line, MAX_LINE, ©_pos)) {
|
while (_copy_line(line, MAX_LINE, ©_pos, ©_len)) {
|
||||||
if (line[0] == '\n')
|
if (line[0] == '\n')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ((n = strchr(line, '\n')))
|
if ((n = strchr(line, '\n')))
|
||||||
*n = '\0';
|
*n = '\0';
|
||||||
|
|
||||||
memcpy(line_orig, line, sizeof(line));
|
memcpy(line_orig, line, copy_len);
|
||||||
_split_line(line, &line_argc, line_argv, ' ');
|
_split_line(line, &line_argc, line_argv, ' ');
|
||||||
|
|
||||||
if (!line_argc)
|
if (!line_argc)
|
||||||
|
@ -1262,15 +1262,6 @@ static const struct command_function *_find_command_id_function(int command_enum
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _unregister_commands(void)
|
|
||||||
{
|
|
||||||
_cmdline.commands = NULL;
|
|
||||||
_cmdline.num_commands = 0;
|
|
||||||
_cmdline.command_names = NULL;
|
|
||||||
_cmdline.num_command_names = 0;
|
|
||||||
memset(&commands, 0, sizeof(commands));
|
|
||||||
}
|
|
||||||
|
|
||||||
int lvm_register_commands(struct cmd_context *cmd, const char *run_name)
|
int lvm_register_commands(struct cmd_context *cmd, const char *run_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1279,8 +1270,6 @@ int lvm_register_commands(struct cmd_context *cmd, const char *run_name)
|
|||||||
if (_cmdline.commands)
|
if (_cmdline.commands)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
memset(&commands, 0, sizeof(commands));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* populate commands[] array with command definitions
|
* populate commands[] array with command definitions
|
||||||
* by parsing command-lines.in/command-lines-input.h
|
* by parsing command-lines.in/command-lines-input.h
|
||||||
@ -3335,7 +3324,6 @@ struct cmd_context *init_lvm(unsigned set_connections, unsigned set_filters)
|
|||||||
|
|
||||||
void lvm_fin(struct cmd_context *cmd)
|
void lvm_fin(struct cmd_context *cmd)
|
||||||
{
|
{
|
||||||
_unregister_commands();
|
|
||||||
destroy_toolcontext(cmd);
|
destroy_toolcontext(cmd);
|
||||||
udev_fin_library_context();
|
udev_fin_library_context();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user