diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c index 975515db59727a6cee0d388b4626d4d1014bef2d..bb3a0a7dfcafa7a32db1d2a6d10507fe46ad04f6 100644 --- a/crypto/stack/stack.c +++ b/crypto/stack/stack.c @@ -226,9 +226,6 @@ OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n) int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n) { - if (st == NULL) - return 0; - if (n < 0) return 1; return sk_reserve(st, n, 1); @@ -236,7 +233,7 @@ int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n) int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc) { - if (st == NULL || st->num == max_nodes) + if (st->num == max_nodes) return 0; if (!sk_reserve(st, 1, 0)) @@ -278,7 +275,7 @@ void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p) void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc) { - if (st == NULL || loc < 0 || loc >= st->num) + if (loc < 0 || loc >= st->num) return NULL; return internal_delete(st, loc); @@ -290,7 +287,7 @@ static int internal_find(OPENSSL_STACK *st, const void *data, const void *r; int i; - if (st == NULL || st->num == 0) + if (st->num == 0) return -1; if (st->comp == NULL) { @@ -325,8 +322,6 @@ int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data) int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data) { - if (st == NULL) - return -1; return OPENSSL_sk_insert(st, data, st->num); } @@ -351,7 +346,7 @@ void *OPENSSL_sk_pop(OPENSSL_STACK *st) void OPENSSL_sk_zero(OPENSSL_STACK *st) { - if (st == NULL || st->num == 0) + if (st->num == 0) return; memset(st->data, 0, sizeof(*st->data) * st->num); st->num = 0; @@ -384,14 +379,14 @@ int OPENSSL_sk_num(const OPENSSL_STACK *st) void *OPENSSL_sk_value(const OPENSSL_STACK *st, int i) { - if (st == NULL || i < 0 || i >= st->num) + if (i < 0 || i >= st->num) return NULL; return (void *)st->data[i]; } void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data) { - if (st == NULL || i < 0 || i >= st->num) + if (i < 0 || i >= st->num) return NULL; st->data[i] = data; st->sorted = 0; @@ -400,7 +395,7 @@ void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data) void OPENSSL_sk_sort(OPENSSL_STACK *st) { - if (st != NULL && !st->sorted && st->comp != NULL) { + if (!st->sorted && st->comp != NULL) { if (st->num > 1) qsort(st->data, st->num, sizeof(void *), st->comp); st->sorted = 1; /* empty or single-element stack is considered sorted */ @@ -409,5 +404,5 @@ void OPENSSL_sk_sort(OPENSSL_STACK *st) int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st) { - return st == NULL ? 1 : st->sorted; + return st->sorted; }