X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fbio%2Fbss_fd.c;h=269a08baa942faa847cf66608aa0df01ff9d4360;hp=78bbfd6f3bead7935d63f2f8a84258a7cdd8db3b;hb=27ab91951c96364351f1ea0652dbf14622440345;hpb=d07aee2c7a33e77d97d8e13811af3637e3849cb2 diff --git a/crypto/bio/bss_fd.c b/crypto/bio/bss_fd.c index 78bbfd6f3b..269a08baa9 100644 --- a/crypto/bio/bss_fd.c +++ b/crypto/bio/bss_fd.c @@ -58,7 +58,10 @@ static int fd_free(BIO *data); int BIO_fd_should_retry(int s); static const BIO_METHOD methods_fdp = { - BIO_TYPE_FD, "file descriptor", + BIO_TYPE_FD, + "file descriptor", + /* TODO: Convert to new style write function */ + bwrite_conv, fd_write, /* TODO: Convert to new style read function */ bread_conv, @@ -73,7 +76,7 @@ static const BIO_METHOD methods_fdp = { const BIO_METHOD *BIO_s_fd(void) { - return (&methods_fdp); + return &methods_fdp; } BIO *BIO_new_fd(int fd, int close_flag) @@ -81,9 +84,9 @@ BIO *BIO_new_fd(int fd, int close_flag) BIO *ret; ret = BIO_new(BIO_s_fd()); if (ret == NULL) - return (NULL); + return NULL; BIO_set_fd(ret, fd, close_flag); - return (ret); + return ret; } static int fd_new(BIO *bi) @@ -92,13 +95,13 @@ static int fd_new(BIO *bi) bi->num = -1; bi->ptr = NULL; bi->flags = BIO_FLAGS_UPLINK; /* essentially redundant */ - return (1); + return 1; } static int fd_free(BIO *a) { if (a == NULL) - return (0); + return 0; if (a->shutdown) { if (a->init) { UP_close(a->num); @@ -106,7 +109,7 @@ static int fd_free(BIO *a) a->init = 0; a->flags = BIO_FLAGS_UPLINK; } - return (1); + return 1; } static int fd_read(BIO *b, char *out, int outl) @@ -122,7 +125,7 @@ static int fd_read(BIO *b, char *out, int outl) BIO_set_retry_read(b); } } - return (ret); + return ret; } static int fd_write(BIO *b, const char *in, int inl) @@ -135,7 +138,7 @@ static int fd_write(BIO *b, const char *in, int inl) if (BIO_fd_should_retry(ret)) BIO_set_retry_write(b); } - return (ret); + return ret; } static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) @@ -146,6 +149,7 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) switch (cmd) { case BIO_CTRL_RESET: num = 0; + /* fall thru */ case BIO_C_FILE_SEEK: ret = (long)UP_lseek(b->num, num, 0); break; @@ -186,7 +190,7 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) ret = 0; break; } - return (ret); + return ret; } static int fd_puts(BIO *bp, const char *str) @@ -195,7 +199,7 @@ static int fd_puts(BIO *bp, const char *str) n = strlen(str); ret = fd_write(bp, str, n); - return (ret); + return ret; } static int fd_gets(BIO *bp, char *buf, int size) @@ -204,14 +208,16 @@ static int fd_gets(BIO *bp, char *buf, int size) char *ptr = buf; char *end = buf + size - 1; - while ((ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n')) - ptr++; + while (ptr < end && fd_read(bp, ptr, 1) > 0) { + if (*ptr++ == '\n') + break; + } ptr[0] = '\0'; if (buf[0] != '\0') ret = strlen(buf); - return (ret); + return ret; } int BIO_fd_should_retry(int i) @@ -221,9 +227,9 @@ int BIO_fd_should_retry(int i) if ((i == 0) || (i == -1)) { err = get_last_sys_error(); - return (BIO_fd_non_fatal_error(err)); + return BIO_fd_non_fatal_error(err); } - return (0); + return 0; } int BIO_fd_non_fatal_error(int err) @@ -265,11 +271,10 @@ int BIO_fd_non_fatal_error(int err) # ifdef EALREADY case EALREADY: # endif - return (1); - /* break; */ + return 1; default: break; } - return (0); + return 0; } #endif