aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2022-10-29 11:51:55 +0200
committerIgor Pashev <pashev.igor@gmail.com>2022-10-29 11:51:55 +0200
commit057bf2717ca56ff83f6ee1f61d095c601e810fa1 (patch)
tree6b490cb0945a1ba2d2a600fb0ba7abc06bff929a
parenta45667193786cdc35ac7f348b9d7478cd8bc412d (diff)
downloadtcp-057bf2717ca56ff83f6ee1f61d095c601e810fa1.tar.gz
Make it valid C++
-rw-r--r--client.c4
-rw-r--r--server.c9
2 files changed, 8 insertions, 5 deletions
diff --git a/client.c b/client.c
index 79f3f4b..9d04966 100644
--- a/client.c
+++ b/client.c
@@ -19,7 +19,7 @@
#include "utils.h"
const char *progname = NULL;
-char *port = "1234";
+const char *port = "1234";
static void
usage ()
@@ -43,7 +43,7 @@ send_file (int fd, const char *filename)
ssize_t rc;
info ("sending `%s'", filename);
const char *name = basename ((char *) filename);
- size_t filename_len = strlen (name) + 1;
+ ssize_t filename_len = strlen (name) + 1;
rc = write (fd, name, filename_len); /* filename\0payload */
if (rc != filename_len)
fatal ("failed to write filename");
diff --git a/server.c b/server.c
index 43148c2..3e3efcd 100644
--- a/server.c
+++ b/server.c
@@ -32,7 +32,10 @@ recvfile (int fd)
char *filename = NULL;
size_t filename_len;
off_t filelength = 0;
- char *buf = malloc (PATH_MAX);
+ char *payload_start;
+ ssize_t rest_len;
+
+ char *buf = (char *) malloc (PATH_MAX);
if (!buf)
{
warning ("failed to allocate space");
@@ -69,8 +72,8 @@ recvfile (int fd)
goto clean;
}
- char *payload_start = buf + filename_len + 1;
- ssize_t rest_len = rc - filename_len - 1;
+ payload_start = buf + filename_len + 1;
+ rest_len = rc - filename_len - 1;
rc = write (dfd, payload_start, rest_len); /* write the rest of buf. */
if (rc != rest_len)
{