JSON_ENC: Minor tweaks
authorHugo Landau <hlandau@openssl.org>
Mon, 22 Jan 2024 14:45:00 +0000 (14:45 +0000)
committerHugo Landau <hlandau@openssl.org>
Fri, 2 Feb 2024 11:50:03 +0000 (11:50 +0000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22037)

include/internal/json_enc.h
ssl/quic/json_enc.c
ssl/quic/qlog.c

index 9c13d0622d6edf66dc790cda932d5884424251ae..96ea920641b300538db151c49b8f599b609d87a5 100644 (file)
@@ -117,12 +117,12 @@ int ossl_json_flush(OSSL_JSON_ENC *json);
 int ossl_json_flush_cleanup(OSSL_JSON_ENC *json);
 
 /*
- * ossl_json_set_sink
- * ------------------
+ * ossl_json_set0_sink
+ * -------------------
  *
  * Changes the sink used by the JSON encoder.
  */
-int ossl_json_set_sink(OSSL_JSON_ENC *json, BIO *bio);
+int ossl_json_set0_sink(OSSL_JSON_ENC *json, BIO *bio);
 
 /*
  * ossl_json_in_error
index f2c6f444e6703843383cfba0986c751f7570cc41..e5cf50066f6859f56db6f07f9d532020b9579b09 100644 (file)
@@ -37,7 +37,7 @@ static void wbuf_cleanup(struct json_write_buf *wbuf)
     wbuf->alloc = 0;
 }
 
-static void wbuf_set_bio(struct json_write_buf *wbuf, BIO *bio)
+static void wbuf_set0_bio(struct json_write_buf *wbuf, BIO *bio)
 {
     wbuf->bio = bio;
 }
@@ -238,7 +238,7 @@ int ossl_json_init(OSSL_JSON_ENC *json, BIO *bio, uint32_t flags)
         return 0;
 
     json->state = STATE_PRE_COMMA;
-    return ossl_json_reset(json);
+    return 1;
 }
 
 void ossl_json_cleanup(OSSL_JSON_ENC *json)
@@ -273,9 +273,9 @@ int ossl_json_flush(OSSL_JSON_ENC *json)
     return wbuf_flush(&json->wbuf);
 }
 
-int ossl_json_set_sink(OSSL_JSON_ENC *json, BIO *bio)
+int ossl_json_set0_sink(OSSL_JSON_ENC *json, BIO *bio)
 {
-    wbuf_set_bio(&json->wbuf, bio);
+    wbuf_set0_bio(&json->wbuf, bio);
     return 1;
 }
 
index 6cf89e355446e67b5d59cc05a8b2fa97bcbb45c8..82da15f5d12674f3cc85a0da6f596d1e9f36886d 100644 (file)
@@ -174,7 +174,7 @@ int ossl_qlog_set_sink_bio(QLOG *qlog, BIO *bio)
     ossl_qlog_flush(qlog); /* best effort */
     BIO_free_all(qlog->bio);
     qlog->bio = bio;
-    ossl_json_set_sink(&qlog->json, bio);
+    ossl_json_set0_sink(&qlog->json, bio);
     return 1;
 }