summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2006-12-18 22:10:24 +0000
committerDenis Vlasenko2006-12-18 22:10:24 +0000
commitc8e6e35ba4095846121d5b5a3eee57caa5e8e0fb (patch)
treed310542c65bbfd183b50f156916ef3313721625f
parent83e5d6f77237b64853c194b0ce592e77ef677c4d (diff)
downloadbusybox-c8e6e35ba4095846121d5b5a3eee57caa5e8e0fb.zip
busybox-c8e6e35ba4095846121d5b5a3eee57caa5e8e0fb.tar.gz
nc: add missing cast
xfuncs: add dprintf for dietlibc
-rw-r--r--include/platform.h3
-rw-r--r--libbb/xfuncs.c31
-rw-r--r--networking/nc.c2
3 files changed, 35 insertions, 1 deletions
diff --git a/include/platform.h b/include/platform.h
index a1ec17a..860143f 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -194,6 +194,9 @@ typedef unsigned long long int uintmax_t;
* libbb. This would require a platform.c. It's not going to be cleaned
* out of the tree, so stop saying it should be. */
#define fdprintf dprintf
+#ifdef __dietlibc__
+int dprintf(int fd, const char *format, ...);
+#endif
/* Don't use lchown with glibc older than 2.1.x ... uC-libc lacks it */
#if (defined __GLIBC__ && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1) || \
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 313e328..4790aa1 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -411,6 +411,37 @@ char *xasprintf(const char *format, ...)
return string_ptr;
}
+#ifdef __dietlibc__
+int dprintf(int fd, const char *format, ...)
+{
+ va_list p;
+ int r;
+ char *string_ptr;
+
+#if 1
+ // GNU extension
+ va_start(p, format);
+ r = vasprintf(&string_ptr, format, p);
+ va_end(p);
+#else
+ // Bloat for systems that haven't got the GNU extension.
+ va_start(p, format);
+ r = vsnprintf(NULL, 0, format, p);
+ va_end(p);
+ string_ptr = xmalloc(r+1);
+ va_start(p, format);
+ r = vsnprintf(string_ptr, r+1, format, p);
+ va_end(p);
+#endif
+
+ if (r >= 0) {
+ full_write(fd, string_ptr, r);
+ free(string_ptr);
+ }
+ return r;
+}
+#endif
+
// Die with an error message if we can't copy an entire FILE * to stdout, then
// close that file.
void xprint_and_close_file(FILE *file)
diff --git a/networking/nc.c b/networking/nc.c
index 5fd9242..b2a4596 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -104,7 +104,7 @@ int nc_main(int argc, char **argv)
if (!lport) {
socklen_t len = sizeof(address);
- getsockname(sfd, &address, &len);
+ getsockname(sfd, (struct sockaddr *) &address, &len);
fdprintf(2, "%d\n", SWAP_BE16(address.sin_port));
}
repeatyness: