summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-10-23 07:26:30 +0200
committerChristian Grothoff <christian@grothoff.org>2021-10-23 07:26:30 +0200
commitf94d9e793861c5e36d17f485c3c1a7053f86587e (patch)
tree2e992a5ad05d471ac34945eb768147a896d52d6a /src
parentbe9b998b3369056c7c8fb0ae84fb4e2a064b496c (diff)
-style fixes
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_json_lib.h4
-rw-r--r--src/json/json.c2
-rw-r--r--src/pq/pq_result_helper.c43
-rw-r--r--src/util/crypto_rsa.c23
4 files changed, 47 insertions, 25 deletions
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)],