Skip to content

Commit

Permalink
[nozzle] cleanup and document nozzle_get_fd
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Nov 28, 2017
1 parent fc58f3d commit 924ddde
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
17 changes: 13 additions & 4 deletions libnozzle/libnozzle.c
Expand Up @@ -1185,12 +1185,21 @@ int nozzle_del_ip(nozzle_t nozzle, const char *ip_addr, const char *prefix, char

int nozzle_get_fd(const nozzle_t nozzle)
{
int fd;
int fd = -1, savederrno = 0;

pthread_mutex_lock(&lib_mutex);
if (!nozzle) {
errno = EINVAL;
return -1;
}

savederrno = pthread_mutex_lock(&lib_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}

if (!_check(nozzle)) {
errno = EINVAL;
savederrno = ENOENT;
fd = -1;
goto out_clean;
}
Expand All @@ -1199,7 +1208,7 @@ int nozzle_get_fd(const nozzle_t nozzle)

out_clean:
pthread_mutex_unlock(&lib_mutex);

errno = savederrno;
return fd;
}

Expand Down
15 changes: 13 additions & 2 deletions libnozzle/libnozzle.h
Expand Up @@ -292,7 +292,7 @@ int nozzle_reset_mac(nozzle_t nozzle);

/**
* nozzle_get_handle_by_name
* @brief fine a nozzle handle by device name
* @brief find a nozzle handle by device name
*
* devname - string containing the name of the interface
*
Expand All @@ -305,7 +305,7 @@ nozzle_t nozzle_get_handle_by_name(char *devname);

/**
* nozzle_get_name_by_handle
* @brief fine a nozzle handle by device name
* @brief retrive nozzle interface name by handle
*
* nozzle - pointer to the nozzle struct
*
Expand All @@ -316,6 +316,17 @@ nozzle_t nozzle_get_handle_by_name(char *devname);

const char *nozzle_get_name_by_handle(const nozzle_t nozzle);

/**
* nozzle_get_fd
* @brief
*
* nozzle - pointer to the nozzle struct
*
* @return
* fd associated to a given nozzle on success.
* -1 on error and errno is set.
*/

int nozzle_get_fd(const nozzle_t nozzle);

#endif

0 comments on commit 924ddde

Please sign in to comment.