Skip to content

Commit 5b0a7f4

Browse files
author
Tomas Winkler
committed
safestringlib: unittests: cast pointer to intptr_t instead to int
Cast pointer intptr_t instead of int warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
1 parent 34d3959 commit 5b0a7f4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

unittests/test_strcasestr_s.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ int test_strcasestr_s()
131131

132132
/* compare to legacy */
133133
std_sub = strcasestr(str1, str2);
134-
if ((int)sub != (int)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
134+
if ((intptr_t)sub != (intptr_t)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
135135
printf("%s %u Error strcasestr_s() does not have same return as strcasestr() when str1 & str2 are zero length strings. rc=%u \n",
136136
__FUNCTION__, __LINE__, rc);
137137
printf("str1:[%s]\n", str1);
@@ -158,7 +158,7 @@ int test_strcasestr_s()
158158

159159
/* compare to legacy */
160160
std_sub = strcasestr(str1, str2);
161-
if ((int)sub != (int)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
161+
if ((intptr_t)sub != (intptr_t)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
162162
printf("%s %u Error strcasestr_s() does not have same return value as strcasestr() when str2 is zero length string. rc=%u \n",
163163
__FUNCTION__, __LINE__, rc);
164164
printf("str1:[%s]\n", str1);
@@ -186,7 +186,7 @@ int test_strcasestr_s()
186186

187187
/* compare to legacy */
188188
std_sub = strcasestr(str1, str2);
189-
if ((int)sub != (int)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
189+
if ((intptr_t)sub != (intptr_t)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
190190
printf("%s %u Error strcasestr_s() does not have same return value as strcasestr() when str2 is zero length string. rc=%u \n",
191191
__FUNCTION__, __LINE__, rc);
192192
printf("str1:[%s]\n", str1);
@@ -268,7 +268,7 @@ int test_strcasestr_s()
268268

269269
/* compare to legacy */
270270
std_sub = strcasestr(str1, str2);
271-
if ((int)sub != (int)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
271+
if ((intptr_t)sub != (intptr_t)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
272272
printf("%s %u Error strcasestr_s() does not have same return value as strcasestr() when str2 is substring of the end of str1. rc=%u \n",
273273
__FUNCTION__, __LINE__, rc);
274274
printf("str1:[%s]\n", str1);
@@ -299,7 +299,7 @@ int test_strcasestr_s()
299299

300300
/* compare to legacy */
301301
std_sub = strcasestr(str1, str2);
302-
if ((int)sub != (int)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
302+
if ((intptr_t)sub != (intptr_t)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
303303
printf("%s %u Error strcasestr_s() does not have same return value as strcasestr() when str2 is substring of middle of str1. rc=%u \n",
304304
__FUNCTION__, __LINE__, rc);
305305
printf("str1:[%s]\n", str1);
@@ -424,7 +424,7 @@ int test_strcasestr_s()
424424

425425
/* compare to legacy */
426426
std_sub = strcasestr(str1, str2);
427-
if ((int)sub != (int)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
427+
if ((intptr_t)sub != (intptr_t)std_sub) { // comparison to handle 32-bit library return and 64-bit library return
428428
printf("%s %u Error rc=%u \n",
429429
__FUNCTION__, __LINE__, rc);
430430
}

0 commit comments

Comments
 (0)