diff options
author | jsing <> | 2014-06-10 15:20:40 +0000 |
---|---|---|
committer | jsing <> | 2014-06-10 15:20:40 +0000 |
commit | 1f0ada29dbbd22c18c51187561c2eb01d2a776b2 (patch) | |
tree | 26b9352fb9a5ac6c506e8003ffd77006cf098bbb /src/lib/libcrypto/engine/eng_init.c | |
parent | 3d34b57814cfdc90c98c015ae0dbd3c1862c83cd (diff) | |
download | openbsd-1f0ada29dbbd22c18c51187561c2eb01d2a776b2.tar.gz openbsd-1f0ada29dbbd22c18c51187561c2eb01d2a776b2.tar.bz2 openbsd-1f0ada29dbbd22c18c51187561c2eb01d2a776b2.zip |
KNF.
Diffstat (limited to 'src/lib/libcrypto/engine/eng_init.c')
-rw-r--r-- | src/lib/libcrypto/engine/eng_init.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/lib/libcrypto/engine/eng_init.c b/src/lib/libcrypto/engine/eng_init.c index 870c456668..540f8957ca 100644 --- a/src/lib/libcrypto/engine/eng_init.c +++ b/src/lib/libcrypto/engine/eng_init.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * are met: | 7 | * are met: |
8 | * | 8 | * |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * | 11 | * |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in | 13 | * notice, this list of conditions and the following disclaimer in |
@@ -57,30 +57,31 @@ | |||
57 | 57 | ||
58 | /* Initialise a engine type for use (or up its functional reference count | 58 | /* Initialise a engine type for use (or up its functional reference count |
59 | * if it's already in use). This version is only used internally. */ | 59 | * if it's already in use). This version is only used internally. */ |
60 | int engine_unlocked_init(ENGINE *e) | 60 | int |
61 | { | 61 | engine_unlocked_init(ENGINE *e) |
62 | { | ||
62 | int to_return = 1; | 63 | int to_return = 1; |
63 | 64 | ||
64 | if((e->funct_ref == 0) && e->init) | 65 | if ((e->funct_ref == 0) && e->init) |
65 | /* This is the first functional reference and the engine | 66 | /* This is the first functional reference and the engine |
66 | * requires initialisation so we do it now. */ | 67 | * requires initialisation so we do it now. */ |
67 | to_return = e->init(e); | 68 | to_return = e->init(e); |
68 | if(to_return) | 69 | if (to_return) { |
69 | { | ||
70 | /* OK, we return a functional reference which is also a | 70 | /* OK, we return a functional reference which is also a |
71 | * structural reference. */ | 71 | * structural reference. */ |
72 | e->struct_ref++; | 72 | e->struct_ref++; |
73 | e->funct_ref++; | 73 | e->funct_ref++; |
74 | engine_ref_debug(e, 0, 1) | 74 | engine_ref_debug(e, 0, 1) |
75 | engine_ref_debug(e, 1, 1) | 75 | engine_ref_debug(e, 1, 1) |
76 | } | ||
77 | return to_return; | ||
78 | } | 76 | } |
77 | return to_return; | ||
78 | } | ||
79 | 79 | ||
80 | /* Free a functional reference to a engine type. This version is only used | 80 | /* Free a functional reference to a engine type. This version is only used |
81 | * internally. */ | 81 | * internally. */ |
82 | int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers) | 82 | int |
83 | { | 83 | engine_unlocked_finish(ENGINE *e, int unlock_for_handlers) |
84 | { | ||
84 | int to_return = 1; | 85 | int to_return = 1; |
85 | 86 | ||
86 | /* Reduce the functional reference count here so if it's the terminating | 87 | /* Reduce the functional reference count here so if it's the terminating |
@@ -91,58 +92,57 @@ int engine_unlocked_finish(ENGINE *e, int unlock_for_handlers) | |||
91 | * 2 to 0 without either calling finish(). */ | 92 | * 2 to 0 without either calling finish(). */ |
92 | e->funct_ref--; | 93 | e->funct_ref--; |
93 | engine_ref_debug(e, 1, -1); | 94 | engine_ref_debug(e, 1, -1); |
94 | if((e->funct_ref == 0) && e->finish) | 95 | if ((e->funct_ref == 0) && e->finish) { |
95 | { | 96 | if (unlock_for_handlers) |
96 | if(unlock_for_handlers) | ||
97 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 97 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
98 | to_return = e->finish(e); | 98 | to_return = e->finish(e); |
99 | if(unlock_for_handlers) | 99 | if (unlock_for_handlers) |
100 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 100 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
101 | if(!to_return) | 101 | if (!to_return) |
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
104 | 104 | ||
105 | /* Release the structural reference too */ | 105 | /* Release the structural reference too */ |
106 | if(!engine_free_util(e, 0)) | 106 | if (!engine_free_util(e, 0)) { |
107 | { | 107 | ENGINEerr(ENGINE_F_ENGINE_UNLOCKED_FINISH, |
108 | ENGINEerr(ENGINE_F_ENGINE_UNLOCKED_FINISH,ENGINE_R_FINISH_FAILED); | 108 | ENGINE_R_FINISH_FAILED); |
109 | return 0; | 109 | return 0; |
110 | } | ||
111 | return to_return; | ||
112 | } | 110 | } |
111 | return to_return; | ||
112 | } | ||
113 | 113 | ||
114 | /* The API (locked) version of "init" */ | 114 | /* The API (locked) version of "init" */ |
115 | int ENGINE_init(ENGINE *e) | 115 | int |
116 | { | 116 | ENGINE_init(ENGINE *e) |
117 | { | ||
117 | int ret; | 118 | int ret; |
118 | if(e == NULL) | 119 | |
119 | { | 120 | if (e == NULL) { |
120 | ENGINEerr(ENGINE_F_ENGINE_INIT,ERR_R_PASSED_NULL_PARAMETER); | 121 | ENGINEerr(ENGINE_F_ENGINE_INIT, ERR_R_PASSED_NULL_PARAMETER); |
121 | return 0; | 122 | return 0; |
122 | } | 123 | } |
123 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 124 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
124 | ret = engine_unlocked_init(e); | 125 | ret = engine_unlocked_init(e); |
125 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 126 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
126 | return ret; | 127 | return ret; |
127 | } | 128 | } |
128 | 129 | ||
129 | /* The API (locked) version of "finish" */ | 130 | /* The API (locked) version of "finish" */ |
130 | int ENGINE_finish(ENGINE *e) | 131 | int |
131 | { | 132 | ENGINE_finish(ENGINE *e) |
133 | { | ||
132 | int to_return = 1; | 134 | int to_return = 1; |
133 | 135 | ||
134 | if(e == NULL) | 136 | if (e == NULL) { |
135 | { | 137 | ENGINEerr(ENGINE_F_ENGINE_FINISH, ERR_R_PASSED_NULL_PARAMETER); |
136 | ENGINEerr(ENGINE_F_ENGINE_FINISH,ERR_R_PASSED_NULL_PARAMETER); | ||
137 | return 0; | 138 | return 0; |
138 | } | 139 | } |
139 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); | 140 | CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); |
140 | to_return = engine_unlocked_finish(e, 1); | 141 | to_return = engine_unlocked_finish(e, 1); |
141 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); | 142 | CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE); |
142 | if(!to_return) | 143 | if (!to_return) { |
143 | { | 144 | ENGINEerr(ENGINE_F_ENGINE_FINISH, ENGINE_R_FINISH_FAILED); |
144 | ENGINEerr(ENGINE_F_ENGINE_FINISH,ENGINE_R_FINISH_FAILED); | ||
145 | return 0; | 145 | return 0; |
146 | } | ||
147 | return to_return; | ||
148 | } | 146 | } |
147 | return to_return; | ||
148 | } | ||