All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ell: cast printf call to double
@ 2020-07-21 22:39 Rosen Penev
  2020-07-21 22:39 ` [PATCH 2/3] ell: match declaration names Rosen Penev
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rosen Penev @ 2020-07-21 22:39 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 543 bytes --]

%f confusingly enough takes a bool, not a float.
---
 ell/settings.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ell/settings.c b/ell/settings.c
index 945dff7..dac45c9 100644
--- a/ell/settings.c
+++ b/ell/settings.c
@@ -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);
 }
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ell: match declaration names
  2020-07-21 22:39 [PATCH 1/3] ell: cast printf call to double Rosen Penev
@ 2020-07-21 22:39 ` Rosen Penev
  2020-07-21 22:39 ` [PATCH 3/3] ell: don't use else after return Rosen Penev
  2020-07-22 12:51 ` [PATCH 1/3] ell: cast printf call to double Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Rosen Penev @ 2020-07-21 22:39 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 3576 bytes --]

Found with clang-tidy's
readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 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(-)

diff --git a/ell/cert-private.h b/ell/cert-private.h
index ba9a513..929f88d 100644
--- a/ell/cert-private.h
+++ b/ell/cert-private.h
@@ -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,
diff --git a/ell/dbus-private.h b/ell/dbus-private.h
index d34a298..66a585e 100644
--- a/ell/dbus-private.h
+++ b/ell/dbus-private.h
@@ -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,
diff --git a/ell/ecc-private.h b/ell/ecc-private.h
index 0e85d98..70d9607 100644
--- a/ell/ecc-private.h
+++ b/ell/ecc-private.h
@@ -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);
 
diff --git a/ell/log.h b/ell/log.h
index 19bf10b..924523b 100644
--- a/ell/log.h
+++ b/ell/log.h
@@ -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);
 
diff --git a/ell/rtnl.h b/ell/rtnl.h
index 60b8db4..a0c06ed 100644
--- a/ell/rtnl.h
+++ b/ell/rtnl.h
@@ -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,
diff --git a/ell/utf8.h b/ell/utf8.h
index c92da60..d1b1811 100644
--- a/ell/utf8.h
+++ b/ell/utf8.h
@@ -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);
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ell: don't use else after return
  2020-07-21 22:39 [PATCH 1/3] ell: cast printf call to double Rosen Penev
  2020-07-21 22:39 ` [PATCH 2/3] ell: match declaration names Rosen Penev
@ 2020-07-21 22:39 ` Rosen Penev
  2020-07-22 12:51 ` [PATCH 1/3] ell: cast printf call to double Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Rosen Penev @ 2020-07-21 22:39 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 4824 bytes --]

Found with clang-tidy's readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 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(-)

diff --git a/ell/ecc-external.c b/ell/ecc-external.c
index 1c118c2..13b55e6 100644
--- a/ell/ecc-external.c
+++ b/ell/ecc-external.c
@@ -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;
 	}
 
diff --git a/ell/ecc.c b/ell/ecc.c
index d0c7393..250f7e8 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -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)
diff --git a/ell/gvariant-util.c b/ell/gvariant-util.c
index cf0161a..d6ebb64 100644
--- a/ell/gvariant-util.c
+++ b/ell/gvariant-util.c
@@ -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) {
diff --git a/ell/key.c b/ell/key.c
index 2e4f3e6..62bd72a 100644
--- a/ell/key.c
+++ b/ell/key.c
@@ -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);
 }
 
 /*
diff --git a/ell/queue.c b/ell/queue.c
index 0f6ed3e..86c52ed 100644
--- a/ell/queue.c
+++ b/ell/queue.c
@@ -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;
diff --git a/ell/tls-extensions.c b/ell/tls-extensions.c
index 2e2d9da..6154df0 100644
--- a/ell/tls-extensions.c
+++ b/ell/tls-extensions.c
@@ -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;
 
diff --git a/ell/tls.c b/ell/tls.c
index 6b47bea..5bf6573 100644
--- a/ell/tls.c
+++ b/ell/tls.c
@@ -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);
 }
 
diff --git a/tools/gpio.c b/tools/gpio.c
index 0fdb31e..0db596e 100644
--- a/tools/gpio.c
+++ b/tools/gpio.c
@@ -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();
 }
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] ell: cast printf call to double
  2020-07-21 22:39 [PATCH 1/3] ell: cast printf call to double Rosen Penev
  2020-07-21 22:39 ` [PATCH 2/3] ell: match declaration names Rosen Penev
  2020-07-21 22:39 ` [PATCH 3/3] ell: don't use else after return Rosen Penev
@ 2020-07-22 12:51 ` Thomas Petazzoni
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2020-07-22 12:51 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

On Tue, 21 Jul 2020 15:39:57 -0700
Rosen Penev <rosenp@gmail.com> wrote:

> %f confusingly enough takes a bool, not a float.

takes a _double_, most likely not a bool :-)

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-22 12:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 22:39 [PATCH 1/3] ell: cast printf call to double Rosen Penev
2020-07-21 22:39 ` [PATCH 2/3] ell: match declaration names Rosen Penev
2020-07-21 22:39 ` [PATCH 3/3] ell: don't use else after return Rosen Penev
2020-07-22 12:51 ` [PATCH 1/3] ell: cast printf call to double Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.