From a45667193786cdc35ac7f348b9d7478cd8bc412d Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Sat, 29 Oct 2022 11:45:23 +0200 Subject: Remove extra brackets --- client.c | 34 +++++++++------------------------- server.c | 20 +++++--------------- 2 files changed, 14 insertions(+), 40 deletions(-) diff --git a/client.c b/client.c index 161284b..79f3f4b 100644 --- a/client.c +++ b/client.c @@ -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]); diff --git a/server.c b/server.c index b383071..43148c2 100644 --- a/server.c +++ b/server.c @@ -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); -- cgit v1.2.3