Commit 2947af32 authored by Beat Bolli's avatar Beat Bolli Committed by Matt Caswell
Browse files

doc/man3: use the documented coding style in the example code

Adjust brace placement, whitespace after keywords, indentation and empty
lines after variable declarations according to
https://www.openssl.org/policies/codingstyle.html

.

Indent literal sections by exactly one space.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1956)
parent 52df25cf
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -82,7 +82,8 @@ checking has been omitted for clarity.
 bio = BIO_new(BIO_s_null());
 mdtmp = BIO_new(BIO_f_md());
 BIO_set_md(mdtmp, EVP_sha1());
 /* For BIO_push() we want to append the sink BIO and keep a note of
 /*
  * For BIO_push() we want to append the sink BIO and keep a note of
  * the start of the chain.
  */
 bio = BIO_push(mdtmp, bio);
@@ -120,7 +121,8 @@ outputs them. This could be used with the examples above.
 do {
     EVP_MD *md;
     mdtmp = BIO_find_type(mdtmp, BIO_TYPE_MD);
        if (!mdtmp) break;
     if (!mdtmp)
         break;
     BIO_get_md(mdtmp, &md);
     printf("%s digest", OBJ_nid2sn(EVP_MD_type(md)));
     mdlen = BIO_gets(mdtmp, mdbuf, EVP_MAX_MD_SIZE);
+6 −5
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ Traverse a chain looking for digest BIOs:

 do {
     btmp = BIO_find_type(btmp, BIO_TYPE_MD);
        if (btmp == NULL) break; /* Not found */
     if (btmp == NULL)
         break; /* Not found */
     /* btmp is a digest BIO, do something with it ...*/
     ...

+10 −5
Original line number Diff line number Diff line
@@ -92,15 +92,18 @@ Alternative technique:

 BIO *bio_out;
 bio_out = BIO_new(BIO_s_file());
 if (bio_out == NULL) /* Error ... */
 if (!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE)) /* Error ... */
 if (bio_out == NULL)
     /* Error */
 if (!BIO_set_fp(bio_out, stdout, BIO_NOCLOSE))
     /* Error */
 BIO_printf(bio_out, "Hello World\n");

Write to a file:

 BIO *out;
 out = BIO_new_file("filename.txt", "w");
 if (!out) /* Error occurred */
 if (!out)
     /* Error */
 BIO_printf(out, "Hello World\n");
 BIO_free(out);

@@ -108,8 +111,10 @@ Alternative technique:

 BIO *out;
 out = BIO_new(BIO_s_file());
 if (out == NULL) /* Error ... */
 if (!BIO_write_filename(out, "filename.txt")) /* Error ... */
 if (out == NULL)
     /* Error */
 if (!BIO_write_filename(out, "filename.txt"))
     /* Error */
 BIO_printf(out, "Hello World\n");
 BIO_free(out);

+6 −3
Original line number Diff line number Diff line
@@ -122,7 +122,8 @@ or

is called before the read and

 callback_ex(b, BIO_CB_READ | BIO_CB_RETURN, data, dlen, 0, 0L, retvalue, readbytes)
 callback_ex(b, BIO_CB_READ | BIO_CB_RETURN, data, dlen, 0, 0L, retvalue,
             readbytes)

or

@@ -140,7 +141,8 @@ or

is called before the write and

 callback_ex(b, BIO_CB_WRITE | BIO_CB_RETURN, data, dlen, 0, 0L, retvalue, written)
 callback_ex(b, BIO_CB_WRITE | BIO_CB_RETURN, data, dlen, 0, 0L, retvalue,
             written)

or

@@ -158,7 +160,8 @@ or

is called before the operation and

 callback_ex(b, BIO_CB_GETS | BIO_CB_RETURN, buf, size, 0, 0L, retvalue, readbytes)
 callback_ex(b, BIO_CB_GETS | BIO_CB_RETURN, buf, size, 0, 0L, retvalue,
             readbytes)

or

+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ replace use of BN_CTX_init with BN_CTX_new instead:

 BN_CTX *ctx;
 ctx = BN_CTX_new();
 if(!ctx) /* Handle error */
 if (!ctx)
     /* error */
 ...
 BN_CTX_free(ctx);

Loading