From c85594ce8b95fe75fd1043bd964b7fb21afbb49e Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Wed, 19 Sep 2012 15:07:36 +0200 Subject: [PATCH] correct return values, 1 for success and 0 for fail --- tests/test_ndef_construction.c | 10 +++++----- ykpers.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_ndef_construction.c b/tests/test_ndef_construction.c index 60ff45d..dce4dda 100644 --- a/tests/test_ndef_construction.c +++ b/tests/test_ndef_construction.c @@ -41,7 +41,7 @@ void _test_https_uri() memset(&ndef, 0, sizeof(YKNDEF)); char uri[] = "https://example.com/foo"; int rc = ykp_construct_ndef_uri(&ndef, uri); - assert(rc == 0); + assert(rc == 1); assert(ndef.type == 'U'); assert(ndef.data[0] == 0x04); assert(strncmp(ndef.data + 1, "example.com/foo", 15) == 0); @@ -54,7 +54,7 @@ void _test_to_long_uri() memset(&ndef, 0, sizeof(YKNDEF)); char uri[] = "https://example.example.example.example.com/foo/kaka/bar/blahonga"; int rc = ykp_construct_ndef_uri(&ndef, uri); - assert(rc == 1); + assert(rc == 0); assert(ndef.type == 0); assert(ndef.len == 0); } @@ -65,7 +65,7 @@ void _test_exact_uri() memset(&ndef, 0, sizeof(YKNDEF)); char uri[] = "https://www.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; int rc = ykp_construct_ndef_uri(&ndef, uri); - assert(rc == 0); + assert(rc == 1); assert(ndef.type == 'U'); assert(ndef.data[0] == 0x02); assert(strncmp(ndef.data + 1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", NDEF_DATA_SIZE -1) == 0); @@ -78,7 +78,7 @@ void _test_exact_text() memset(&ndef, 0, sizeof(YKNDEF)); char text[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; int rc = ykp_construct_ndef_text(&ndef, text, "en", false); - assert(rc == 0); + assert(rc == 1); assert(ndef.type == 'T'); assert(ndef.data[0] == 2); assert(strncmp(ndef.data + 1, "en", 2) == 0); @@ -93,7 +93,7 @@ void _test_other_lang_text() char text[] = "aaaaaaaaaaaaaaa"; size_t text_len = strlen(text); int rc = ykp_construct_ndef_text(&ndef, text, "sv-SE", true); - assert(rc == 0); + assert(rc == 1); assert(ndef.type == 'T'); assert(ndef.data[0] == (0x80 & 5)); assert(strncmp(ndef.data + 1, "sv-SE", 5) == 0); diff --git a/ykpers.c b/ykpers.c index 432ca75..f8d449d 100644 --- a/ykpers.c +++ b/ykpers.c @@ -387,7 +387,7 @@ int ykp_construct_ndef_uri(YKNDEF *ndef, const char *uri) data_length = strlen(uri); if(data_length + 1 > NDEF_DATA_SIZE) { ykp_errno = YKP_EINVAL; - return 1; + return 0; } if(indx > num_identifiers) { ndef->data[0] = 0; @@ -397,7 +397,7 @@ int ykp_construct_ndef_uri(YKNDEF *ndef, const char *uri) memcpy(ndef->data + 1, uri, data_length); ndef->len = data_length + 1; ndef->type = 'U'; - return 0; + return 1; } /* Fill in the data and len parts of the YKNDEF struct based on supplied text. */ @@ -411,14 +411,14 @@ int ykp_construct_ndef_text(YKNDEF *ndef, const char *text, const char *lang, bo } if((data_length + lang_length + 1) > NDEF_DATA_SIZE) { ykp_errno = YKP_EINVAL; - return 1; + return 0; } ndef->data[0] = status; memcpy(ndef->data + 1, lang, lang_length); memcpy(ndef->data + lang_length + 1, text, data_length); ndef->len = data_length + lang_length + 1; ndef->type = 'T'; - return 0; + return 1; } static bool vcheck_all(const YKP_CONFIG *cfg) -- 2.39.5