ell: cast printf call to double
PATCH 1/3 ell: cast printf call to double
%f confusingly enough takes a bool, not a float.
--- ell/settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ell/settings.c +1 -1
@@ -1320,7 +1320,7 @@ LIB_EXPORT bool l_settings_set_float(struct l_settings *settings, { L_AUTO_FREE_VAR(char *, buf); - buf =l_strdup_printf ("%f" , in); + buf =l_strdup_printf ("%f" , (double )in);return l_settings_set_value (settings, group_name, key, buf); }
Signature · 1 line
2.26.2
PATCH 2/3 ell: match declaration names
Found with clang-tidy's readability-inconsistent-declaration-parameter-name
Signed-off-by Rosen Penev <[email protected]>
--- ell/cert-private.h | 2 +- ell/dbus-private.h | 2 +- ell/ecc-private.h | 4 ++-- ell/log.h | 2 +- ell/rtnl.h | 2 +- ell/utf8.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-)
ell/cert-private.h +1 -1
@@ -23,7 +23,7 @@struct asn1_oid ;struct l_certchain *certchain_new_from_leaf (struct l_cert *leaf); -void certchain_link_issuer (struct l_certchain *chain,struct l_cert *issuer); +void certchain_link_issuer (struct l_certchain *chain,struct l_cert *ca); const uint8_t *cert_get_extension(struct l_cert *cert, const struct asn1_oid *ext_id,
ell/dbus-private.h +1 -1
@@ -179,7 +179,7 @@ void _dbus_property_introspection(struct _dbus_property *info,void _dbus_interface_introspection (struct l_dbus_interface *interface,struct l_string *buf); -struct l_dbus_interface *_dbus_interface_new (const char *interface); +struct l_dbus_interface *_dbus_interface_new (const char *name);void _dbus_interface_free (struct l_dbus_interface *interface); struct _dbus_method *_dbus_interface_find_method(struct l_dbus_interface *i,
ell/ecc-private.h +2 -2
@@ -59,10 +59,10 @@ void _vli_mod_inv(uint64_t *result, const uint64_t *input, const uint64_t *mod, unsigned int ndigits);void _vli_mod_sub (uint64_t *result,const uint64_t *left,const uint64_t *right, -const uint64_t *curve_prime,unsigned int ndigits); +const uint64_t *mod,unsigned int ndigits);void _vli_mod_add (uint64_t *result,const uint64_t *left,const uint64_t *right, -const uint64_t *curve_prime,unsigned int ndigits); +const uint64_t *mod,unsigned int ndigits);void _vli_rshift1 (uint64_t *vli,unsigned int ndigits);
ell/log.h +1 -1
@@ -74,7 +74,7 @@ struct l_debug_desc {void l_debug_enable_full (const char *pattern,struct l_debug_desc *start, -struct l_debug_desc *stop); +struct l_debug_desc *end);void l_debug_add_section (struct l_debug_desc *start,struct l_debug_desc *end);
ell/rtnl.h +1 -1
@@ -83,7 +83,7 @@ uint32_t l_rtnl_route4_add_gateway(struct l_netlink *rtnl, int ifindex,void *user_data, l_netlink_destroy_func_t destroy); -void l_rtnl_ifaddr6_extract (const struct ifaddrmsg *ifa,int bytes, +void l_rtnl_ifaddr6_extract (const struct ifaddrmsg *ifa,int len,char **ip); uint32_t l_rtnl_ifaddr6_dump(struct l_netlink *rtnl, l_netlink_command_func_t cb,
ell/utf8.h +1 -1
@@ -102,7 +102,7 @@ static inline __attribute__ ((always_inline)) bool l_ascii_isascii(int c) }bool l_utf8_validate (const char *src,size_t len,const char **end); -size_t l_utf8_strlen (const char *src); +size_t l_utf8_strlen (const char *str);int l_utf8_get_codepoint (const char *str,size_t len,wchar_t *cp);size_t l_utf8_from_wchar (wchar_t c,char *out_buf);
Signature · 1 line
2.26.2
PATCH 3/3 ell: don't use else after return
In reply to Rosen PenevFound with clang-tidy's readability-else-after-return
Signed-off-by Rosen Penev <[email protected]>
--- ell/ecc-external.c | 2 +- ell/ecc.c | 5 ++--- ell/gvariant-util.c | 8 +++----- ell/key.c | 15 +++++++-------- ell/queue.c | 6 +++--- ell/tls-extensions.c | 3 ++- ell/tls.c | 3 +-- tools/gpio.c | 11 +++++------ 8 files changed, 24 insertions(+), 29 deletions(-)
ell/ecc-external.c +1 -1
@@ -85,7 +85,7 @@ int _vli_cmp(const uint64_t *left, const uint64_t *right, unsigned int ndigits)for (i = ndigits -1 ; i >=0 ; i--) {if (left[i] > right[i])return 1 ; -else if (left[i] < right[i]) +if (left[i] < right[i])return -1 ; }
ell/ecc.c +2 -3
@@ -442,10 +442,9 @@ int _vli_legendre(uint64_t *val, const uint64_t *p, unsigned int ndigits)if (_vli_cmp (tmp, _1, ndigits) ==0 )return 1 ; -else if (_vli_cmp (tmp, _0, ndigits) ==0 ) +if (_vli_cmp (tmp, _0, ndigits) ==0 )return 0 ; -else -return -1 ; +return -1 ; }static bool vli_is_zero_or_one (const uint64_t *vli,unsigned int ndigits)
ell/gvariant-util.c +3 -5
@@ -307,8 +307,7 @@ static inline size_t offset_length(size_t size, size_t n_offsets)return 2 ;if (size + n_offsets *4 <=0xffffffff )return 4 ; -else -return 8 ; +return 8 ; }static inline size_t read_word_le (const void *p,size_t sz) {
@@ -325,10 +324,9 @@ static inline size_t read_word_le(const void *p, size_t sz) {if (sz ==2 )return le16toh (x.u16); -else if (sz ==4 ) +if (sz ==4 )return le32toh (x.u32); -else -return le64toh (x.u64); +return le64toh (x.u64); }static inline void write_word_le (void *p,size_t value,size_t sz) {
ell/key.c +7 -8
@@ -500,9 +500,8 @@ static bool compute_common(struct l_key *base, struct l_key *private,if (result_len >0 ) { *len = result_len;return usable_payload; - }else { -return false; } +return false; } LIB_EXPORT bool l_key_compute_dh_public(struct l_key *generator,
@@ -532,13 +531,13 @@ static int be_bignum_compare(const uint8_t *a, size_t a_len,return 1 ;return memcmp (a + i, b, b_len); - }else { -for (i =0 ; i < b_len - a_len; i++) -if (b[i]) -return -1 ; - -return memcmp (a, b + i, a_len); } + +for (i =0 ; i < b_len - a_len; i++) +if (b[i]) +return -1 ; + +return memcmp (a, b + i, a_len); }/*
ell/queue.c +3 -3
@@ -533,10 +533,10 @@ LIB_EXPORT void *l_queue_remove_if(struct l_queue *queue, queue->entries--;return data; - }else { - prev = entry; - entry = entry->next; } + + prev = entry; + entry = entry->next; }return NULL ;
ell/tls-extensions.c +2 -1
@@ -742,7 +742,8 @@ ssize_t tls_parse_signature_algorithms(struct l_tls *tls, tls->pending.cipher_suite->signature->id != sig_alg_id)) continue; - else if (!tls->pending.cipher_suite && + +if (!tls->pending.cipher_suite && !memchr (sig_alg_ids, sig_alg_id, sig_alg_cnt))continue ;
ell/tls.c +1 -2
@@ -134,8 +134,7 @@ static bool tls_prf_get_bytes(struct l_tls *tls,return tls12_prf (tls->prf_hmac->l_id, secret, secret_len, label, seed, seed_len, buf, len); - else - return tls10_prf(secret, secret_len, label, seed, seed_len, +return tls10_prf (secret, secret_len, label, seed, seed_len, buf, len); }
tools/gpio.c +5 -6
@@ -252,14 +252,13 @@ int main(int argc, char **argv)if (strcmp (cmd,"get" ) ==0 )return get (argc, argv); -else if (strcmp (cmd,"set" ) ==0 ) +if (strcmp (cmd,"set" ) ==0 )return set (argc, argv); -else if (strcmp (cmd,"find" ) ==0 ) +if (strcmp (cmd,"find" ) ==0 )return find (argc, argv); -else if (strcmp (cmd,"chip" ) ==0 ) +if (strcmp (cmd,"chip" ) ==0 )return chip (argc, argv); -else if (strcmp (cmd,"line" ) ==0 ) +if (strcmp (cmd,"line" ) ==0 )return line (argc, argv); -else -return print_usage (); +return print_usage (); }
Signature · 1 line
2.26.2
Quoted 1 line · On Tue, 21 Jul 2020 15:39:57 -0700 Rosen Penev <[email protected]> wrote:
%f confusingly enough takes a bool, not a float.
takes a _double_, most likely not a bool :-)
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com