A caller might be interested in the case when @ifname was already
set and it wasn't a template. In such case the
virNetDevGenerateName() does not touch the @ifname at all and
returns 0 to indicate success. Make it return 1 to distinguish
this case from the other case, in which a new name was generated.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virnetdev.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 66cfc5d781..82dbb486f2 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3595,7 +3595,9 @@ virNetDevReserveName(const char *name)
* Note: if string pointed by @ifname is NOT a template or NULL, leave
* it unchanged and return it directly.
*
- * Returns 0 on success, -1 on failure.
+ * Returns: 1 if @ifname already contains a valid name,
+ * 0 on success (@ifname was generated),
+ * -1 on failure.
*/
int
virNetDevGenerateName(char **ifname, virNetDevGenNameType type)
@@ -3609,7 +3611,7 @@ virNetDevGenerateName(char **ifname, virNetDevGenNameType type)
if (*ifname &&
(strchr(*ifname, '%') != strrchr(*ifname, '%') ||
strstr(*ifname, "%d") == NULL)) {
- return 0;
+ return 1;
}
if (maxIDd <= (double)INT_MAX)
--
2.37.4