Skip to content

Commit

Permalink
Fix printf warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
babelouest committed Feb 28, 2024
1 parent f7e2e28 commit 737b37b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion example_programs/websocket_example/websocket_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void websocket_incoming_message_callback (const struct _u_request * request,
}
y_log_message(Y_LOG_LEVEL_DEBUG, "Incoming message, opcode: 0x%02x, mask: %d, len: %zu", last_message->opcode, last_message->has_mask, last_message->data_len);
if (last_message->opcode == U_WEBSOCKET_OPCODE_TEXT) {
y_log_message(Y_LOG_LEVEL_DEBUG, "text payload '%.*s'", last_message->data_len, last_message->data);
y_log_message(Y_LOG_LEVEL_DEBUG, "text payload '%.*s'", (int)last_message->data_len, last_message->data);
} else if (last_message->opcode == U_WEBSOCKET_OPCODE_BINARY) {
y_log_message(Y_LOG_LEVEL_DEBUG, "binary payload");
}
Expand Down
4 changes: 2 additions & 2 deletions example_programs/websocket_example/websocket_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void websocket_incoming_message_callback (const struct _u_request * request,
}
y_log_message(Y_LOG_LEVEL_DEBUG, "Incoming message, rsv: 0x%02x, opcode: 0x%02x, mask: %d, len: %zu", last_message->rsv, last_message->opcode, last_message->has_mask, last_message->data_len);
if (last_message->opcode == U_WEBSOCKET_OPCODE_TEXT) {
y_log_message(Y_LOG_LEVEL_DEBUG, "text payload '%.*s'", last_message->data_len, last_message->data);
y_log_message(Y_LOG_LEVEL_DEBUG, "text payload '%.*s'", (int)last_message->data_len, last_message->data);
} else if (last_message->opcode == U_WEBSOCKET_OPCODE_BINARY) {
y_log_message(Y_LOG_LEVEL_DEBUG, "binary payload");
}
Expand All @@ -261,7 +261,7 @@ void websocket_echo_message_callback (const struct _u_request * request,
(void)(request);
(void)(websocket_incoming_message_user_data);
y_log_message(Y_LOG_LEVEL_DEBUG, "Incoming message, rsv: 0x%02x, opcode: 0x%02x, mask: %d, len: %zu, text payload '%.*s'", last_message->rsv, last_message->opcode, last_message->has_mask, last_message->data_len, last_message->data_len, last_message->data);
if (ulfius_websocket_send_message(websocket_manager, last_message->opcode, last_message->data_len, last_message->data) != U_OK) {
if (ulfius_websocket_send_message(websocket_manager, last_message->opcode, (int)last_message->data_len, last_message->data) != U_OK) {
y_log_message(Y_LOG_LEVEL_ERROR, "Error ulfius_websocket_send_message");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/u_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ char * ulfius_export_request_http(const struct _u_request * request) {

if (request->binary_body_length) {
out = mstrcatf(out, "\r\n");
out = mstrcatf(out, "%.*s\r\n", request->binary_body_length, request->binary_body);
out = mstrcatf(out, "%.*s\r\n", (int)request->binary_body_length, request->binary_body);
} else if (u_map_count(request->map_post_body)) {
if (NULL == u_map_get(request->map_header, ULFIUS_HTTP_HEADER_CONTENT) ||
NULL != o_strstr(u_map_get(request->map_header, ULFIUS_HTTP_HEADER_CONTENT), MHD_HTTP_POST_ENCODING_FORM_URLENCODED)) {
Expand Down
2 changes: 1 addition & 1 deletion src/u_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ char * ulfius_export_response_http(const struct _u_response * response) {
out = mstrcatf(out, "\r\n");

if (response->binary_body_length) {
out = mstrcatf(out, "%.*s\r\n", response->binary_body_length, response->binary_body);
out = mstrcatf(out, "%.*s\r\n", (int)response->binary_body_length, response->binary_body);
}
}
return out;
Expand Down
2 changes: 1 addition & 1 deletion src/u_websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,7 @@ int ulfius_open_websocket_client_connection(struct _u_request * request,
if (y_url.username != NULL && y_url.password != NULL) {
basic_auth = msprintf("%s:%s", y_url.username, y_url.password);
if (o_base64_encode_alloc((const unsigned char *)basic_auth, o_strlen(basic_auth), &dat)) {
basic_auth_encoded_header = msprintf("Basic: %.*s", dat.size, dat.data);
basic_auth_encoded_header = msprintf("Basic: %.*s", (int)dat.size, dat.data);
u_map_remove_from_key(request->map_header, "Authorization");
u_map_put(request->map_header, "Authorization", basic_auth_encoded_header);
o_free(basic_auth_encoded_header);
Expand Down
4 changes: 2 additions & 2 deletions test/framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -4937,7 +4937,7 @@ int callback_function_cookie_param(const struct _u_request * request, struct _u_

int callback_function_multiple_continue(const struct _u_request * request, struct _u_response * response, void * user_data) {
if (response->binary_body != NULL) {
char * body = msprintf("%.*s\n%s", response->binary_body_length, (char*)response->binary_body, request->http_url);
char * body = msprintf("%.*s\n%s", (int)response->binary_body_length, (char*)response->binary_body, request->http_url);
ulfius_set_string_body_response(response, 200, body);
o_free(body);
} else {
Expand All @@ -4948,7 +4948,7 @@ int callback_function_multiple_continue(const struct _u_request * request, struc

int callback_function_multiple_complete(const struct _u_request * request, struct _u_response * response, void * user_data) {
if (response->binary_body != NULL) {
char * body = msprintf("%.*s\n%s", response->binary_body_length, (char*)response->binary_body, request->http_url);
char * body = msprintf("%.*s\n%s", (int)response->binary_body_length, (char*)response->binary_body, request->http_url);
ulfius_set_string_body_response(response, 200, body);
o_free(body);
} else {
Expand Down
10 changes: 5 additions & 5 deletions test/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int websocket_extension1_message_out_perform(const uint8_t opcode, const uint64_
if (((uintptr_t)user_data)&U_W_FLAG_CONTEXT) {
ck_assert_ptr_ne(context, NULL);
}
*data_out = msprintf("%.*s%s", (size_t)data_len_in, data_in, MESSAGE_EXT1);
*data_out = msprintf("%.*s%s", (int)data_len_in, data_in, MESSAGE_EXT1);
ck_assert_ptr_ne(*data_out, NULL);
*data_len_out = o_strlen(*data_out);
y_log_message(Y_LOG_LEVEL_DEBUG, "inside websocket_extension1_message_out_perform");
Expand All @@ -306,9 +306,9 @@ int websocket_extension1_message_in_perform(const uint8_t opcode, const uint64_t
if (((uintptr_t)user_data)&U_W_FLAG_CONTEXT) {
ck_assert_ptr_ne(context, NULL);
}
*data_out = msprintf("%.*s%s", (size_t)data_len_in, data_in, MESSAGE_EXT1);
*data_out = msprintf("%.*s%s", (int)data_len_in, data_in, MESSAGE_EXT1);
*data_len_out = o_strlen(*data_out);
y_log_message(Y_LOG_LEVEL_DEBUG, "inside websocket_extension1_message_in_perform: '%.*s'", (size_t)data_len_in, data_in);
y_log_message(Y_LOG_LEVEL_DEBUG, "inside websocket_extension1_message_in_perform: '%.*s'", (int)data_len_in, data_in);
return U_OK;
}

Expand All @@ -317,7 +317,7 @@ int websocket_extension2_message_out_perform(const uint8_t opcode, const uint64_
if (((uintptr_t)user_data)&U_W_FLAG_CONTEXT) {
ck_assert_ptr_ne(context, NULL);
}
*data_out = msprintf("%.*s%s", (size_t)data_len_in, data_in, MESSAGE_EXT2);
*data_out = msprintf("%.*s%s", (int)data_len_in, data_in, MESSAGE_EXT2);
*data_len_out = o_strlen(*data_out);
y_log_message(Y_LOG_LEVEL_DEBUG, "inside websocket_extension2_message_out_perform");
return U_OK;
Expand All @@ -328,7 +328,7 @@ int websocket_extension2_message_in_perform(const uint8_t opcode, const uint64_t
if (((uintptr_t)user_data)&U_W_FLAG_CONTEXT) {
ck_assert_ptr_ne(context, NULL);
}
*data_out = msprintf("%.*s%s", (size_t)data_len_in, data_in, MESSAGE_EXT2);
*data_out = msprintf("%.*s%s", (int)data_len_in, data_in, MESSAGE_EXT2);
*data_len_out = o_strlen(*data_out);
y_log_message(Y_LOG_LEVEL_DEBUG, "inside websocket_extension2_message_in_perform");
return U_OK;
Expand Down

0 comments on commit 737b37b

Please sign in to comment.