lib/doc: clearify return value of send_simple() functions

The return value of the *nl_send_simple() functions is
inconsistent and not according to the documentation.

nl_send_simple() is document to return the number of bytes sent.
Other *nl_send_simple() functions are documented to return 0 on
success -- for the most part.
See also commit b70174668b which
changed behavior of nl_rtgen_request() to be according to documenation.

Don't change behavior again, only adjust the documentation.

http://lists.infradead.org/pipermail/libnl/2015-May/001872.html

Reported-by: Xiao Jia <stfairy@gmail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2015-05-12 15:04:48 +02:00
parent c3dd6a7355
commit 4818248634
7 changed files with 26 additions and 7 deletions

View file

@ -637,7 +637,9 @@ void nl_cache_set_flags(struct nl_cache *cache, unsigned int flags)
*
* @see nl_cache_pickup(), nl_cache_resync()
*
* @return 0 on success or a negative error code.
* @return 0 on success or a negative error code. Some implementations
* of co_request_update() return a positive number on success that is
* the number of bytes sent. Treat any non-negative number as success too.
*/
static int nl_cache_request_full_dump(struct nl_sock *sk,
struct nl_cache *cache)

View file

@ -79,7 +79,8 @@ int genl_connect(struct nl_sock *sk)
*
* @see nl_send_simple()
*
* @return 0 on success or a negative error code.
* @return 0 on success or a negative error code. Due to a bug, this function
* returns the number of bytes sent. Treat any non-negative number as success.
*/
int genl_send_simple(struct nl_sock *sk, int family, int cmd,
int version, int flags)

View file

@ -57,7 +57,8 @@ int idiagnl_connect(struct nl_sock *sk)
* @arg states Socket states to query
* @arg ext Inet Diag attribute extensions to query
*
* @return Newly allocated netlink message or NULL.
* @return 0 on success or a negative error code. Due to a bug, this function
* returns the number of bytes sent. Treat any non-negative number as success.
*/
int idiagnl_send_simple(struct nl_sock *sk, int flags, uint8_t family,
uint16_t states, uint16_t ext)

View file

@ -413,6 +413,13 @@ static int ct_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
return err;
}
/**
* Send nfnl ct dump request
* @arg sk Netlink socket.
*
* @return 0 on success or a negative error code. Due to a bug, this function
* returns the number of bytes sent. Treat any non-negative number as success.
*/
int nfnl_ct_dump_request(struct nl_sock *sk)
{
return nfnl_send_simple(sk, NFNL_SUBSYS_CTNETLINK, IPCTNL_MSG_CT_GET,

View file

@ -305,6 +305,13 @@ static int exp_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
return err;
}
/**
* Send nfnl exp dump request
* @arg sk Netlink socket.
*
* @return 0 on success or a negative error code. Due to a bug, this function
* returns the number of bytes sent. Treat any non-negative number as success.
*/
int nfnl_exp_dump_request(struct nl_sock *sk)
{
return nfnl_send_simple(sk, NFNL_SUBSYS_CTNETLINK_EXP, IPCTNL_MSG_EXP_GET,

View file

@ -102,7 +102,8 @@ int nfnl_connect(struct nl_sock *sk)
* @arg family nfnetlink address family
* @arg res_id nfnetlink resource id
*
* @return Newly allocated netlink message or NULL.
* @return 0 on success or a negative error code. Due to a bug, this function
* returns the number of bytes sent. Treat any non-negative number as success.
*/
int nfnl_send_simple(struct nl_sock *sk, uint8_t subsys_id, uint8_t type,
int flags, uint8_t family, uint16_t res_id)

View file

@ -34,9 +34,9 @@
* Fills out a routing netlink request message and sends it out
* using nl_send_simple().
*
* @return 0 on success or a negative error code. Due to a bug in
* older versions, this returned the number of bytes sent. So for
* compatibility, treat positive return values as success too.
* @return 0 on success or a negative error code. Due to a bug in older
* version of the library, this function returned the number of bytes sent.
* Treat any non-negative number as success.
*/
int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
{