mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
cleanup: dmeventd simplify restart message parsing
Since we already check every characted in the message, skip extra callback to strlen, and do the implicit message length checking.
This commit is contained in:
parent
1f701c7bf6
commit
7a1777302f
@ -1918,7 +1918,6 @@ static void restart(void)
|
|||||||
struct dm_event_daemon_message msg = { 0 };
|
struct dm_event_daemon_message msg = { 0 };
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
char *message;
|
char *message;
|
||||||
int length;
|
|
||||||
int version;
|
int version;
|
||||||
const char *e;
|
const char *e;
|
||||||
|
|
||||||
@ -1943,16 +1942,12 @@ static void restart(void)
|
|||||||
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0))
|
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0))
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
message = msg.data;
|
message = strchr(msg.data, ' ') + 1;
|
||||||
message = strchr(message, ' ');
|
for (i = 0; msg.data[i]; ++i)
|
||||||
++ message;
|
|
||||||
length = strlen(msg.data);
|
|
||||||
for (i = 0; i < length; ++i) {
|
|
||||||
if (msg.data[i] == ';') {
|
if (msg.data[i] == ';') {
|
||||||
msg.data[i] = 0;
|
msg.data[i] = 0;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!(_initial_registrations = dm_malloc(sizeof(char*) * (count + 1)))) {
|
if (!(_initial_registrations = dm_malloc(sizeof(char*) * (count + 1)))) {
|
||||||
fprintf(stderr, "Memory allocation registration failed.\n");
|
fprintf(stderr, "Memory allocation registration failed.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user