Skip to content

Commit 4febd10

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#1364 from diffblue/phread-create-fix
pthread_create arguments null/nonnull fix
2 parents 8782103 + 3ddd377 commit 4febd10

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

src/ansi-c/library/pthread_lib.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -523,22 +523,19 @@ extern __CPROVER_thread_local unsigned long __CPROVER_thread_id;
523523
extern unsigned long __CPROVER_next_thread_id;
524524

525525
inline int pthread_create(
526-
pthread_t *thread,
527-
const pthread_attr_t *attr,
528-
void * (*start_routine)(void *),
529-
void *arg)
526+
pthread_t *thread, // must not be null
527+
const pthread_attr_t *attr, // may be null
528+
void * (*start_routine)(void *), // must not be null
529+
void *arg) // may be null
530530
{
531531
__CPROVER_HIDE:;
532532
unsigned long this_thread_id;
533533
__CPROVER_atomic_begin();
534534
this_thread_id=++__CPROVER_next_thread_id;
535535
__CPROVER_atomic_end();
536536

537-
if(thread)
538-
{
539-
// pthread_t is a pointer type on some systems
540-
*thread=(pthread_t)this_thread_id;
541-
}
537+
// pthread_t is a pointer type on some systems
538+
*thread=(pthread_t)this_thread_id;
542539

543540
#ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
544541
__CPROVER_set_must(thread, "pthread-id");

src/ansi-c/library/string.c

-24
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)