Skip to content

Commit 10f3f55

Browse files
committed
Fix some Windows warnings
1 parent 22604da commit 10f3f55

6 files changed

+9
-9
lines changed

graphics.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void *recv_thread(void *arg) {
6666
perror("recv");
6767
break;
6868
} else if (bytes_received > LEN_FORMATTED_MSG) {
69-
fprintf(stderr, "Packet length exceeded by %ld bytes\n", bytes_received - LEN_FORMATTED_MSG);
69+
fprintf(stderr, "Packet length exceeded by %zd bytes\n", bytes_received - LEN_FORMATTED_MSG);
7070
break;
7171
}
7272

tcp_file_transfer_client.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int func(socket_t sockfd, const char *file) {
4848
exit(errno);
4949
}
5050
long len = ftell(fp);
51-
printf("file length: %li\n", len);
51+
printf("file length: %zd\n", len);
5252
rewind(fp);
5353

5454
// basename() may modify the contents of 'file', so create a copy
@@ -71,7 +71,7 @@ int func(socket_t sockfd, const char *file) {
7171
}
7272
send(sockfd, buff, num, 0);
7373
n_bytes_total += num;
74-
printf("bytes sent: %li\r", n_bytes_total);
74+
printf("bytes sent: %zu\r", n_bytes_total);
7575

7676
} while (feof(fp) == 0);
7777

tcp_file_transfer_server.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int recv_file(socket_t sockfd) {
105105
}
106106
n_bytes_total += n_bytes_recvd;
107107
}
108-
printf("bytes received: %li\r", n_bytes_total);
108+
printf("bytes received: %zd\r", n_bytes_total);
109109
}
110110
}
111111
}
@@ -135,13 +135,13 @@ static int recv_file(socket_t sockfd) {
135135
printf("Poll timed out!\n");
136136
} else {
137137
if (pfds[0].revents & POLLOUT) {
138-
snprintf(buff, sizeof buff, "%s %li bytes",
138+
snprintf(buff, sizeof buff, "%s %zd bytes",
139139
f_exists == 0 ? "Received " : "File already exists. Received", n_bytes_total);
140140
puts(buff);
141141
puts("Sending confirmation to client");
142142
ssize_t s_r = send(pfds[0].fd, buff, strlen(buff) + 1, 0);
143143
if (s_r >= 0)
144-
printf("%li bytes sent\n", s_r);
144+
printf("%zd bytes sent\n", s_r);
145145
else
146146
perror("send");
147147
}

udp_echo_client.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
9797
return -1;
9898
}
9999

100-
printf("Received %ld bytes: %s\n\n", (long)nread, buf);
100+
printf("Received %zu bytes: %s\n\n", nread, buf);
101101

102102
if (strncasecmp(buf, "exit", 4) == 0) {
103103
close(socket_info.sockfd);

udp_echo_server.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
5656
int s = getnameinfo((struct sockaddr *)&peer_addr, peer_addr_len, host, NI_MAXHOST, service,
5757
NI_MAXSERV, NI_NUMERICSERV);
5858
if (s == 0)
59-
printf("Received %ld bytes from %s:%s\n", (long)nread, host, service);
59+
printf("Received %zd bytes from %s:%s\n", nread, host, service);
6060
else
6161
fprintf(stderr, "getnameinfo: %s\n", gai_strerror(s));
6262

util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
extern volatile sig_atomic_t stop;
77

88
#ifdef _WIN32_
9-
BOOL WINAPI console_handler(DWORD signal_type)
9+
BOOL WINAPI console_handler(DWORD signal_type);
1010
#else
1111
void signal_handler(int signum);
1212
#endif

0 commit comments

Comments
 (0)