diff options
author | jsing <> | 2016-11-04 10:54:25 +0000 |
---|---|---|
committer | jsing <> | 2016-11-04 10:54:25 +0000 |
commit | 252facfdd0694e48464592726a507540bfeee459 (patch) | |
tree | 416da2e19d514f15237a7331da7442c23cc470ed /src/lib | |
parent | b8bebcaa974c0742248e7d9941cfb70a404ea46b (diff) | |
download | openbsd-252facfdd0694e48464592726a507540bfeee459.tar.gz openbsd-252facfdd0694e48464592726a507540bfeee459.tar.bz2 openbsd-252facfdd0694e48464592726a507540bfeee459.zip |
There's not much point having three static functions that do a cast and
assign a pointer, when we can just inline the three and do one cast
followed by three pointer assignments.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libtls/tls_bio_cb.c | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/src/lib/libtls/tls_bio_cb.c b/src/lib/libtls/tls_bio_cb.c index b85c1c606a..a5ab206c62 100644 --- a/src/lib/libtls/tls_bio_cb.c +++ b/src/lib/libtls/tls_bio_cb.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_bio_cb.c,v 1.8 2016/11/04 10:51:35 jsing Exp $ */ | 1 | /* $OpenBSD: tls_bio_cb.c,v 1.9 2016/11/04 10:54:25 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2016 Tobias Pape <tobias@netshed.de> | 3 | * Copyright (c) 2016 Tobias Pape <tobias@netshed.de> |
4 | * | 4 | * |
@@ -55,35 +55,6 @@ bio_s_cb(void) | |||
55 | } | 55 | } |
56 | 56 | ||
57 | static int | 57 | static int |
58 | bio_set_write_cb(BIO *bi, | ||
59 | int (*write_cb)(BIO *h, const char *buf, int num, void *cb_arg)) | ||
60 | { | ||
61 | struct bio_cb_st *b; | ||
62 | b = (struct bio_cb_st *)bi->ptr; | ||
63 | b->write_cb = write_cb; | ||
64 | return (0); | ||
65 | } | ||
66 | |||
67 | static int | ||
68 | bio_set_read_cb(BIO *bi, | ||
69 | int (*read_cb)(BIO *h, char *buf, int size, void *cb_arg)) | ||
70 | { | ||
71 | struct bio_cb_st *b; | ||
72 | b = (struct bio_cb_st *)bi->ptr; | ||
73 | b->read_cb = read_cb; | ||
74 | return (0); | ||
75 | } | ||
76 | |||
77 | static int | ||
78 | bio_set_cb_arg(BIO *bi, void *cb_arg) | ||
79 | { | ||
80 | struct bio_cb_st *b; | ||
81 | b = (struct bio_cb_st *)bi->ptr; | ||
82 | b->cb_arg = cb_arg; | ||
83 | return (0); | ||
84 | } | ||
85 | |||
86 | static int | ||
87 | bio_cb_new(BIO *bi) | 58 | bio_cb_new(BIO *bi) |
88 | { | 59 | { |
89 | struct bio_cb_st *bcb; | 60 | struct bio_cb_st *bcb; |
@@ -203,6 +174,7 @@ tls_bio_read_cb(BIO *h, char *buf, int size, void *cb_arg) | |||
203 | static BIO * | 174 | static BIO * |
204 | tls_get_new_cb_bio(struct tls *ctx) | 175 | tls_get_new_cb_bio(struct tls *ctx) |
205 | { | 176 | { |
177 | struct bio_cb_st *b; | ||
206 | BIO *bcb; | 178 | BIO *bcb; |
207 | if (ctx->read_cb == NULL || ctx->write_cb == NULL) | 179 | if (ctx->read_cb == NULL || ctx->write_cb == NULL) |
208 | tls_set_errorx(ctx, "no callbacks registered"); | 180 | tls_set_errorx(ctx, "no callbacks registered"); |
@@ -213,9 +185,10 @@ tls_get_new_cb_bio(struct tls *ctx) | |||
213 | return (NULL); | 185 | return (NULL); |
214 | } | 186 | } |
215 | 187 | ||
216 | bio_set_write_cb(bcb, tls_bio_write_cb); | 188 | b = (struct bio_cb_st *)bcb->ptr; |
217 | bio_set_read_cb(bcb, tls_bio_read_cb); | 189 | b->read_cb = tls_bio_read_cb; |
218 | bio_set_cb_arg(bcb, ctx); | 190 | b->write_cb = tls_bio_write_cb; |
191 | b->cb_arg = ctx; | ||
219 | 192 | ||
220 | return (bcb); | 193 | return (bcb); |
221 | } | 194 | } |