From 286d6c31654be0e34117bd981da2e93a27c32241 Mon Sep 17 00:00:00 2001 From: adi2011 Date: Fri, 24 Jun 2022 06:37:16 +0530 Subject: [PATCH] tools/gen: Always return bool! --- common/test/run-lease_rates.c | 2 +- tools/gen/header_template | 2 +- tools/gen/impl_template | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/test/run-lease_rates.c b/common/test/run-lease_rates.c index 5d8b7d0e8597..31da81c7d317 100644 --- a/common/test/run-lease_rates.c +++ b/common/test/run-lease_rates.c @@ -15,7 +15,7 @@ bool fromwire_bool(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) void *fromwire_fail(const u8 **cursor UNNEEDED, size_t *max UNNEEDED) { fprintf(stderr, "fromwire_fail called!\n"); abort(); } /* Generated stub for fromwire_lease_rates */ -void fromwire_lease_rates(const u8 **cursor UNNEEDED, size_t *plen UNNEEDED, struct lease_rates *lease_rates UNNEEDED) +bool fromwire_lease_rates(const u8 **cursor UNNEEDED, size_t *plen UNNEEDED, struct lease_rates *lease_rates UNNEEDED) { fprintf(stderr, "fromwire_lease_rates called!\n"); abort(); } /* Generated stub for fromwire_secp256k1_ecdsa_signature */ void fromwire_secp256k1_ecdsa_signature(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, diff --git a/tools/gen/header_template b/tools/gen/header_template index 35e62e60aeea..4b7188555f5e 100644 --- a/tools/gen/header_template +++ b/tools/gen/header_template @@ -148,7 +148,7 @@ void towire_${subtype.name}(u8 **p, const ${subtype.type_name()} *${subtype.name % if subtype.is_varsize(): ${subtype.type_name()} *fromwire_${subtype.name}(const tal_t *ctx, const u8 **cursor, size_t *plen); % else: -void fromwire_${subtype.name}(const u8 **cursor, size_t *plen, ${subtype.type_name()} *${subtype.name}); +bool fromwire_${subtype.name}(const u8 **cursor, size_t *plen, ${subtype.type_name()} *${subtype.name}); % endif % endfor diff --git a/tools/gen/impl_template b/tools/gen/impl_template index 3d013f7f144d..cb3d1f77b206 100644 --- a/tools/gen/impl_template +++ b/tools/gen/impl_template @@ -151,7 +151,7 @@ ${static}void towire_${subtype.name}(u8 **p, const ${subtype.type_name()} *${sub ${static}${subtype.type_name()} * fromwire_${subtype.name}(const tal_t *ctx, const u8 **cursor, size_t *plen) % else: -${static}void fromwire_${subtype.name}(${'const tal_t *ctx, ' if subtype.needs_context() else ''}const u8 **cursor, size_t *plen, ${subtype.type_name()} *${subtype.name}) +${static}bool fromwire_${subtype.name}(${'const tal_t *ctx, ' if subtype.needs_context() else ''}const u8 **cursor, size_t *plen, ${subtype.type_name()} *${subtype.name}) % endif { % if subtype.is_varsize(): @@ -175,6 +175,9 @@ ${static}void fromwire_${subtype.name}(${'const tal_t *ctx, ' if subtype.needs_c % if subtype.is_varsize(): return ${subtype.name}; +% else: + + return *cursor != NULL; % endif } % endfor ## END Subtypes