mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-21 03:55:05 +00:00
explicitly cast -1 to size_t, support static_assert on pre-c11
This commit is contained in:
parent
108f785c12
commit
2088adcdc1
5 changed files with 10 additions and 6 deletions
|
@ -10,6 +10,10 @@
|
|||
#include "util/log.h"
|
||||
#include "util/str_util.h"
|
||||
|
||||
#ifndef static_assert
|
||||
#define static_assert(x, msg) (void) sizeof(struct {int a[(x) ? 1 : -1]})
|
||||
#endif
|
||||
|
||||
void
|
||||
scrcpy_print_usage(const char *arg0) {
|
||||
fprintf(stderr,
|
||||
|
|
|
@ -47,7 +47,7 @@ process_msgs(const unsigned char *buf, size_t len) {
|
|||
for (;;) {
|
||||
struct device_msg msg;
|
||||
size_t r = device_msg_deserialize(&buf[head], len - head, &msg);
|
||||
if (r == -1) {
|
||||
if (r == (size_t)-1) {
|
||||
return -1;
|
||||
}
|
||||
if (r == 0) {
|
||||
|
@ -76,14 +76,14 @@ run_receiver(void *data) {
|
|||
assert(head < DEVICE_MSG_MAX_SIZE);
|
||||
size_t r = net_recv(receiver->control_socket, buf + head,
|
||||
DEVICE_MSG_MAX_SIZE - head);
|
||||
if (!r || r == -1) {
|
||||
if (!r || r == (size_t)-1) {
|
||||
LOGD("Receiver stopped");
|
||||
break;
|
||||
}
|
||||
|
||||
head += r;
|
||||
size_t consumed = process_msgs(buf, head);
|
||||
if (consumed == -1) {
|
||||
if (consumed == (size_t)-1) {
|
||||
// an error occurred
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ stream_recv_packet(struct stream *stream, AVPacket *packet) {
|
|||
}
|
||||
|
||||
r = net_recv_all(stream->socket, packet->data, len);
|
||||
if (r == -1 || ((uint32_t) r) < len) {
|
||||
if (r == (size_t)-1 || ((uint32_t) r) < len) {
|
||||
av_packet_unref(packet);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ get_executable_path(void) {
|
|||
#ifdef __linux__
|
||||
char buf[PATH_MAX + 1]; // +1 for the null byte
|
||||
size_t len = readlink("/proc/self/exe", buf, PATH_MAX);
|
||||
if (len == -1) {
|
||||
if (len == (size_t)-1) {
|
||||
perror("readlink");
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ net_send_all(socket_t socket, const void *buf, size_t len) {
|
|||
size_t w = 0;
|
||||
while (len > 0) {
|
||||
w = send(socket, buf, len, 0);
|
||||
if (w == -1) {
|
||||
if (w == (size_t)-1) {
|
||||
return -1;
|
||||
}
|
||||
len -= w;
|
||||
|
|
Loading…
Add table
Reference in a new issue