More parameter naming of BIO_read*/BIO_write* related functions

Based on feedback received.

Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
Matt Caswell 2016-10-21 15:15:51 +01:00
parent f42fd819d6
commit 42c6046064
4 changed files with 33 additions and 32 deletions

View file

@ -250,7 +250,7 @@ int BIO_method_type(const BIO *b)
* is for compatibility with the old style BIO_read(), where existing code may * is for compatibility with the old style BIO_read(), where existing code may
* make assumptions about the return value that it might get. * 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; 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) && 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)) read)) <= 0))
return ret; return ret;
@ -269,27 +269,27 @@ static int bio_read_intern(BIO *b, void *out, size_t outl, size_t *read)
return -2; return -2;
} }
ret = b->method->bread(b, out, outl, read); ret = b->method->bread(b, data, datal, read);
if (ret > 0) if (ret > 0)
b->num_read += (uint64_t)*read; b->num_read += (uint64_t)*read;
if (b->callback != NULL || b->callback_ex != NULL) if (b->callback != NULL || b->callback_ex != NULL)
ret = (int)bio_call_callback(b, BIO_CB_READ | BIO_CB_RETURN, out, outl, ret = (int)bio_call_callback(b, BIO_CB_READ | BIO_CB_RETURN, data,
0, 0L, ret, read); datal, 0, 0L, ret, read);
return ret; return ret;
} }
int BIO_read(BIO *b, void *out, int outl) int BIO_read(BIO *b, void *data, int datal)
{ {
size_t read; size_t read;
int ret; int ret;
if (outl < 0) if (datal < 0)
return 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) { if (ret > 0) {
/* *read should always be <= outl */ /* *read should always be <= outl */
@ -299,11 +299,11 @@ int BIO_read(BIO *b, void *out, int outl)
return ret; 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; int ret;
ret = bio_read_intern(b, out, outl, read); ret = bio_read_intern(b, data, datal, read);
if (ret > 0) if (ret > 0)
ret = 1; ret = 1;
@ -313,7 +313,8 @@ int BIO_read_ex(BIO *b, void *out, size_t outl, size_t *read)
return ret; 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; 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) && 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)) written)) <= 0))
return ret; return ret;
@ -335,27 +336,27 @@ static int bio_write_intern(BIO *b, const void *in, size_t inl, size_t *written)
return -2; return -2;
} }
ret = b->method->bwrite(b, in, inl, written); ret = b->method->bwrite(b, data, datal, written);
if (ret > 0) if (ret > 0)
b->num_write += (uint64_t)*written; b->num_write += (uint64_t)*written;
if (b->callback != NULL || b->callback_ex != NULL) if (b->callback != NULL || b->callback_ex != NULL)
ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, data,
0, 0L, ret, written); datal, 0, 0L, ret, written);
return ret; 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; size_t written;
int ret; int ret;
if (inl < 0) if (datal < 0)
return 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) { if (ret > 0) {
/* *written should always be <= inl */ /* *written should always be <= inl */
@ -365,11 +366,11 @@ int BIO_write(BIO *b, const void *in, int inl)
return ret; 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; int ret;
ret = bio_write_intern(b, in, inl, written); ret = bio_write_intern(b, data, datal, written);
if (ret > 0) if (ret > 0)
ret = 1; ret = 1;

View file

@ -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 */ /* 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; int ret;
if (inl > INT_MAX) if (datal > INT_MAX)
inl = 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) { if (ret <= 0) {
*written = 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 */ /* 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; int ret;
if (outl > INT_MAX) if (datal > INT_MAX)
outl = 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) { if (ret <= 0) {
*read = 0; *read = 0;

View file

@ -29,5 +29,5 @@ void bio_cleanup(void);
/* Old style to new style BIO_METHOD conversion functions */ /* Old style to new style BIO_METHOD conversion functions */
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 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);

View file

@ -551,10 +551,10 @@ void BIO_set_shutdown(BIO *a, int shut);
int BIO_get_shutdown(BIO *a); int BIO_get_shutdown(BIO *a);
void BIO_vfree(BIO *a); void BIO_vfree(BIO *a);
int BIO_up_ref(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_read_ex(BIO *b, void *data, size_t datal, size_t *read);
int BIO_gets(BIO *bp, char *buf, int size); 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_write_ex(BIO *b, const void *data, size_t datal, size_t *written);
int BIO_puts(BIO *bp, const char *buf); int BIO_puts(BIO *bp, const char *buf);
int BIO_indent(BIO *b, int indent, int max); int BIO_indent(BIO *b, int indent, int max);