From f94d9e793861c5e36d17f485c3c1a7053f86587e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Oct 2021 07:26:30 +0200 Subject: -style fixes --- src/include/gnunet_json_lib.h | 4 ++-- src/json/json.c | 2 +- src/pq/pq_result_helper.c | 43 +++++++++++++++++++++++++------------------ src/util/crypto_rsa.c | 23 +++++++++++++++++++---- 4 files changed, 47 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h index 92f696e08..5ef4592e5 100644 --- a/src/include/gnunet_json_lib.h +++ b/src/include/gnunet_json_lib.h @@ -107,9 +107,9 @@ struct GNUNET_JSON_Specification size_t *size_ptr; /** - * Set to #GNUNET_YES if this component is optional. + * Set to true if this component is optional. */ - int is_optional; + bool is_optional; }; diff --git a/src/json/json.c b/src/json/json.c index 51d5c0c72..6d11b4fdd 100644 --- a/src/json/json.c +++ b/src/json/json.c @@ -77,7 +77,7 @@ GNUNET_JSON_spec_mark_optional (struct GNUNET_JSON_Specification spec) { struct GNUNET_JSON_Specification ret = spec; - ret.is_optional = GNUNET_YES; + ret.is_optional = true; return ret; } diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 23fb4f96e..f264603f4 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c @@ -127,10 +127,13 @@ GNUNET_PQ_result_spec_variable_size (const char *name, void **dst, size_t *sptr) { - struct GNUNET_PQ_ResultSpec res = - { &extract_varsize_blob, - &clean_varsize_blob, NULL, - (void *) (dst), 0, name, sptr }; + struct GNUNET_PQ_ResultSpec res = { + .conv = &extract_varsize_blob, + .cleaner = &clean_varsize_blob, + .dst = (void *) (dst), + .fname = name, + .result_size = sptr + }; return res; } @@ -207,10 +210,12 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, void *dst, size_t dst_size) { - struct GNUNET_PQ_ResultSpec res = - { &extract_fixed_blob, - NULL, NULL, - (dst), dst_size, name, NULL }; + struct GNUNET_PQ_ResultSpec res = { + .conv = &extract_fixed_blob, + .dst = (dst), + .dst_size = dst_size, + .fname = name + }; return res; } @@ -301,11 +306,12 @@ struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_public_key (const char *name, struct GNUNET_CRYPTO_RsaPublicKey **rsa) { - struct GNUNET_PQ_ResultSpec res = - { &extract_rsa_public_key, - &clean_rsa_public_key, - NULL, - (void *) rsa, 0, name, NULL }; + struct GNUNET_PQ_ResultSpec res = { + .conv = &extract_rsa_public_key, + .cleaner = &clean_rsa_public_key, + .dst = (void *) rsa, + .fname = name + }; return res; } @@ -395,11 +401,12 @@ struct GNUNET_PQ_ResultSpec GNUNET_PQ_result_spec_rsa_signature (const char *name, struct GNUNET_CRYPTO_RsaSignature **sig) { - struct GNUNET_PQ_ResultSpec res = - { &extract_rsa_signature, - &clean_rsa_signature, - NULL, - (void *) sig, 0, (name), NULL }; + struct GNUNET_PQ_ResultSpec res = { + .conv = &extract_rsa_signature, + .cleaner = &clean_rsa_signature, + .dst = (void *) sig, + .fname = name + }; return res; } diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 4d3de00bc..f017d1f10 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c @@ -310,9 +310,15 @@ GNUNET_CRYPTO_rsa_public_key_encode ( struct GNUNET_CRYPTO_RsaPublicKeyHeaderP hdr; int ret; - ret = key_from_sexp (ne, key->sexp, "public-key", "ne"); + ret = key_from_sexp (ne, + key->sexp, + "public-key", + "ne"); if (0 != ret) - ret = key_from_sexp (ne, key->sexp, "rsa", "ne"); + ret = key_from_sexp (ne, + key->sexp, + "rsa", + "ne"); if (0 != ret) { GNUNET_break (0); @@ -333,16 +339,25 @@ GNUNET_CRYPTO_rsa_public_key_encode ( (n_size > UINT16_MAX) ) { GNUNET_break (0); - *buffer = NULL; + if (NULL != buffer) + *buffer = NULL; gcry_mpi_release (ne[0]); gcry_mpi_release (ne[1]); return 0; } buf_size = n_size + e_size + sizeof (hdr); + if (NULL == buffer) + { + gcry_mpi_release (ne[0]); + gcry_mpi_release (ne[1]); + return buf_size; + } buf = GNUNET_malloc (buf_size); hdr.modulus_length = htons ((uint16_t) n_size); hdr.public_exponent_length = htons ((uint16_t) e_size); - memcpy (buf, &hdr, sizeof (hdr)); + memcpy (buf, + &hdr, + sizeof (hdr)); GNUNET_assert (0 == gcry_mpi_print (GCRYMPI_FMT_USG, (unsigned char *) &buf[sizeof (hdr)], -- cgit v1.2.3