Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/pr94362-1.c

raw
1 /* { dg-additional-options "-Wno-analyzer-too-complex" } */
2 /* TODO: remove the need for -Wno-analyzer-too-complex. */
3
4 typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
5 typedef struct engine_st ENGINE;
6 struct stack_st_EVP_PKEY_ASN1_METHOD;
7 struct evp_pkey_asn1_method_st {
8 unsigned long pkey_flags;
9 };
10
11 const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe,
12 const char *str, int len);
13 extern int
14 sk_EVP_PKEY_ASN1_METHOD_num(const struct stack_st_EVP_PKEY_ASN1_METHOD *sk);
15 extern const EVP_PKEY_ASN1_METHOD *
16 sk_EVP_PKEY_ASN1_METHOD_value(const struct stack_st_EVP_PKEY_ASN1_METHOD *sk,
17 int idx);
18 extern const EVP_PKEY_ASN1_METHOD hmac_asn1_meth;
19 static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {&hmac_asn1_meth};
20 static struct stack_st_EVP_PKEY_ASN1_METHOD *app_methods = (struct stack_st_EVP_PKEY_ASN1_METHOD *) ((void *)0);
21
22 int EVP_PKEY_asn1_get_count(void) {
23 int num = (sizeof(standard_methods) / sizeof((standard_methods)[0]));
24 if (app_methods)
25 num += sk_EVP_PKEY_ASN1_METHOD_num(app_methods);
26 return num;
27 }
28
29 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx) {
30 int num = (sizeof(standard_methods) / sizeof((standard_methods)[0]));
31 if (idx < 0)
32 return (const EVP_PKEY_ASN1_METHOD *) ((void *)0);
33 if (idx < num)
34 return standard_methods[idx];
35 idx -= num;
36 return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
37 }
38
39 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, const char *str,
40 int len) {
41 int i;
42 const EVP_PKEY_ASN1_METHOD *ameth = (const EVP_PKEY_ASN1_METHOD *) ((void *)0);
43
44 if (pe) {
45 ENGINE *e;
46 ameth = ENGINE_pkey_asn1_find_str(&e, str, len);
47 if (ameth) {
48 *pe = e;
49 return ameth;
50 }
51 *pe = (ENGINE *) ((void *)0);
52 }
53 for (i = EVP_PKEY_asn1_get_count(); i-- > 0;) {
54 ameth = EVP_PKEY_asn1_get0(i);
55 if (ameth->pkey_flags & 0x1)
56 continue;
57 return ameth;
58 }
59 return (const EVP_PKEY_ASN1_METHOD *) ((void *)0);
60 }