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>
int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
{
virCommandPtr cmd = NULL;
+ size_t len;
int ret = -1;
cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5", "--if-exists", "get", "Interface",
}
/* Wipeout the newline, if it exists */
- if (strlen(*migrate) > 0)
- (*migrate)[strlen(*migrate) - 1] = '\0';
+ len = strlen(*migrate);
+ if (len > 0)
+ (*migrate)[len - 1] = '\0';
ret = 0;
cleanup: