Skip to content

Commit

Permalink
virnetdev: Make virNetDevGenerateName() return 1 if no name was gener…
Browse files Browse the repository at this point in the history
…ated

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@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
  • Loading branch information
zippy2 committed Dec 9, 2022
1 parent 8a5a4e6 commit 6cbbc71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/util/virnetdev.c
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6cbbc71

Please sign in to comment.