Skip to content

Display and control your Android device

Fix warnings on Windows

Romain Vimont8dc11a0286fb
diff --git a/app/src/command.h b/app/src/command.h
index d119c9bb..e748c1c5 100644
--- a/app/src/command.h
+++ b/app/src/command.h
@@ -18,6 +18,7 @@
# define PRIsizet PRIu32
# endif
# define PROCESS_NONE NULL
+# define NO_EXIT_CODE -1u // max value as unsigned
typedef HANDLE process_t;
typedef DWORD exit_code_t;
@@ -28,6 +29,7 @@
# define PRIsizet "zu"
# define PRIexitcode "d"
# define PROCESS_NONE -1
+# define NO_EXIT_CODE -1
typedef pid_t process_t;
typedef int exit_code_t;
@@ -35,8 +37,6 @@
#include "config.h"
-# define NO_EXIT_CODE -1
-
enum process_result {
PROCESS_SUCCESS,
PROCESS_ERROR_GENERIC,
diff --git a/app/src/main.c b/app/src/main.c
index c17cc6bf..cdd8c2ef 100644
--- a/app/src/main.c
+++ b/app/src/main.c
@@ -243,7 +243,7 @@ parse_bit_rate(char *optarg, uint32_t *bit_rate) {
return false;
}
}
- if (value < 0 || ((uint32_t) -1) / mul < value) {
+ if (value < 0 || ((uint32_t) -1) / mul < (unsigned long) value) {
LOGE("Bitrate must be positive and less than 2^32: %s", optarg);
return false;
}
diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c
index 06e20e26..17be1ed4 100644
--- a/app/src/scrcpy.c
+++ b/app/src/scrcpy.c
@@ -103,6 +103,7 @@ sdl_init_and_configure(bool display) {
// <https://stackoverflow.com/a/40693139/1987178>
static int
event_watcher(void *data, SDL_Event *event) {
+ (void) data;
if (event->type == SDL_WINDOWEVENT
&& event->window.event == SDL_WINDOWEVENT_RESIZED) {
// called from another thread, not very safe, but it's a workaround!
diff --git a/app/src/stream.c b/app/src/stream.c
index c84de981..35a541e4 100644
--- a/app/src/stream.c
+++ b/app/src/stream.c
@@ -44,6 +44,7 @@ stream_recv_packet(struct stream *stream, AVPacket *packet) {
uint64_t pts = buffer_read64be(header);
uint32_t len = buffer_read32be(&header[8]);
+ SDL_assert(pts == NO_PTS || (pts & 0x8000000000000000) == 0);
SDL_assert(len);
if (av_new_packet(packet, len)) {
@@ -52,12 +53,12 @@ stream_recv_packet(struct stream *stream, AVPacket *packet) {
}
r = net_recv_all(stream->socket, packet->data, len);
- if (r < len) {
+ if (r < 0 || ((uint32_t) r) < len) {
av_packet_unref(packet);
return false;
}
- packet->pts = pts != NO_PTS ? pts : AV_NOPTS_VALUE;
+ packet->pts = pts != NO_PTS ? (int64_t) pts : AV_NOPTS_VALUE;
return true;
}
diff --git a/app/src/sys/win/command.c b/app/src/sys/win/command.c
index ab335089..6cd0e944 100644
--- a/app/src/sys/win/command.c
+++ b/app/src/sys/win/command.c
@@ -20,6 +20,7 @@ build_cmd(char *cmd, size_t len, const char *const argv[]) {
enum process_result
cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
+ (void) path;
STARTUPINFOW si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));