Skip to contentSkip to conversation

latencystats: fix missing f suffix on literal float

PATCH Applied Tyler Retzlaff 3 participants 4 messages Apr 15, 2024 – May 29, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 latencystats: fix missing f suffix on literal float

Add missing f suffix to floating point literal to avoid warning about truncation from double to float.

Fixes 5cd3cac9ed22 ("latency: added new library for latency stats")
---
 lib/latencystats/rte_latencystats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/latencystats/rte_latencystats.c +1 -1
index 4ea9b0d..cae4b50 100644
@@ -166,7 +166,7 @@ struct latency_stats_nameoff {
 	 * a constant smoothing factor between 0 and 1. The value
 	 * is used below for measuring average latency.
 	 */
-	const float alpha = 0.2;
+	const float alpha = 0.2f;
 
 	now = rte_rdtsc();
 	for (i = 0; i < nb_pkts; i++) {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 17 lines · On Mon, 15 Apr 2024 14:32:26 -0700 Tyler Retzlaff…

Add missing f suffix to floating point literal to avoid warning about truncation from double to float.

Fixes 5cd3cac9ed22 ("latency: added new library for latency stats")
---
 lib/latencystats/rte_latencystats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/latencystats/rte_latencystats.c +0 -0
index 4ea9b0d..cae4b50 100644

lib/latencystats/rte_latencystats.c struct latency_stats_nameoff { · line 172

Quoted 8 lines
lib/latencystats/rte_latencystats.c +1 -1
@@ -166,7 +166,7 @@ struct latency_stats_nameoff {
 	 * a constant smoothing factor between 0 and 1. The value
 	 * is used below for measuring average latency.
 	 */
-	const float alpha = 0.2;
+	const float alpha = 0.2f;
 
 	now = rte_rdtsc();
 	for (i = 0; i < nb_pkts; i++) {

The use of floating point in fast path here is unnecessary. Even without doing the full per-core values, this could just change to an alpha of .25 and use fast fixed point math.

#2 lore raw
Quoted 26 lines · Stephen Hemminger
Quoted 23 lines · On Mon, 15 Apr 2024 14:32:26 -0700 Tyler Retzlaff…

Add missing f suffix to floating point literal to avoid warning about truncation from double to float.

Fixes 5cd3cac9ed22 ("latency: added new library for latency stats")
---
 lib/latencystats/rte_latencystats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/latencystats/rte_latencystats.c +1 -1
index 4ea9b0d..cae4b50 100644
@@ -166,7 +166,7 @@ struct latency_stats_nameoff {
 	 * a constant smoothing factor between 0 and 1. The value
 	 * is used below for measuring average latency.
 	 */
-	const float alpha = 0.2;
+	const float alpha = 0.2f;
 
Quoted 6 lines

lib/latencystats/rte_latencystats.c struct latency_stats_nameoff { · line 172

Quoted 2 lines
lib/latencystats/rte_latencystats.c +0 -0
 	now = rte_rdtsc();
 	for (i = 0; i < nb_pkts; i++) {

The use of floating point in fast path here is unnecessary. Even without doing the full per-core values, this could just change to an alpha of .25 and use fast fixed point math.

agree, though my thoughts are make this code correct optimization is for the maintainer. if they submit an alternate series i can withdraw this patch. otherwise i think we should take it as-is.

#3 lore raw

16/04/2024 01:14, Tyler Retzlaff:

Quoted 20 lines · Stephen Hemminger
Quoted 10 lines
Quoted 7 lines · On Mon, 15 Apr 2024 14:32:26 -0700 Tyler Retzlaff…

Add missing f suffix to floating point literal to avoid warning about truncation from double to float.

Fixes 5cd3cac9ed22 ("latency: added new library for latency stats")
Quoted 8 lines

lib/latencystats/rte_latencystats.c struct latency_stats_nameoff { · line 169

Quoted 4 lines

---

lib/latencystats/rte_latencystats.c +1 -1
-	const float alpha = 0.2;
+	const float alpha = 0.2f;

The use of floating point in fast path here is unnecessary. Even without doing the full per-core values, this could just change to an alpha of .25 and use fast fixed point math.

Quoted 3 lines

agree, though my thoughts are make this code correct optimization is for the maintainer. if they submit an alternate series i can withdraw this patch. otherwise i think we should take it as-is.

OK to fix build warning now.

Applied, thanks.