diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2022-10-29 11:45:23 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2022-10-29 11:45:23 +0200 |
commit | a45667193786cdc35ac7f348b9d7478cd8bc412d (patch) | |
tree | 130ce8f3103849dc27ad0f02be8ace022d655e38 | |
parent | be89d3952695df8feb2af12db313f2254e9da771 (diff) | |
download | tcp-a45667193786cdc35ac7f348b9d7478cd8bc412d.tar.gz |
Remove extra brackets
-rw-r--r-- | client.c | 34 | ||||
-rw-r--r-- | server.c | 20 |
2 files changed, 14 insertions, 40 deletions
@@ -35,9 +35,7 @@ send_file (int fd, const char *filename) off_t dummy = 0; /* specially for Solaris (it crashes if sendfile's 3rd arg is NULL). */ int sfd = open (filename, O_RDONLY); if (sfd < 0) - { - fatal ("cannot read `%s'", filename); - } + fatal ("cannot read `%s'", filename); struct stat st; if (!fstat (sfd, &st)) @@ -48,28 +46,18 @@ send_file (int fd, const char *filename) size_t filename_len = strlen (name) + 1; rc = write (fd, name, filename_len); /* filename\0payload */ if (rc != filename_len) - { - fatal ("failed to write filename"); - } + fatal ("failed to write filename"); rc = sendfile (fd, sfd, &dummy, st.st_size); if (rc < 0) - { - fatal ("failed to send file `%s'", filename); - } + fatal ("failed to send file `%s'", filename); else if (rc != st.st_size) - { - warning ("sent only %d of %d bytes of file `%s'", rc, - st.st_size, filename); - } + warning ("sent only %d of %d bytes of file `%s'", rc, + st.st_size, filename); else - { - info ("sent %d bytes of `%s'", rc, filename); - } + info ("sent %d bytes of `%s'", rc, filename); } else - { - fatal ("failed to stat `%s'", filename); - } + fatal ("failed to stat `%s'", filename); (void) close (sfd); } @@ -108,9 +96,7 @@ main (int argc, char **argv) rc = getaddrinfo (host, port, &hints, &result); if (0 != rc) - { - fatal ("getaddrinfo() failed"); - } + fatal ("getaddrinfo() failed"); for (rp = result; rp != NULL; rp = rp->ai_next) { fd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol); @@ -125,9 +111,7 @@ main (int argc, char **argv) freeaddrinfo (result); if (rp == NULL) - { - fatal ("failed to connect"); - } + fatal ("failed to connect"); send_file (fd, argv[2]); @@ -98,9 +98,7 @@ clean: if (dfd > 0) { if (close (dfd)) - { - warning ("failed to close %d", dfd); - } + warning ("failed to close %d", dfd); } } @@ -117,15 +115,11 @@ main (int argc, char **argv) progname = argv[0]; if (chdir (basedir)) - { - fatal ("failed to change directory to `%s'", basedir); - } + fatal ("failed to change directory to `%s'", basedir); listen_fd = socket (AF_INET, SOCK_STREAM, 0); if (listen_fd < 0) - { - fatal ("failed to create listen socket"); - } + fatal ("failed to create listen socket"); memset (&servaddr, 0, sizeof (servaddr)); servaddr.sin_family = AF_INET; @@ -135,15 +129,11 @@ main (int argc, char **argv) rc = bind (listen_fd, (const struct sockaddr *) &servaddr, sizeof (servaddr)); if (0 != rc) - { - fatal ("failed to bind listen socket"); - } + fatal ("failed to bind listen socket"); rc = listen (listen_fd, listen_queue); if (0 != rc) - { - fatal ("failed to plug listen socket"); - } + fatal ("failed to plug listen socket"); info ("accepting connections on port %d", port); info ("will save files under `%s'", basedir); |