Skip to content

Commit

Permalink
use size_t for the total byte count
Browse files Browse the repository at this point in the history
  • Loading branch information
vladak committed Dec 1, 2024
1 parent 95bbf7f commit 824c743
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions select/write-select.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ main(int argc, char **argv)
fd_set wrfds;
char buf[BUF_LEN];
struct sockaddr_in sa;
int s, newsock, n, total = 0, optval = 1;
int s, newsock, n, optval = 1;
size_t total = 0;

if (argc != 2)
errx(1, "usage: %s <port>", basename(argv[0]));
Expand Down Expand Up @@ -104,7 +105,7 @@ main(int argc, char **argv)
if ((n = write(newsock, buf, sizeof (buf))) == -1)
err(1, "write");
total = total + n;
fprintf(stderr, "[ %d bytes written (total %d) ]\n",
fprintf(stderr, "[ %d bytes written (total %zu) ]\n",
n, total);
}

Expand Down

0 comments on commit 824c743

Please sign in to comment.