Skip to content

Fix some Windows warnings #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void *recv_thread(void *arg) {
perror("recv");
break;
} else if (bytes_received > LEN_FORMATTED_MSG) {
fprintf(stderr, "Packet length exceeded by %ld bytes\n", bytes_received - LEN_FORMATTED_MSG);
fprintf(stderr, "Packet length exceeded by %zd bytes\n", bytes_received - LEN_FORMATTED_MSG);
break;
}

Expand Down
4 changes: 2 additions & 2 deletions tcp_file_transfer_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int func(socket_t sockfd, const char *file) {
exit(errno);
}
long len = ftell(fp);
printf("file length: %li\n", len);
printf("file length: %zd\n", len);
rewind(fp);

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

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

Expand Down
6 changes: 3 additions & 3 deletions tcp_file_transfer_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int recv_file(socket_t sockfd) {
}
n_bytes_total += n_bytes_recvd;
}
printf("bytes received: %li\r", n_bytes_total);
printf("bytes received: %zd\r", n_bytes_total);
}
}
}
Expand Down Expand Up @@ -135,13 +135,13 @@ static int recv_file(socket_t sockfd) {
printf("Poll timed out!\n");
} else {
if (pfds[0].revents & POLLOUT) {
snprintf(buff, sizeof buff, "%s %li bytes",
snprintf(buff, sizeof buff, "%s %zd bytes",
f_exists == 0 ? "Received " : "File already exists. Received", n_bytes_total);
puts(buff);
puts("Sending confirmation to client");
ssize_t s_r = send(pfds[0].fd, buff, strlen(buff) + 1, 0);
if (s_r >= 0)
printf("%li bytes sent\n", s_r);
printf("%zd bytes sent\n", s_r);
else
perror("send");
}
Expand Down
2 changes: 1 addition & 1 deletion udp_echo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
return -1;
}

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

if (strncasecmp(buf, "exit", 4) == 0) {
close(socket_info.sockfd);
Expand Down
2 changes: 1 addition & 1 deletion udp_echo_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
int s = getnameinfo((struct sockaddr *)&peer_addr, peer_addr_len, host, NI_MAXHOST, service,
NI_MAXSERV, NI_NUMERICSERV);
if (s == 0)
printf("Received %ld bytes from %s:%s\n", (long)nread, host, service);
printf("Received %zd bytes from %s:%s\n", nread, host, service);
else
fprintf(stderr, "getnameinfo: %s\n", gai_strerror(s));

Expand Down
4 changes: 0 additions & 4 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

#include "util.h"

#ifdef _WIN32
#include <windows.h>
#endif

volatile sig_atomic_t stop = 0;

#ifdef _WIN32
Expand Down
6 changes: 5 additions & 1 deletion util.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#pragma once
#include <signal.h>

#ifdef _WIN32
#include <windows.h>
#endif

#include "netex.h"

extern volatile sig_atomic_t stop;

#ifdef _WIN32_
BOOL WINAPI console_handler(DWORD signal_type)
BOOL WINAPI console_handler(DWORD signal_type);
#else
void signal_handler(int signum);
#endif
Expand Down
Loading