From 42c6046064d2ee45d59baec53bedde4ea434294f Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 21 Oct 2016 15:15:51 +0100 Subject: [PATCH] More parameter naming of BIO_read*/BIO_write* related functions Based on feedback received. Reviewed-by: Richard Levitte --- crypto/bio/bio_lib.c | 41 +++++++++++++++++++++-------------------- crypto/bio/bio_meth.c | 16 ++++++++-------- include/internal/bio.h | 4 ++-- include/openssl/bio.h | 4 ++-- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 6d958b1e92..1a9b9137ba 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -250,7 +250,7 @@ int BIO_method_type(const BIO *b) * is for compatibility with the old style BIO_read(), where existing code may * make assumptions about the return value that it might get. */ -static int bio_read_intern(BIO *b, void *out, size_t outl, size_t *read) +static int bio_read_intern(BIO *b, void *data, size_t datal, size_t *read) { int ret; @@ -260,7 +260,7 @@ static int bio_read_intern(BIO *b, void *out, size_t outl, size_t *read) } if ((b->callback != NULL || b->callback_ex != NULL) && - ((ret = (int)bio_call_callback(b, BIO_CB_READ, out, outl, 0, 0L, 1L, + ((ret = (int)bio_call_callback(b, BIO_CB_READ, data, datal, 0, 0L, 1L, read)) <= 0)) return ret; @@ -269,27 +269,27 @@ static int bio_read_intern(BIO *b, void *out, size_t outl, size_t *read) return -2; } - ret = b->method->bread(b, out, outl, read); + ret = b->method->bread(b, data, datal, read); if (ret > 0) b->num_read += (uint64_t)*read; if (b->callback != NULL || b->callback_ex != NULL) - ret = (int)bio_call_callback(b, BIO_CB_READ | BIO_CB_RETURN, out, outl, - 0, 0L, ret, read); + ret = (int)bio_call_callback(b, BIO_CB_READ | BIO_CB_RETURN, data, + datal, 0, 0L, ret, read); return ret; } -int BIO_read(BIO *b, void *out, int outl) +int BIO_read(BIO *b, void *data, int datal) { size_t read; int ret; - if (outl < 0) + if (datal < 0) return 0; - ret = bio_read_intern(b, out, (size_t)outl, &read); + ret = bio_read_intern(b, data, (size_t)datal, &read); if (ret > 0) { /* *read should always be <= outl */ @@ -299,11 +299,11 @@ int BIO_read(BIO *b, void *out, int outl) return ret; } -int BIO_read_ex(BIO *b, void *out, size_t outl, size_t *read) +int BIO_read_ex(BIO *b, void *data, size_t datal, size_t *read) { int ret; - ret = bio_read_intern(b, out, outl, read); + ret = bio_read_intern(b, data, datal, read); if (ret > 0) ret = 1; @@ -313,7 +313,8 @@ int BIO_read_ex(BIO *b, void *out, size_t outl, size_t *read) return ret; } -static int bio_write_intern(BIO *b, const void *in, size_t inl, size_t *written) +static int bio_write_intern(BIO *b, const void *data, size_t datal, + size_t *written) { int ret; @@ -326,7 +327,7 @@ static int bio_write_intern(BIO *b, const void *in, size_t inl, size_t *written) } if ((b->callback != NULL || b->callback_ex != NULL) && - ((ret = (int)bio_call_callback(b, BIO_CB_WRITE, in, inl, 0, 0L, 1L, + ((ret = (int)bio_call_callback(b, BIO_CB_WRITE, data, datal, 0, 0L, 1L, written)) <= 0)) return ret; @@ -335,27 +336,27 @@ static int bio_write_intern(BIO *b, const void *in, size_t inl, size_t *written) return -2; } - ret = b->method->bwrite(b, in, inl, written); + ret = b->method->bwrite(b, data, datal, written); if (ret > 0) b->num_write += (uint64_t)*written; if (b->callback != NULL || b->callback_ex != NULL) - ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, - 0, 0L, ret, written); + ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, data, + datal, 0, 0L, ret, written); return ret; } -int BIO_write(BIO *b, const void *in, int inl) +int BIO_write(BIO *b, const void *data, int datal) { size_t written; int ret; - if (inl < 0) + if (datal < 0) return 0; - ret = bio_write_intern(b, in, (size_t)inl, &written); + ret = bio_write_intern(b, data, (size_t)datal, &written); if (ret > 0) { /* *written should always be <= inl */ @@ -365,11 +366,11 @@ int BIO_write(BIO *b, const void *in, int inl) return ret; } -int BIO_write_ex(BIO *b, const void *in, size_t inl, size_t *written) +int BIO_write_ex(BIO *b, const void *data, size_t datal, size_t *written) { int ret; - ret = bio_write_intern(b, in, inl, written); + ret = bio_write_intern(b, data, datal, written); if (ret > 0) ret = 1; diff --git a/crypto/bio/bio_meth.c b/crypto/bio/bio_meth.c index ea3155f3fa..5eaa1fd461 100644 --- a/crypto/bio/bio_meth.c +++ b/crypto/bio/bio_meth.c @@ -61,14 +61,14 @@ int (*BIO_meth_get_write_ex(BIO_METHOD *biom)) (BIO *, const char *, size_t, } /* Conversion for old style bwrite to new style */ -int bwrite_conv(BIO *bio, const char *in, size_t inl, size_t *written) +int bwrite_conv(BIO *bio, const char *data, size_t datal, size_t *written) { int ret; - if (inl > INT_MAX) - inl = INT_MAX; + if (datal > INT_MAX) + datal = INT_MAX; - ret = bio->method->bwrite_old(bio, in, (int)inl); + ret = bio->method->bwrite_old(bio, data, (int)datal); if (ret <= 0) { *written = 0; @@ -107,14 +107,14 @@ int (*BIO_meth_get_read_ex(BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *) } /* Conversion for old style bread to new style */ -int bread_conv(BIO *bio, char *out, size_t outl, size_t *read) +int bread_conv(BIO *bio, char *data, size_t datal, size_t *read) { int ret; - if (outl > INT_MAX) - outl = INT_MAX; + if (datal > INT_MAX) + datal = INT_MAX; - ret = bio->method->bread_old(bio, out, (int)outl); + ret = bio->method->bread_old(bio, data, (int)datal); if (ret <= 0) { *read = 0; diff --git a/include/internal/bio.h b/include/internal/bio.h index e1fe62af3e..f02d74115f 100644 --- a/include/internal/bio.h +++ b/include/internal/bio.h @@ -29,5 +29,5 @@ void bio_cleanup(void); /* Old style to new style BIO_METHOD conversion functions */ -int bwrite_conv(BIO *bio, const char *in, size_t inl, size_t *written); -int bread_conv(BIO *bio, char *out, size_t outl, size_t *read); +int bwrite_conv(BIO *bio, const char *data, size_t datal, size_t *written); +int bread_conv(BIO *bio, char *data, size_t datal, size_t *read); diff --git a/include/openssl/bio.h b/include/openssl/bio.h index 7ecd46049b..a3c5062f21 100644 --- a/include/openssl/bio.h +++ b/include/openssl/bio.h @@ -551,10 +551,10 @@ void BIO_set_shutdown(BIO *a, int shut); int BIO_get_shutdown(BIO *a); void BIO_vfree(BIO *a); int BIO_up_ref(BIO *a); -int BIO_read(BIO *b, void *data, int len); +int BIO_read(BIO *b, void *data, int datal); int BIO_read_ex(BIO *b, void *data, size_t datal, size_t *read); int BIO_gets(BIO *bp, char *buf, int size); -int BIO_write(BIO *b, const void *data, int len); +int BIO_write(BIO *b, const void *data, int datal); int BIO_write_ex(BIO *b, const void *data, size_t datal, size_t *written); int BIO_puts(BIO *bp, const char *buf); int BIO_indent(BIO *b, int indent, int max); -- 2.25.1