ifdef cleanup, 2 remove OPENSSL_NO_SETVBUF_IONBF
authorRich Salz <rsalz@openssl.org>
Thu, 22 Jan 2015 17:57:29 +0000 (12:57 -0500)
committerRich Salz <rsalz@openssl.org>
Thu, 22 Jan 2015 17:57:29 +0000 (12:57 -0500)
Use setbuf(fp, NULL) instead of setvbuf().  This removes some
ifdef complexity because all of our platforms support setbuf.

Reviewed-by: Richard Levitte <levitte@openssl.org>
CHANGES
apps/apps.c
apps/enc.c
crypto/rand/randfile.c
makevms.com

diff --git a/CHANGES b/CHANGES
index 946d2a03627126e0732433cb047ea1c645d3fcf5..2cecbf60104d3124f9d42157ec2751817fd58133 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -43,6 +43,7 @@
   *) Start cleaning up OPENSSL_NO_xxx #define's
        OPENSSL_NO_RIPEMD160, OPENSSL_NO_RIPEMD merged into OPENSSL_NO_RMD160
        OPENSSL_NO_FP_API merged into OPENSSL_NO_STDIO
+       Use setbuf() and remove OPENSSL_NO_SETVBUF_IONBF
      [Rich Salz]
 
   *) Experimental support for a new, fast, unbiased prime candidate generator,
index b6549d5040399056ad316f82b5624107ddf70975..ccd218260d4431537944144e3d8e607fb3be3ea1 100644 (file)
@@ -852,11 +852,7 @@ X509 *load_cert(BIO *err, const char *file, int format,
     }
 
     if (file == NULL) {
-#ifdef _IONBF
-# ifndef OPENSSL_NO_SETVBUF_IONBF
-        setvbuf(stdin, NULL, _IONBF, 0);
-# endif                         /* ndef OPENSSL_NO_SETVBUF_IONBF */
-#endif
+        setbuf(stdin, NULL); /* don't do buffered reads */
         BIO_set_fp(cert, stdin, BIO_NOCLOSE);
     } else {
         if (BIO_read_filename(cert, file) <= 0) {
@@ -980,11 +976,7 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
         goto end;
     }
     if (file == NULL && maybe_stdin) {
-#ifdef _IONBF
-# ifndef OPENSSL_NO_SETVBUF_IONBF
-        setvbuf(stdin, NULL, _IONBF, 0);
-# endif                         /* ndef OPENSSL_NO_SETVBUF_IONBF */
-#endif
+        setbuf(stdin, NULL); /* don't do buffered reads */
         BIO_set_fp(key, stdin, BIO_NOCLOSE);
     } else if (BIO_read_filename(key, file) <= 0) {
         BIO_printf(err, "Error opening %s %s\n", key_descrip, file);
@@ -1058,11 +1050,7 @@ EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
         goto end;
     }
     if (file == NULL && maybe_stdin) {
-#ifdef _IONBF
-# ifndef OPENSSL_NO_SETVBUF_IONBF
-        setvbuf(stdin, NULL, _IONBF, 0);
-# endif                         /* ndef OPENSSL_NO_SETVBUF_IONBF */
-#endif
+        setbuf(stdin, NULL); /* don't do buffered reads */
         BIO_set_fp(key, stdin, BIO_NOCLOSE);
     } else if (BIO_read_filename(key, file) <= 0) {
         BIO_printf(err, "Error opening %s %s\n", key_descrip, file);
index 8334f39284d8fd90d4c3d606e5595cfaacdec50c..3bf4a6eb040384084400564f3f74c80d69a6c8b2 100644 (file)
@@ -396,10 +396,8 @@ int MAIN(int argc, char **argv)
     }
 
     if (inf == NULL) {
-#ifndef OPENSSL_NO_SETVBUF_IONBF
         if (bufsize != NULL)
-            setvbuf(stdin, (char *)NULL, _IONBF, 0);
-#endif                          /* ndef OPENSSL_NO_SETVBUF_IONBF */
+            setbuf(stdin, NULL);
         BIO_set_fp(in, stdin, BIO_NOCLOSE);
     } else {
         if (BIO_read_filename(in, inf) <= 0) {
@@ -442,10 +440,8 @@ int MAIN(int argc, char **argv)
 
     if (outf == NULL) {
         BIO_set_fp(out, stdout, BIO_NOCLOSE);
-#ifndef OPENSSL_NO_SETVBUF_IONBF
         if (bufsize != NULL)
-            setvbuf(stdout, (char *)NULL, _IONBF, 0);
-#endif                          /* ndef OPENSSL_NO_SETVBUF_IONBF */
+            setbuf(stdin, NULL); /* don't do buffered reads */
 #ifdef OPENSSL_SYS_VMS
         {
             BIO *tmpbio = BIO_new(BIO_f_linebuffer());
index bec7058525b6e6fe38ed56a781a77bb148350a87..b234be0df5c73f288c1139adb4f4477694edd959 100644 (file)
@@ -160,9 +160,7 @@ int RAND_load_file(const char *file, long bytes)
          * because we will waste system entropy.
          */
         bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */
-# ifndef OPENSSL_NO_SETVBUF_IONBF
-        setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */
-# endif                         /* ndef OPENSSL_NO_SETVBUF_IONBF */
+        setbuf(stdin, NULL); /* don't do buffered reads */
     }
 #endif
     for (;;) {
index 37e1e3ce185db8dc236d59b03e760bae3f483f55..82aa4ceea811c45da401c1a130e8161b897c881f 100755 (executable)
@@ -493,14 +493,6 @@ $   GOTO CONFIG_LOG_LOOP2
 $ CONFIG_LOG_LOOP2_END:
 $!
 $ WRITE H_FILE ""
-$ WRITE H_FILE "/* 2011-02-23 SMS."
-$ WRITE H_FILE " * On VMS (V8.3), setvbuf() doesn't support a 64-bit"
-$ WRITE H_FILE " * ""in"" pointer, and the help says:"
-$ WRITE H_FILE " *       Please note that the previously documented"
-$ WRITE H_FILE " *       value _IONBF is not supported."
-$ WRITE H_FILE " * So, skip it on VMS."
-$ WRITE H_FILE " */"
-$ WRITE H_FILE "#define OPENSSL_NO_SETVBUF_IONBF"
 $ WRITE H_FILE "/* STCP support comes with TCPIP 5.7 ECO 2 "
 $ WRITE H_FILE " * enable on newer systems / 2012-02-24 arpadffy */"
 $ WRITE H_FILE "#define OPENSSL_NO_SCTP"