summaryrefslogtreecommitdiffhomepage
path: root/src/network.c
diff options
context:
space:
mode:
authorrofl0r <retnyg@gmx.net>2017-12-04 11:33:01 +0000
committerrofl0r <retnyg@gmx.net>2017-12-04 11:33:01 +0000
commit9bb699628fe0375ab03fa795c44261e97a898beb (patch)
tree71b6cf739f30b075291516f260a9f3c216c5f595 /src/network.c
parente9e0f0b4f0341fa279e88d03f0f2baddff43cbe9 (diff)
safe_write/read: take void* buffer for generic use
if using one of unsigned or signed char for the function prototype, one gets nasty warnings when using it with the other type. the only proper solution is to put void* into the prototype, and then specialize the pointer inside the function using an automatic variable. for exactly this reason, libc functions like read(), write(), etc use void* too.
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/network.c b/src/network.c
index 7bae20b..224f924 100644
--- a/src/network.c
+++ b/src/network.c
@@ -32,10 +32,11 @@
* Write the buffer to the socket. If an EINTR occurs, pick up and try
* again. Keep sending until the buffer has been sent.
*/
-ssize_t safe_write (int fd, const char *buffer, size_t count)
+ssize_t safe_write (int fd, const void *buf, size_t count)
{
ssize_t len;
size_t bytestosend;
+ const char *buffer = buf;
assert (fd >= 0);
assert (buffer != NULL);
@@ -67,7 +68,7 @@ ssize_t safe_write (int fd, const char *buffer, size_t count)
* Matched pair for safe_write(). If an EINTR occurs, pick up and try
* again.
*/
-ssize_t safe_read (int fd, char *buffer, size_t count)
+ssize_t safe_read (int fd, void *buffer, size_t count)
{
ssize_t len;