diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2022-10-29 11:51:55 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2022-10-29 11:51:55 +0200 |
commit | 057bf2717ca56ff83f6ee1f61d095c601e810fa1 (patch) | |
tree | 6b490cb0945a1ba2d2a600fb0ba7abc06bff929a | |
parent | a45667193786cdc35ac7f348b9d7478cd8bc412d (diff) | |
download | tcp-057bf2717ca56ff83f6ee1f61d095c601e810fa1.tar.gz |
Make it valid C++
-rw-r--r-- | client.c | 4 | ||||
-rw-r--r-- | server.c | 9 |
2 files changed, 8 insertions, 5 deletions
@@ -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"); @@ -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) { |