Skip to content

Commit 9513544

Browse files
committed
[C] Fix warnings.
1 parent 5cb2ebc commit 9513544

7 files changed

+15
-14
lines changed

aeron-driver/src/main/c/aeron_network_publication.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,11 @@ int aeron_network_publication_send_data(
401401
mmsghdr[i].msg_hdr.msg_controllen = 0;
402402
vlen++;
403403

404-
bytes_sent += available;
405-
available_window -= available + padding;
406-
term_offset += available + padding;
407-
highest_pos += available + padding;
404+
bytes_sent += (int)available;
405+
int32_t total_available = (int32_t)(available + padding);
406+
available_window -= total_available;
407+
term_offset += total_available;
408+
highest_pos += total_available;
408409
}
409410

410411
if (available == 0 || term_length == (size_t)term_offset)

aeron-driver/src/main/c/aeronmd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ int set_property(void *clientd, const char *name, const char *value)
6161
int main(int argc, char **argv)
6262
{
6363
int status = EXIT_FAILURE;
64-
int opt;
6564
aeron_driver_context_t *context = NULL;
6665
aeron_driver_t *driver = NULL;
6766

6867
#ifndef _MSC_VER
68+
int opt;
69+
6970
while ((opt = getopt(argc, argv, "D:v")) != -1)
7071
{
7172
switch (opt)

aeron-driver/src/main/c/protocol/aeron_udp_protocol.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ int aeron_udp_protocol_sm_receiver_tag(aeron_status_message_header_t *sm, int64_
3737

3838
*receiver_tag = 0;
3939

40-
return (int)sm->frame_header.frame_length - receiver_tag_offset;
40+
return (int)((size_t)sm->frame_header.frame_length - receiver_tag_offset);
4141
}
42-

aeron-driver/src/main/c/util/aeron_http_util.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ int aeron_http_retrieve(aeron_http_response_t **response, const char *url, int64
368368

369369
int aeron_http_header_get(aeron_http_response_t *response, const char *header_name, char *line, size_t max_length)
370370
{
371-
int line_result = 0, header_name_length = strlen(header_name);
371+
int line_result = 0;
372+
size_t header_name_length = strlen(header_name);
372373
size_t cursor = response->headers_offset;
373374

374375
while (cursor < response->body_offset)

aeron-driver/src/main/c/util/aeron_parse_util.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include <memory.h>
1817
#include <stdlib.h>
1918
#include <errno.h>
2019
#include <limits.h>
@@ -454,7 +453,7 @@ int aeron_parse_get_line(char *str, size_t max_length, const char *buffer)
454453
if ('\n' == buffer[i])
455454
{
456455
str[i + 1] = '\0';
457-
return i + 1;
456+
return (int)(i + 1);
458457
}
459458
}
460459

aeron-driver/src/main/c/util/aeron_properties_util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ int aeron_properties_parse_line(
7878
if (':' == c || '=' == c)
7979
{
8080
state->property_str[state->name_end] = '\0';
81-
value_start = i + 1;
81+
value_start = (int)i + 1;
8282

8383
/* trim back for whitespace after name */
84-
for (int j = i - 1; j >= 0; j--)
84+
for (size_t j = i - 1; j >= 0; j--)
8585
{
8686
if (' ' != line[j] && '\t' != line[j])
8787
{

aeron-driver/src/test/c/media/aeron_udp_channel_transport_loss_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ void aeron_udp_channel_interceptor_loss_incoming_delegate(
5656
size_t length,
5757
struct sockaddr_storage *addr)
5858
{
59-
delegate_recv_state_t *state = (delegate_recv_state_t *)interceptor_state;
59+
auto *state = (delegate_recv_state_t *)interceptor_state;
6060

6161
state->messages_received++;
62-
state->bytes_received += length;
62+
state->bytes_received += (int)length;
6363
}
6464

6565
TEST_F(UdpChannelTransportLossTest, shouldDiscardAllPacketsWithRateOfOne)

0 commit comments

Comments
 (0)