Skip to content

Commit

Permalink
Fix size_t incorrectly assigned to int
Browse files Browse the repository at this point in the history
The function control_msg_serialize() returns a size_t.
  • Loading branch information
rom1v committed Jan 17, 2021
1 parent 8dbb167 commit 94eff0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ static bool
process_msg(struct controller *controller,
const struct control_msg *msg) {
static unsigned char serialized_msg[CONTROL_MSG_MAX_SIZE];
int length = control_msg_serialize(msg, serialized_msg);
size_t length = control_msg_serialize(msg, serialized_msg);
if (!length) {
return false;
}
int w = net_send_all(controller->control_socket, serialized_msg, length);
return w == length;
return (size_t) w == length;
}

static int
Expand Down
24 changes: 12 additions & 12 deletions app/tests/test_control_msg_serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static void test_serialize_inject_keycode(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 14);

const unsigned char expected[] = {
Expand All @@ -39,7 +39,7 @@ static void test_serialize_inject_text(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 18);

const unsigned char expected[] = {
Expand All @@ -59,7 +59,7 @@ static void test_serialize_inject_text_long(void) {
msg.inject_text.text = text;

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 5 + CONTROL_MSG_INJECT_TEXT_MAX_LENGTH);

unsigned char expected[5 + CONTROL_MSG_INJECT_TEXT_MAX_LENGTH];
Expand Down Expand Up @@ -95,7 +95,7 @@ static void test_serialize_inject_touch_event(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 28);

const unsigned char expected[] = {
Expand Down Expand Up @@ -130,7 +130,7 @@ static void test_serialize_inject_scroll_event(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 21);

const unsigned char expected[] = {
Expand All @@ -149,7 +149,7 @@ static void test_serialize_back_or_screen_on(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 1);

const unsigned char expected[] = {
Expand All @@ -164,7 +164,7 @@ static void test_serialize_expand_notification_panel(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 1);

const unsigned char expected[] = {
Expand All @@ -179,7 +179,7 @@ static void test_serialize_collapse_notification_panel(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 1);

const unsigned char expected[] = {
Expand All @@ -194,7 +194,7 @@ static void test_serialize_get_clipboard(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 1);

const unsigned char expected[] = {
Expand All @@ -213,7 +213,7 @@ static void test_serialize_set_clipboard(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 19);

const unsigned char expected[] = {
Expand All @@ -234,7 +234,7 @@ static void test_serialize_set_screen_power_mode(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 2);

const unsigned char expected[] = {
Expand All @@ -250,7 +250,7 @@ static void test_serialize_rotate_device(void) {
};

unsigned char buf[CONTROL_MSG_MAX_SIZE];
int size = control_msg_serialize(&msg, buf);
size_t size = control_msg_serialize(&msg, buf);
assert(size == 1);

const unsigned char expected[] = {
Expand Down

0 comments on commit 94eff0a

Please sign in to comment.