From 45bb7f0ae87ddf787dd06d515db9afb04a74bf6c Mon Sep 17 00:00:00 2001 From: miod <> Date: Sun, 27 Apr 2014 20:26:49 +0000 Subject: Use C99 initializers for the various FOO_METHOD structs. More readable, and avoid unreadable/unmaintainable constructs like that: const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { EVP_PKEY_CMAC, EVP_PKEY_CMAC, 0, "CMAC", "OpenSSL CMAC method", 0,0,0,0, 0,0,0, cmac_size, 0, 0,0,0,0,0,0,0, cmac_key_free, 0, 0,0 }; ok matthew@ deraadt@ --- src/lib/libcrypto/bio/bf_buff.c | 20 ++++++++++---------- src/lib/libcrypto/bio/bf_lbuf.c | 20 ++++++++++---------- src/lib/libcrypto/bio/bf_nbio.c | 20 ++++++++++---------- src/lib/libcrypto/bio/bf_null.c | 20 ++++++++++---------- src/lib/libcrypto/bio/bss_acpt.c | 18 ++++++++---------- src/lib/libcrypto/bio/bss_bio.c | 18 ++++++++---------- src/lib/libcrypto/bio/bss_conn.c | 19 +++++++++---------- src/lib/libcrypto/bio/bss_dgram.c | 36 ++++++++++++++++-------------------- src/lib/libcrypto/bio/bss_fd.c | 18 +++++++++--------- src/lib/libcrypto/bio/bss_file.c | 19 +++++++++---------- src/lib/libcrypto/bio/bss_log.c | 16 +++++++--------- src/lib/libcrypto/bio/bss_mem.c | 19 +++++++++---------- src/lib/libcrypto/bio/bss_null.c | 19 +++++++++---------- src/lib/libcrypto/bio/bss_sock.c | 18 ++++++++---------- 14 files changed, 132 insertions(+), 148 deletions(-) (limited to 'src/lib/libcrypto/bio') diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c index 99be1a629e..e96da40a58 100644 --- a/src/lib/libcrypto/bio/bf_buff.c +++ b/src/lib/libcrypto/bio/bf_buff.c @@ -72,16 +72,16 @@ static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); #define DEFAULT_BUFFER_SIZE 4096 static BIO_METHOD methods_buffer = { - BIO_TYPE_BUFFER, - "buffer", - buffer_write, - buffer_read, - buffer_puts, - buffer_gets, - buffer_ctrl, - buffer_new, - buffer_free, - buffer_callback_ctrl, + .type = BIO_TYPE_BUFFER, + .name = "buffer", + .bwrite = buffer_write, + .bread = buffer_read, + .bputs = buffer_puts, + .bgets = buffer_gets, + .ctrl = buffer_ctrl, + .create = buffer_new, + .destroy = buffer_free, + .callback_ctrl = buffer_callback_ctrl }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bf_lbuf.c b/src/lib/libcrypto/bio/bf_lbuf.c index f0bd0d709e..54c370d038 100644 --- a/src/lib/libcrypto/bio/bf_lbuf.c +++ b/src/lib/libcrypto/bio/bf_lbuf.c @@ -77,16 +77,16 @@ static long linebuffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); /* #define DEBUG */ static BIO_METHOD methods_linebuffer = { - BIO_TYPE_LINEBUFFER, - "linebuffer", - linebuffer_write, - linebuffer_read, - linebuffer_puts, - linebuffer_gets, - linebuffer_ctrl, - linebuffer_new, - linebuffer_free, - linebuffer_callback_ctrl, + .type = BIO_TYPE_LINEBUFFER, + .name = "linebuffer", + .bwrite = linebuffer_write, + .bread = linebuffer_read, + .bputs = linebuffer_puts, + .bgets = linebuffer_gets, + .ctrl = linebuffer_ctrl, + .create = linebuffer_new, + .destroy = linebuffer_free, + .callback_ctrl = linebuffer_callback_ctrl }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c index 048e6892cc..5a0f6b276a 100644 --- a/src/lib/libcrypto/bio/bf_nbio.c +++ b/src/lib/libcrypto/bio/bf_nbio.c @@ -81,16 +81,16 @@ typedef struct nbio_test_st { } NBIO_TEST; static BIO_METHOD methods_nbiof = { - BIO_TYPE_NBIO_TEST, - "non-blocking IO test filter", - nbiof_write, - nbiof_read, - nbiof_puts, - nbiof_gets, - nbiof_ctrl, - nbiof_new, - nbiof_free, - nbiof_callback_ctrl, + .type = BIO_TYPE_NBIO_TEST, + .name = "non-blocking IO test filter", + .bwrite = nbiof_write, + .bread = nbiof_read, + .bputs = nbiof_puts, + .bgets = nbiof_gets, + .ctrl = nbiof_ctrl, + .create = nbiof_new, + .destroy = nbiof_free, + .callback_ctrl = nbiof_callback_ctrl }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bf_null.c b/src/lib/libcrypto/bio/bf_null.c index 3bba2afe98..7554ed9cf5 100644 --- a/src/lib/libcrypto/bio/bf_null.c +++ b/src/lib/libcrypto/bio/bf_null.c @@ -74,16 +74,16 @@ static int nullf_free(BIO *data); static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); static BIO_METHOD methods_nullf = { - BIO_TYPE_NULL_FILTER, - "NULL filter", - nullf_write, - nullf_read, - nullf_puts, - nullf_gets, - nullf_ctrl, - nullf_new, - nullf_free, - nullf_callback_ctrl, + .type = BIO_TYPE_NULL_FILTER, + .name = "NULL filter", + .bwrite = nullf_write, + .bread = nullf_read, + .bputs = nullf_puts, + .bgets = nullf_gets, + .ctrl = nullf_ctrl, + .create = nullf_new, + .destroy = nullf_free, + .callback_ctrl = nullf_callback_ctrl }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c index 916af3cb20..943d3d9d96 100644 --- a/src/lib/libcrypto/bio/bss_acpt.c +++ b/src/lib/libcrypto/bio/bss_acpt.c @@ -98,16 +98,14 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a); #define ACPT_S_OK 3 static BIO_METHOD methods_acceptp = { - BIO_TYPE_ACCEPT, - "socket accept", - acpt_write, - acpt_read, - acpt_puts, - NULL, /* connect_gets, */ - acpt_ctrl, - acpt_new, - acpt_free, - NULL, + .type = BIO_TYPE_ACCEPT, + .name = "socket accept", + .bwrite = acpt_write, + .bread = acpt_read, + .bputs = acpt_puts, + .ctrl = acpt_ctrl, + .create = acpt_new, + .destroy = acpt_free }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c index d31e59872e..1a17cdf275 100644 --- a/src/lib/libcrypto/bio/bss_bio.c +++ b/src/lib/libcrypto/bio/bss_bio.c @@ -94,16 +94,14 @@ static int bio_make_pair(BIO *bio1, BIO *bio2); static void bio_destroy_pair(BIO *bio); static BIO_METHOD methods_biop = { - BIO_TYPE_BIO, - "BIO pair", - bio_write, - bio_read, - bio_puts, - NULL /* no bio_gets */, - bio_ctrl, - bio_new, - bio_free, - NULL /* no bio_callback_ctrl */ + .type = BIO_TYPE_BIO, + .name = "BIO pair", + .bwrite = bio_write, + .bread = bio_read, + .bputs = bio_puts, + .ctrl = bio_ctrl, + .create = bio_new, + .destroy = bio_free }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c index d7a8619b38..7ed8f1fe31 100644 --- a/src/lib/libcrypto/bio/bss_conn.c +++ b/src/lib/libcrypto/bio/bss_conn.c @@ -103,16 +103,15 @@ BIO_CONNECT *BIO_CONNECT_new(void); void BIO_CONNECT_free(BIO_CONNECT *a); static BIO_METHOD methods_connectp = { - BIO_TYPE_CONNECT, - "socket connect", - conn_write, - conn_read, - conn_puts, - NULL, /* connect_gets, */ - conn_ctrl, - conn_new, - conn_free, - conn_callback_ctrl, + .type = BIO_TYPE_CONNECT, + .name = "socket connect", + .bwrite = conn_write, + .bread = conn_read, + .bputs = conn_puts, + .ctrl = conn_ctrl, + .create = conn_new, + .destroy = conn_free, + .callback_ctrl = conn_callback_ctrl }; static int diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c index 8c08eff352..8f7439c51e 100644 --- a/src/lib/libcrypto/bio/bss_dgram.c +++ b/src/lib/libcrypto/bio/bss_dgram.c @@ -106,30 +106,26 @@ static int BIO_dgram_should_retry(int s); static void get_current_time(struct timeval *t); static BIO_METHOD methods_dgramp = { - BIO_TYPE_DGRAM, - "datagram socket", - dgram_write, - dgram_read, - dgram_puts, - NULL, /* dgram_gets, */ - dgram_ctrl, - dgram_new, - dgram_free, - NULL, + .type = BIO_TYPE_DGRAM, + .name = "datagram socket", + .bwrite = dgram_write, + .bread = dgram_read, + .bputs = dgram_puts, + .ctrl = dgram_ctrl, + .create = dgram_new, + .destroy = dgram_free }; #ifndef OPENSSL_NO_SCTP static BIO_METHOD methods_dgramp_sctp = { - BIO_TYPE_DGRAM_SCTP, - "datagram sctp socket", - dgram_sctp_write, - dgram_sctp_read, - dgram_sctp_puts, - NULL, /* dgram_gets, */ - dgram_sctp_ctrl, - dgram_sctp_new, - dgram_sctp_free, - NULL, + .type = BIO_TYPE_DGRAM_SCTP, + .name = "datagram sctp socket", + .bwrite = dgram_sctp_write, + .bread = dgram_sctp_read, + .bputs = dgram_sctp_puts, + .ctrl = dgram_sctp_ctrl, + .create = dgram_sctp_new, + .destroy = dgram_sctp_free }; #endif diff --git a/src/lib/libcrypto/bio/bss_fd.c b/src/lib/libcrypto/bio/bss_fd.c index 8ea80f1f65..04a88a155b 100644 --- a/src/lib/libcrypto/bio/bss_fd.c +++ b/src/lib/libcrypto/bio/bss_fd.c @@ -79,15 +79,15 @@ static int fd_free(BIO *data); int BIO_fd_should_retry(int s); static BIO_METHOD methods_fdp = { - BIO_TYPE_FD, "file descriptor", - fd_write, - fd_read, - fd_puts, - fd_gets, - fd_ctrl, - fd_new, - fd_free, - NULL, + .type = BIO_TYPE_FD, + .name = "file descriptor", + .bwrite = fd_write, + .bread = fd_read, + .bputs = fd_puts, + .bgets = fd_gets, + .ctrl = fd_ctrl, + .create = fd_new, + .destroy = fd_free }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 6d5444f666..6f81a45a47 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c @@ -100,16 +100,15 @@ static int file_new(BIO *h); static int file_free(BIO *data); static BIO_METHOD methods_filep = { - BIO_TYPE_FILE, - "FILE pointer", - file_write, - file_read, - file_puts, - file_gets, - file_ctrl, - file_new, - file_free, - NULL, + .type = BIO_TYPE_FILE, + .name = "FILE pointer", + .bwrite = file_write, + .bread = file_read, + .bputs = file_puts, + .bgets = file_gets, + .ctrl = file_ctrl, + .create = file_new, + .destroy = file_free }; BIO * diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c index 6aa2d8b0a4..ac1cbc5087 100644 --- a/src/lib/libcrypto/bio/bss_log.c +++ b/src/lib/libcrypto/bio/bss_log.c @@ -86,15 +86,13 @@ static void xsyslog(BIO* bp, int priority, const char* string); static void xcloselog(BIO* bp); static BIO_METHOD methods_slg = { - BIO_TYPE_MEM, "syslog", - slg_write, - NULL, - slg_puts, - NULL, - slg_ctrl, - slg_new, - slg_free, - NULL, + .type = BIO_TYPE_MEM, + .name = "syslog", + .bwrite = slg_write, + .bputs = slg_puts, + .ctrl = slg_ctrl, + .create = slg_new, + .destroy = slg_free }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c index 1a477c12be..b147a8eccb 100644 --- a/src/lib/libcrypto/bio/bss_mem.c +++ b/src/lib/libcrypto/bio/bss_mem.c @@ -70,16 +70,15 @@ static int mem_new(BIO *h); static int mem_free(BIO *data); static BIO_METHOD mem_method = { - BIO_TYPE_MEM, - "memory buffer", - mem_write, - mem_read, - mem_puts, - mem_gets, - mem_ctrl, - mem_new, - mem_free, - NULL, + .type = BIO_TYPE_MEM, + .name = "memory buffer", + .bwrite = mem_write, + .bread = mem_read, + .bputs = mem_puts, + .bgets = mem_gets, + .ctrl = mem_ctrl, + .create = mem_new, + .destroy = mem_free }; /* bio->num is used to hold the value to return on 'empty', if it is diff --git a/src/lib/libcrypto/bio/bss_null.c b/src/lib/libcrypto/bio/bss_null.c index c7289725d9..a5796ea87a 100644 --- a/src/lib/libcrypto/bio/bss_null.c +++ b/src/lib/libcrypto/bio/bss_null.c @@ -70,16 +70,15 @@ static int null_new(BIO *h); static int null_free(BIO *data); static BIO_METHOD null_method = { - BIO_TYPE_NULL, - "NULL", - null_write, - null_read, - null_puts, - null_gets, - null_ctrl, - null_new, - null_free, - NULL, + .type = BIO_TYPE_NULL, + .name = "NULL", + .bwrite = null_write, + .bread = null_read, + .bputs = null_puts, + .bgets = null_gets, + .ctrl = null_ctrl, + .create = null_new, + .destroy = null_free }; BIO_METHOD * diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c index 3dae2562bf..757e1dbb8f 100644 --- a/src/lib/libcrypto/bio/bss_sock.c +++ b/src/lib/libcrypto/bio/bss_sock.c @@ -74,16 +74,14 @@ static int sock_free(BIO *data); int BIO_sock_should_retry(int s); static BIO_METHOD methods_sockp = { - BIO_TYPE_SOCKET, - "socket", - sock_write, - sock_read, - sock_puts, - NULL, /* sock_gets, */ - sock_ctrl, - sock_new, - sock_free, - NULL, + .type = BIO_TYPE_SOCKET, + .name = "socket", + .bwrite = sock_write, + .bread = sock_read, + .bputs = sock_puts, + .ctrl = sock_ctrl, + .create = sock_new, + .destroy = sock_free }; BIO_METHOD * -- cgit v1.2.3-55-g6feb