git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] test-path-utils: use a C89 compatible format for double printf

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
Aug 9, 2021, 07:25 UTC
Message-ID
<20210809072551.94391-1-carenas@gmail.com>
In-Reply-To
<20210809063004.73736-1-carenas@gmail.com>

a62f9d1ace (test-path-utils: offer to run a protectNTFS/protectHFS benchmark, 2019-09-04) add a tool for testing that uses a double variable to keep track of time but prints them with "%lf".

while correct for newer C standards, it is not defined in C89 and it is not needed, since both float and double will be promoted to double by printf and should therefore use "%f"; change it accordingly.

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 t/helper/test-path-utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 229ed416b0..3d33d2a3e7 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -275,18 +275,18 @@ static int protect_ntfs_hfs_benchmark(int argc, const char **argv)
 				for (j = 0; j < nr; j++)
 					verify_path(names[j], file_mode);
 				end = getnanotime();
-				printf("protect_ntfs = %d, protect_hfs = %d: %lfms\n", protect_ntfs, protect_hfs, (end-begin) / (double)1e6);
+				printf("protect_ntfs = %d, protect_hfs = %d: %fms\n", protect_ntfs, protect_hfs, (end-begin) / (double)1e6);
 				cumul += end - begin;
 				cumul2 += (end - begin) * (end - begin);
 			}
 			m[protect_ntfs][protect_hfs] = cumul / (double)repetitions;
 			v[protect_ntfs][protect_hfs] = my_sqrt(cumul2 / (double)repetitions - m[protect_ntfs][protect_hfs] * m[protect_ntfs][protect_hfs]);
-			printf("mean: %lfms, stddev: %lfms\n", m[protect_ntfs][protect_hfs] / (double)1e6, v[protect_ntfs][protect_hfs] / (double)1e6);
+			printf("mean: %fms, stddev: %fms\n", m[protect_ntfs][protect_hfs] / (double)1e6, v[protect_ntfs][protect_hfs] / (double)1e6);
 		}
 
 	for (protect_ntfs = 0; protect_ntfs < 2; protect_ntfs++)
 		for (protect_hfs = 0; protect_hfs < 2; protect_hfs++)
-			printf("ntfs=%d/hfs=%d: %lf%% slower\n", protect_ntfs, protect_hfs, (m[protect_ntfs][protect_hfs] - m[0][0]) * 100 / m[0][0]);
+			printf("ntfs=%d/hfs=%d: %f%% slower\n", protect_ntfs, protect_hfs, (m[protect_ntfs][protect_hfs] - m[0][0]) * 100 / m[0][0]);
 
 	return 0;
 }
-- 
2.33.0.rc1.373.gc715f1a457
Previous: Carlo Marcelo Arenas BelónNext: Jeff Hostetler
Message 4 of 13 in “fsmonitor: fixup to avoid warnings from pedantic”
  1. 0/2 fsmonitor: fixup to avoid warnings from pedanticCarlo Marcelo Arenas Belón, Aug 9, 2021
  2. 1/2 fixup! fsmonitor-ipc: create client routines for git-fsmonitor--daemonCarlo Marcelo Arenas Belón, Aug 9, 2021
  3. 2/2 fixup! fsmonitor--daemon: implement handle_client callbackCarlo Marcelo Arenas Belón, Aug 9, 2021
  4. test-path-utils: use a C89 compatible format for double printfCarlo Marcelo Arenas Belón, Aug 9, 2021
  5. Jeff HostetlerAug 9, 2021
  6. Junio C HamanoAug 9, 2021
  7. Carlo ArenasAug 10, 2021
  8. Jeff HostetlerAug 10, 2021
  9. Jeff HostetlerAug 10, 2021
  10. Junio C HamanoAug 27, 2021
  11. Carlo ArenasAug 27, 2021
  12. Junio C HamanoAug 27, 2021
  13. Carlo ArenasAug 28, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.