From: Jan Engelhardt <jengelh@medozas.de>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 2/6] socket: propagate sendto/recvmsg's return types
Date: Tue, 16 Nov 2010 12:43:29 +0100 [thread overview]
Message-ID: <1289907814-32706-3-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1289907814-32706-1-git-send-email-jengelh@medozas.de>
sendto/recvfrom return ssize_t, so libmnl should not truncate the
result range.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
include/libmnl/libmnl.h | 4 ++--
src/socket.c | 8 +++++---
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index c58635f..01ae484 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -36,8 +36,8 @@ MNL_API int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pi
MNL_API int mnl_socket_close(struct mnl_socket *nl);
MNL_API int mnl_socket_get_fd(const struct mnl_socket *nl);
MNL_API unsigned int mnl_socket_get_portid(const struct mnl_socket *nl);
-MNL_API int mnl_socket_sendto(const struct mnl_socket *nl, const void *req, size_t siz);
-MNL_API int mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t siz);
+MNL_API ssize_t mnl_socket_sendto(const struct mnl_socket *nl, const void *req, size_t siz);
+MNL_API ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t siz);
MNL_API int mnl_socket_setsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t len);
MNL_API int mnl_socket_getsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t *len);
diff --git a/src/socket.c b/src/socket.c
index cc997df..9b102e7 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -169,7 +169,8 @@ int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid)
* On error, it returns -1 and errno is appropriately set. Otherwise, it
* returns the number of bytes sent.
*/
-int mnl_socket_sendto(const struct mnl_socket *nl, const void *buf, size_t len)
+ssize_t mnl_socket_sendto(const struct mnl_socket *nl, const void *buf,
+ size_t len)
{
static const struct sockaddr_nl snl = {
.nl_family = AF_NETLINK
@@ -192,9 +193,10 @@ int mnl_socket_sendto(const struct mnl_socket *nl, const void *buf, size_t len)
* buffer size ensures that your buffer is big enough to store the netlink
* message without truncating it.
*/
-int mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t bufsiz)
+ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf,
+ size_t bufsiz)
{
- int ret;
+ ssize_t ret;
struct sockaddr_nl addr;
struct iovec iov = {
.iov_base = buf,
--
1.7.1
next prev parent reply other threads:[~2010-11-16 11:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 11:43 libmnl: proposed patches 20101116 Jan Engelhardt
2010-11-16 11:43 ` [PATCH 1/6] attr: avoid multiple definition of hidden variable Jan Engelhardt
2010-11-16 11:43 ` Jan Engelhardt [this message]
2010-11-16 11:43 ` [PATCH 3/6] Update .gitignore Jan Engelhardt
2010-11-16 11:43 ` [PATCH 4/6] build: tag function headers rather than decls as exported Jan Engelhardt
2010-11-19 11:09 ` Pablo Neira Ayuso
2010-11-19 11:26 ` Jan Engelhardt
2010-11-19 11:43 ` Pablo Neira Ayuso
2010-11-16 11:43 ` [PATCH 5/6] build: add some more precautionary CFLAGS Jan Engelhardt
2010-11-16 11:43 ` [PATCH 6/6] nlmsg: remove unused function Jan Engelhardt
2010-11-19 11:16 ` libmnl: proposed patches 20101116 Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1289907814-32706-3-git-send-email-jengelh@medozas.de \
--to=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).