@@ -133,7 +133,7 @@ static const char *test_fseek_ftell(void *arg)
133133 }
134134
135135 ret = fread (buf , 2 , 1 , fp );
136- if (ret != 1 || strncmp (buf , "he" , 2 ) != 0 )
136+ if (ret != 1 || memcmp (buf , "he" , 2 ) != 0 )
137137 {
138138 error = "failed to read first two bytes" ;
139139 goto failed ;
@@ -149,7 +149,7 @@ static const char *test_fseek_ftell(void *arg)
149149 }
150150
151151 ret = fread (buf , 2 , 1 , fp );
152- if (ret != 1 || strncmp (buf , "o " , 2 ) != 0 )
152+ if (ret != 1 || memcmp (buf , "o " , 2 ) != 0 )
153153 {
154154 error = "error reading from test file" ;
155155 goto failed ;
@@ -165,7 +165,7 @@ static const char *test_fseek_ftell(void *arg)
165165 }
166166
167167 ret = fread (buf , 2 , 1 , fp );
168- if (ret != 1 || strncmp (buf , "o " , 2 ) != 0 )
168+ if (ret != 1 || memcmp (buf , "o " , 2 ) != 0 )
169169 {
170170 error = "error reading from test file" ;
171171 goto failed ;
@@ -203,23 +203,23 @@ static const char *test_fread(void *arg)
203203
204204 /* test of reading one chunk */
205205 ret = fread (buf , 3 , 1 , fp );
206- if (ret != 1 || strncmp (buf , "hel" , 3 ) != 0 )
206+ if (ret != 1 || memcmp (buf , "hel" , 3 ) != 0 )
207207 {
208208 error = "failed to read one block" ;
209209 goto failed ;
210210 }
211211
212212 /* three chunks */
213213 ret = fread (buf , 2 , 3 , fp );
214- if (ret != 3 || strncmp (buf , "lo wor" , 6 ) != 0 )
214+ if (ret != 3 || memcmp (buf , "lo wor" , 6 ) != 0 )
215215 {
216216 error = "failed to read three blocks" ;
217217 goto failed ;
218218 }
219219
220220 /* until end of file */
221221 ret = fread (buf , 1 , sizeof (buf ), fp );
222- if (ret < 2 || strncmp (buf , "ld" , 2 ) != 0 )
222+ if (ret < 2 || memcmp (buf , "ld" , 2 ) != 0 )
223223 {
224224 error = "failed to read until eof" ;
225225 goto failed ;
@@ -265,7 +265,7 @@ static const char *test_fwrite(void *arg)
265265
266266 fseek (fp , 0 , SEEK_SET );
267267 ret = fread (buf2 , 2 , 1 , fp );
268- if (ret != 1 || strncmp (buf2 , "he" , 2 ) != 0 )
268+ if (ret != 1 || memcmp (buf2 , "he" , 2 ) != 0 )
269269 {
270270 fclose (fp );
271271 printf ("buf2 = %s ret = %d\n" , buf2 , ret );
@@ -281,7 +281,7 @@ static const char *test_fwrite(void *arg)
281281
282282 fseek (fp , 0 , SEEK_SET );
283283 ret = fread (buf2 , 1 , sizeof (buf2 ), fp );
284- if (ret != 13 || strncmp (buf2 , "hehello world" , 13 ))
284+ if (ret != 13 || memcmp (buf2 , "hehello world" , 13 ))
285285 {
286286 fclose (fp );
287287 return "failed to write rest of file" ;
0 commit comments