Skip to content

Commit 3ddd377

Browse files
author
Daniel Kroening
committed
clean-out ill-modeled optimization in string comparisons
1 parent fe60e60 commit 3ddd377

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

src/ansi-c/library/string.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,6 @@ inline char *strncat(char *dst, const char *src, size_t n)
298298
inline int strcmp(const char *s1, const char *s2)
299299
{
300300
__CPROVER_HIDE:;
301-
#if !defined(__linux__) || defined(__GLIBC__)
302-
if(s1!=0 && s1==s2) return 0;
303-
#else
304-
// musl guarantees non-null of s1
305-
if(s1==s2) return 0;
306-
#endif
307301
#ifdef __CPROVER_STRING_ABSTRACTION
308302
int retval;
309303
__CPROVER_assert(__CPROVER_is_zero_string(s1), "strcmp zero-termination of 1st argument");
@@ -345,12 +339,6 @@ inline int strcmp(const char *s1, const char *s2)
345339
inline int strcasecmp(const char *s1, const char *s2)
346340
{
347341
__CPROVER_HIDE:;
348-
#if !defined(__linux__) || defined(__GLIBC__)
349-
if(s1!=0 && s1==s2) return 0;
350-
#else
351-
// musl guarantees non-null of s1
352-
if(s1==s2) return 0;
353-
#endif
354342
#ifdef __CPROVER_STRING_ABSTRACTION
355343
int retval;
356344
__CPROVER_assert(__CPROVER_is_zero_string(s1), "strcasecmp zero-termination of 1st argument");
@@ -395,12 +383,6 @@ inline int strcasecmp(const char *s1, const char *s2)
395383
inline int strncmp(const char *s1, const char *s2, size_t n)
396384
{
397385
__CPROVER_HIDE:;
398-
#if !defined(__linux__) || defined(__GLIBC__)
399-
if(s1!=0 && s1==s2) return 0;
400-
#else
401-
// musl guarantees non-null of s1
402-
if(s1==s2) return 0;
403-
#endif
404386
#ifdef __CPROVER_STRING_ABSTRACTION
405387
__CPROVER_assert(__CPROVER_is_zero_string(s1) || __CPROVER_buffer_size(s1)>=n, "strncmp zero-termination of 1st argument");
406388
__CPROVER_assert(__CPROVER_is_zero_string(s2) || __CPROVER_buffer_size(s2)>=n, "strncmp zero-termination of 2nd argument");
@@ -439,12 +421,6 @@ inline int strncmp(const char *s1, const char *s2, size_t n)
439421
inline int strncasecmp(const char *s1, const char *s2, size_t n)
440422
{
441423
__CPROVER_HIDE:;
442-
#if !defined(__linux__) || defined(__GLIBC__)
443-
if(s1!=0 && s1==s2) return 0;
444-
#else
445-
// musl guarantees non-null of s1
446-
if(s1==s2) return 0;
447-
#endif
448424
#ifdef __CPROVER_STRING_ABSTRACTION
449425
int retval;
450426
__CPROVER_assert(__CPROVER_is_zero_string(s1), "strncasecmp zero-termination of 1st argument");

0 commit comments

Comments
 (0)