diff options
author | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-07-11 21:26:29 +0200 |
---|---|---|
committer | Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> | 2021-07-19 12:53:25 +0200 |
commit | 487089b9cbe557d6c8686ad5dae56b4997f9bd41 (patch) | |
tree | 15a19a103448020ed46c8394ddbddd2b8ee6f5d9 | |
parent | 418f64b18cc7acce8797a54ff0873f1bb2196845 (diff) | |
download | neard-487089b9cbe557d6c8686ad5dae56b4997f9bd41.tar.gz |
unit: use proper format for integers (-Wformat)
Properly print signed and unsigned integers. This fixes warnings like:
unit/test-ndef-parse.c: In function ‘test_ndef_single_sp’:
unit/test-ndef-parse.c:318:33: error: field precision specifier ‘.*’ expects argument of type ‘int’, but argument 2 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
318 | g_print("NDEF SP URI field: %.*s\n", uri->field_length,
| ~~^~ ~~~~~~~~~~~~~~~~~
| | |
| int uint32_t {aka unsigned int}
unit/test-snep-read.c: In function ‘test_snep_dummy_req_put’:
unit/test-snep-read.c:42:12: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘uint32_t’ {aka ‘unsigned int’} [-Werror=format=]
42 | g_printf("[SNEP unit] " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~~~~
......
118 | frag_cnt, fragment->nfc_data_length,
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| uint32_t {aka unsigned int}
unit/test-snep-read.c: In function ‘test_snep_read_verify_resp’:
unit/test-snep-read.c:42:12: error: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘int’ [-Werror=format=]
42 | g_printf("[SNEP unit] " fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~~~~
......
454 | resp->response, exp_resp_code);
| ~~~~~~~~~~~~~
| |
| int
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
-rw-r--r-- | unit/test-ndef-parse.c | 8 | ||||
-rw-r--r-- | unit/test-snep-read.c | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/unit/test-ndef-parse.c b/unit/test-ndef-parse.c index f8b3b7b..24f7d2f 100644 --- a/unit/test-ndef-parse.c +++ b/unit/test-ndef-parse.c @@ -302,8 +302,8 @@ static void test_ndef_single_sp(void) uri->field_length) == 0); if (g_test_verbose()) - g_print("NDEF SP URI field: %.*s\n", uri->field_length, - (char *) uri->field); + g_print("NDEF SP URI field: %.*s\n", (int)uri->field_length, + (char *) uri->field); g_free(uri->field); g_free(uri); @@ -346,8 +346,8 @@ static void test_ndef_title_sp(void) uri->field_length) == 0); if (g_test_verbose()) - g_print("NDEF SP URI field: %.*s\n", uri->field_length, - (char *) uri->field); + g_print("NDEF SP URI field: %.*s\n", (int)uri->field_length, + (char *) uri->field); g_assert_cmpstr(text->data, ==, "Intel"); g_assert_cmpstr(text->encoding, ==, "UTF-8"); diff --git a/unit/test-snep-read.c b/unit/test-snep-read.c index 78db58b..414b801 100644 --- a/unit/test-snep-read.c +++ b/unit/test-snep-read.c @@ -114,7 +114,7 @@ static bool test_snep_dummy_req_put(int fd, void *data) static int frag_cnt; struct p2p_snep_data *fragment = test_fragments->data; - TEST_SNEP_LOG("\tdummy_req_put frag=%d, len=%d, current=%d\n", + TEST_SNEP_LOG("\tdummy_req_put frag=%d, len=%u, current=%u\n", frag_cnt, fragment->nfc_data_length, fragment->nfc_data_current_length); test_fragments = g_slist_remove(test_fragments, fragment); @@ -437,7 +437,7 @@ static void test_snep_read_no_response(void) * @param[in] exp_resp_info_len Expected response info length * @param[in] exp_resp_info Expected response info */ -static void test_snep_read_verify_resp(int exp_resp_code, +static void test_snep_read_verify_resp(uint8_t exp_resp_code, uint32_t exp_resp_info_len, uint8_t *exp_resp_info) { struct p2p_snep_resp_frame *resp; @@ -467,7 +467,7 @@ static void test_snep_read_verify_resp(int exp_resp_code, * * @param[in] exp_resp_code Expected response code */ -static void test_snep_read_verify_resp_code(int exp_resp_code) +static void test_snep_read_verify_resp_code(uint8_t exp_resp_code) { test_snep_read_verify_resp(exp_resp_code, 0, NULL); } |