From 4d4882797676382c04b50109b288fccab0de3ece Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Sat, 3 Jan 2015 16:40:32 +0100 Subject: [PATCH] test: Silent warnings in simline tests --- test/simline/basic_authentication.c | 2 +- .../certificate_user_password_authentication.c | 2 +- test/simline/hotp_authentication.c | 2 +- test/simline/hotp_isds_change_password.c | 2 +- test/simline/http.c | 2 +- test/simline/isds_change_password.c | 2 +- test/simline/isds_delete_message_from_storage.c | 2 +- test/simline/isds_find_box_by_fulltext.c | 2 +- test/simline/isds_get_commercial_credit.c | 46 ++++++++------ test/simline/isds_ping.c | 2 +- test/simline/isds_resign_message.c | 2 +- test/simline/server.c | 2 + test/simline/server_cli.c | 2 + test/simline/service.c | 73 ++++++++++------------ test/simline/totp_authentication.c | 2 +- test/simline/totp_isds_change_password.c | 2 +- 16 files changed, 76 insertions(+), 71 deletions(-) diff --git a/test/simline/basic_authentication.c b/test/simline/basic_authentication.c index 6be5fee..3ec0a92 100644 --- a/test/simline/basic_authentication.c +++ b/test/simline/basic_authentication.c @@ -37,7 +37,7 @@ static int test_login(const isds_error error, struct isds_ctx *context, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/certificate_user_password_authentication.c b/test/simline/certificate_user_password_authentication.c index c586dbe..ca28a95 100644 --- a/test/simline/certificate_user_password_authentication.c +++ b/test/simline/certificate_user_password_authentication.c @@ -44,7 +44,7 @@ static int test_login(const isds_error error, struct isds_ctx *context, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/hotp_authentication.c b/test/simline/hotp_authentication.c index 0a44890..6269c15 100644 --- a/test/simline/hotp_authentication.c +++ b/test/simline/hotp_authentication.c @@ -66,7 +66,7 @@ static int test_ping(const isds_error error, struct isds_ctx *context) { PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/hotp_isds_change_password.c b/test/simline/hotp_isds_change_password.c index 62ee764..3958850 100644 --- a/test/simline/hotp_isds_change_password.c +++ b/test/simline/hotp_isds_change_password.c @@ -64,7 +64,7 @@ static int test_isds_change_password(const isds_error error, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/http.c b/test/simline/http.c index b340e5b..5864b22 100644 --- a/test/simline/http.c +++ b/test/simline/http.c @@ -587,7 +587,7 @@ static int find_content_length(struct http_request *request) { return HTTP_ERROR_SERVER; if (value < 0) return HTTP_ERROR_CLIENT; - if (value > SIZE_MAX) + if ((unsigned long long)value > SIZE_MAX) return HTTP_ERROR_SERVER; request->body_length = value; } else { diff --git a/test/simline/isds_change_password.c b/test/simline/isds_change_password.c index a567c0b..967a6ec 100644 --- a/test/simline/isds_change_password.c +++ b/test/simline/isds_change_password.c @@ -51,7 +51,7 @@ static int test_isds_change_password(const isds_error error, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/isds_delete_message_from_storage.c b/test/simline/isds_delete_message_from_storage.c index 029ec89..1de9c8a 100644 --- a/test/simline/isds_delete_message_from_storage.c +++ b/test/simline/isds_delete_message_from_storage.c @@ -49,7 +49,7 @@ static int test_isds_delete_message_from_storage(const isds_error error, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/isds_find_box_by_fulltext.c b/test/simline/isds_find_box_by_fulltext.c index 754ae74..08e9f4b 100644 --- a/test/simline/isds_find_box_by_fulltext.c +++ b/test/simline/isds_find_box_by_fulltext.c @@ -199,7 +199,7 @@ static int test_isds_find_box_by_fulltext(const isds_error expected_error, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/isds_get_commercial_credit.c b/test/simline/isds_get_commercial_credit.c index a656591..f668f10 100644 --- a/test/simline/isds_get_commercial_credit.c +++ b/test/simline/isds_get_commercial_credit.c @@ -155,7 +155,7 @@ static int test_isds_get_commercial_credit(const isds_error error, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; @@ -244,26 +244,30 @@ int main(int argc, char **argv) { .credit_change = 133, .new_credit = 244, .type = ISDS_CREDIT_STORAGE_SET, - .details.storage_set.new_capacity = 41, - .details.storage_set.new_valid_from = &new_valid_from, - .details.storage_set.new_valid_to = &new_valid_to, - .details.storage_set.old_capacity = &old_capacity, - .details.storage_set.old_valid_from = &old_valid_from, - .details.storage_set.old_valid_to = &old_valid_to, - .details.storage_set.initiator = "Foo", + .details.storage_set = { + .new_capacity = 41, + .new_valid_from = &new_valid_from, + .new_valid_to = &new_valid_to, + .old_capacity = &old_capacity, + .old_valid_from = &old_valid_from, + .old_valid_to = &old_valid_to, + .initiator = "Foo", + }, }; struct server_credit_event server_event_credit_storage_set = { .time = &event_time, .credit_change = 133, .new_credit = 244, .type = SERVER_CREDIT_STORAGE_SET, - .details.storage_set.new_capacity = 41, - .details.storage_set.new_valid_from = &new_valid_from, - .details.storage_set.new_valid_to = &new_valid_to, - .details.storage_set.old_capacity = &old_capacity, - .details.storage_set.old_valid_from = &old_valid_from, - .details.storage_set.old_valid_to = &old_valid_to, - .details.storage_set.initiator = "Foo", + .details.storage_set = { + .new_capacity = 41, + .new_valid_from = &new_valid_from, + .new_valid_to = &new_valid_to, + .old_capacity = &old_capacity, + .old_valid_from = &old_valid_from, + .old_valid_to = &old_valid_to, + .initiator = "Foo", + }, }; struct isds_list history_storage_set = { .next = &history_expired, @@ -281,16 +285,20 @@ int main(int argc, char **argv) { .credit_change = 133, .new_credit = 244, .type = ISDS_CREDIT_MESSAGE_SENT, - .details.message_sent.recipient = "Foo", - .details.message_sent.message_id = "ijklmnop", + .details.message_sent = { + .recipient = "Foo", + .message_id = "ijklmnop", + }, }; struct server_credit_event server_event_credit_message_sent = { .time = &event_time, .credit_change = 133, .new_credit = 244, .type = SERVER_CREDIT_MESSAGE_SENT, - .details.message_sent.recipient = "Foo", - .details.message_sent.message_id = "ijklmnop", + .details.message_sent = { + .recipient = "Foo", + .message_id = "ijklmnop", + }, }; struct isds_list history_message_sent = { .next = &history_storage_set, diff --git a/test/simline/isds_ping.c b/test/simline/isds_ping.c index 07be765..e12db57 100644 --- a/test/simline/isds_ping.c +++ b/test/simline/isds_ping.c @@ -51,7 +51,7 @@ static int test_isds_ping(const isds_error error, struct isds_ctx *context) { } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/isds_resign_message.c b/test/simline/isds_resign_message.c index 810996b..f1ba6a8 100644 --- a/test/simline/isds_resign_message.c +++ b/test/simline/isds_resign_message.c @@ -161,7 +161,7 @@ static void test_error(const char *code, const isds_error expected_error, url = NULL; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/server.c b/test/simline/server.c index be7c02e..c5412ea 100644 --- a/test/simline/server.c +++ b/test/simline/server.c @@ -625,6 +625,8 @@ int server_out_of_order(const struct http_connection *connection, const void *server_arguments, const struct http_request *request) { const char *soap_mime_type = "text/xml"; /* SOAP/1.1 requires text/xml */ const char *fault = "Probíhá plánovaná údržbaOmlouváme se všem uživatelům datových schránek za dočasné omezení přístupu do systému datových schránek z důvodu plánované údržby systému. Děkujeme za pochopení."; + (void)server_arguments; + (void)request; http_send_response_503(connection, fault, strlen(fault), soap_mime_type); diff --git a/test/simline/server_cli.c b/test/simline/server_cli.c index d075c8e..4548f98 100644 --- a/test/simline/server_cli.c +++ b/test/simline/server_cli.c @@ -17,7 +17,9 @@ static _Bool terminate = 0; static int otp_type = 'n'; +/* Signal handler */ static void terminator(int signal) { + (void)signal; terminate = 1; } diff --git a/test/simline/service.c b/test/simline/service.c index 09bf0f6..eadabaa 100644 --- a/test/simline/service.c +++ b/test/simline/service.c @@ -40,8 +40,8 @@ struct service { const char *end_point; const xmlChar *name_space; const xmlChar *name; - http_error (*function) (const struct http_connection *, xmlDocPtr, - xmlXPathContextPtr, xmlNodePtr, xmlDocPtr, xmlNodePtr, + http_error (*function) ( + xmlXPathContextPtr, xmlNodePtr, const void *arguments); }; @@ -260,11 +260,13 @@ static http_error element_exists(const char **code, char **message, } if (xmlXPathNodeSetIsEmpty(result->nodesetval)) { xmlXPathFreeObject(result); + *code = "9999"; test_asprintf(message, "Element %s does not exist", element_name); return HTTP_ERROR_CLIENT; } else { if (!allow_multiple && result->nodesetval->nodeNr > 1) { xmlXPathFreeObject(result); + *code = "9999"; test_asprintf(message, "Multiple %s element", element_name); return HTTP_ERROR_CLIENT; } @@ -303,6 +305,7 @@ static http_error extract_string(const char **code, char **message, if (!xmlXPathNodeSetIsEmpty(result->nodesetval)) { if (result->nodesetval->nodeNr > 1) { xmlXPathFreeObject(result); + *code = "9999"; test_asprintf(message, "Multiple %s element", element_name); error = HTTP_ERROR_CLIENT; goto leave; @@ -619,10 +622,12 @@ static int datecmp(const struct tm *a, const struct tm *b) { /* Implement DummyOperation */ static http_error service_DummyOperation( - const struct http_connection *connection, const xmlDocPtr soap_request, - xmlXPathContextPtr xpath_ctx, xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { + (void)xpath_ctx; + (void)arguments; + return insert_isds_status(isds_response, 1, BAD_CAST "0000", BAD_CAST "Success", NULL); } @@ -632,10 +637,8 @@ static http_error service_DummyOperation( * It sends document from request back. * @arguments is pointer to struct arguments_DS_Dz_ResignISDSDocument */ static http_error service_ResignISDSDocument( - const struct http_connection *connection, - const xmlDocPtr soap_request, xmlXPathContextPtr xpath_ctx, - const xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { http_error error = HTTP_ERROR_SUCCESS; const char *code = "9999"; @@ -691,10 +694,9 @@ leave: /* Implement EraseMessage. * @arguments is pointer to struct arguments_DS_DsManage_ChangeISDSPassword */ -static http_error service_EraseMessage(const struct http_connection *connection, - const xmlDocPtr soap_request, xmlXPathContextPtr xpath_ctx, - const xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, +static http_error service_EraseMessage( + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { http_error error = HTTP_ERROR_SUCCESS; char *code = "9999", *message = NULL; @@ -827,10 +829,8 @@ leave: /* Implement DataBoxCreditInfo. * @arguments is pointer to struct arguments_DS_df_DataBoxCreditInfo */ static http_error service_DataBoxCreditInfo( - const struct http_connection *connection, - const xmlDocPtr soap_request, xmlXPathContextPtr xpath_ctx, - const xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { http_error error = HTTP_ERROR_SUCCESS; const char *code = "9999"; @@ -945,10 +945,8 @@ leave: /* Implement ISDSSearch2. * @arguments is pointer to struct arguments_DS_df_ISDSSearch2 */ static http_error service_ISDSSearch2( - const struct http_connection *connection, - const xmlDocPtr soap_request, xmlXPathContextPtr xpath_ctx, - const xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { http_error error = HTTP_ERROR_SUCCESS; const char *code = "9999"; @@ -1092,7 +1090,7 @@ static http_error check_passwd( const char special[] = "!#$%&()*+,-.:=?@[]_{}|~"; _Bool has_lower = 0, has_upper = 0, has_digit=0; - for (int i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) { if (NULL != strchr(lower, new_password[i])) has_lower = 1; else if (NULL != strchr(upper, new_password[i])) @@ -1130,7 +1128,7 @@ static http_error check_passwd( goto leave; } - for (int i = 0; i < length - 2; i++) { + for (size_t i = 0; i < length - 2; i++) { if (new_password[i] == new_password[i+1] && new_password[i] == new_password[i+2]) { *code = "1083"; @@ -1143,7 +1141,7 @@ static http_error check_passwd( { const char *forbidden_prefix[] = { "qwert", "asdgf", "12345" }; - for (int i = 0; i < sizeof(forbidden_prefix)/sizeof(*forbidden_prefix); + for (size_t i = 0; i < sizeof(forbidden_prefix)/sizeof(*forbidden_prefix); i++) { if (!strncmp(new_password, forbidden_prefix[i], strlen(forbidden_prefix[i]))) { @@ -1168,10 +1166,8 @@ leave: /* Implement ChangeISDSPassword. * @arguments is pointer to struct arguments_DS_DsManage_ChangeISDSPassword */ static http_error service_ChangeISDSPassword( - const struct http_connection *connection, - const xmlDocPtr soap_request, xmlXPathContextPtr xpath_ctx, - const xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { http_error error = HTTP_ERROR_SUCCESS; char *code = "9999", *message = NULL; @@ -1204,10 +1200,8 @@ leave: * @arguments is pointer to struct * arguments_asws_changePassword_ChangePasswordOTP */ static http_error service_ChangePasswordOTP( - const struct http_connection *connection, - const xmlDocPtr soap_request, xmlXPathContextPtr xpath_ctx, - const xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { http_error error = HTTP_ERROR_SUCCESS; char *code = "9999", *message = NULL; @@ -1257,14 +1251,13 @@ leave: /* Implement SendSMSCode. * @arguments is pointer to struct arguments_asws_changePassword_SendSMSCode */ static http_error service_SendSMSCode( - const struct http_connection *connection, - const xmlDocPtr soap_request, xmlXPathContextPtr xpath_ctx, - const xmlNodePtr isds_request, - xmlDocPtr soap_response, xmlNodePtr isds_response, + xmlXPathContextPtr xpath_ctx, + xmlNodePtr isds_response, const void *arguments) { const struct arguments_asws_changePassword_SendSMSCode *configuration = (const struct arguments_asws_changePassword_SendSMSCode *) arguments; + (void)xpath_ctx; if (NULL == configuration || NULL == configuration->status_code || NULL == configuration->status_message) { @@ -1503,7 +1496,7 @@ void soap(const struct http_connection *connection, xmlSetNs(isds_response, isds_ns); /* Dispatch request to service */ - for (int i = 0; i < sizeof(services)/sizeof(services[0]); i++) { + for (size_t i = 0; i < sizeof(services)/sizeof(services[0]); i++) { if (!strcmp(services[i].end_point, end_point) && !xmlStrcmp(services[i].name_space, isds_request->ns->href) && !xmlStrcmp(services[i].name, isds_request->name)) { @@ -1523,9 +1516,9 @@ void soap(const struct http_connection *connection, } } xpath_ctx->node = isds_request; - if (HTTP_ERROR_SERVER != services[i].function(connection, - request_doc, xpath_ctx, isds_request, - response_doc, isds_response, + if (HTTP_ERROR_SERVER != services[i].function( + xpath_ctx, + isds_response, service->arguments)) { service_passed = 1; } else { diff --git a/test/simline/totp_authentication.c b/test/simline/totp_authentication.c index da7bea1..47d9638 100644 --- a/test/simline/totp_authentication.c +++ b/test/simline/totp_authentication.c @@ -67,7 +67,7 @@ static int test_ping(const isds_error error, struct isds_ctx *context) { PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; diff --git a/test/simline/totp_isds_change_password.c b/test/simline/totp_isds_change_password.c index faa8496..525678c 100644 --- a/test/simline/totp_isds_change_password.c +++ b/test/simline/totp_isds_change_password.c @@ -64,7 +64,7 @@ static int test_isds_change_password(const isds_error error, PASS_TEST; } -int main(int argc, char **argv) { +int main(void) { int error; pid_t server_process; struct isds_ctx *context = NULL; -- 2.11.4.GIT