From f076ed27db62b3dd87789380d366a983a4e12290 Mon Sep 17 00:00:00 2001 From: aldot Date: Thu, 12 Apr 2007 11:34:39 +0000 Subject: - add xsendto and use where appropriate; shrink iplink; sanitize libiproute a bit. -916 byte git-svn-id: svn://busybox.net/trunk/busybox@18413 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- libbb/xfuncs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libbb') diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 870d736b3..7fe5c3a45 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -557,6 +557,22 @@ void xlisten(int s, int backlog) if (listen(s, backlog)) bb_perror_msg_and_die("listen"); } +/* Die with an error message if we the sendto failed. + * Return bytes sent otherwise + */ + +ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to, + socklen_t tolen) +{ + ssize_t ret = sendto(s, buf, len, 0, to, tolen); + if (ret < 0) { + if (ENABLE_FEATURE_CLEAN_UP) + close(s); + bb_perror_msg_and_die("sendto"); + } + return ret; +} + // xstat() - a stat() which dies on failure with meaningful error message void xstat(const char *name, struct stat *stat_buf) { -- cgit v1.2.3-55-g6feb