mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-05 12:35:20 +00:00
virnetdevopenvswitch: Don't call strlen() twice on the same string
Commit 871e10f
fixed a memory corruption error, but called strlen()
twice on the same string to do so. Even though the compiler is
probably smart enough to optimize the second call away, having a
single invocation makes the code slightly cleaner.
Suggested-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
720bc953f8
commit
d87f0c0052
@ -207,6 +207,7 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch
|
|||||||
int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
|
int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
|
||||||
{
|
{
|
||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
|
size_t len;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5", "--if-exists", "get", "Interface",
|
cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5", "--if-exists", "get", "Interface",
|
||||||
@ -223,8 +224,9 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Wipeout the newline, if it exists */
|
/* Wipeout the newline, if it exists */
|
||||||
if (strlen(*migrate) > 0)
|
len = strlen(*migrate);
|
||||||
(*migrate)[strlen(*migrate) - 1] = '\0';
|
if (len > 0)
|
||||||
|
(*migrate)[len - 1] = '\0';
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user