{"thread":{"id":"55169","subject":"[PATCH] test-lib-functions.sh: update comment on generate_zero_bytes()","startedAt":"2021-02-18T12:22:19Z","lastAt":"2021-02-18T18:53:24Z","messageCount":2,"participants":["Rasmus Villemoes","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"417288","messageId":"20210218095750.939746-1-rv@rasmusvillemoes.dk","threadId":"55169","inReplyTo":null,"subject":"[PATCH] test-lib-functions.sh: update comment on generate_zero_bytes()","fromName":"Rasmus Villemoes","fromEmail":"rv@rasmusvillemoes.dk","sentAt":"2021-02-18T09:57:50Z","receivedAt":"2021-02-18T12:22:19Z","isPatch":true,"sender":{"key":"rv@rasmusvillemoes.dk","avatar":"https://avatars.githubusercontent.com/u/4375908?v=4"},"body":"Commit d5cfd142ec (tests: teach the test-tool to generate NUL bytes\nand use it) changed the implementation of this helper, but didn't\npreserve the magic meaning of the word 'infinity' - in fact, since\nstrtol() returns 0 when presented with that string, it ends up\nproducing no output at all. Instead, the C implementation interprets\nlack of optional argument to mean infinity.\n\nSince the last and only user that actually passed 'infinity' vanished\nwith d99194822b (Revert \"t5562: replace /dev/zero with a pipe from\ngenerate_zero_bytes\"), just update the comment to match the\nimplementation, and while there, short-circuit \"forever or X\" to just\nX.\n\nSigned-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>\n---\nI wasn't actually sure what \"$@\" would expand to if a shell function\nis passed no positional arguments (i.e., whether it would end up\npassing a single empty string as argument), but at least the bash man\npage says\n\n    When there are no positional parameters, \"$@\" and $@ expand to\n    nothing (i.e., they are removed).\n\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 07976af81c..0a1e008767 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -117,8 +117,7 @@ remove_cr () {\n }\n \n # Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).\n-# If $1 is 'infinity', output forever or until the receiving pipe stops reading,\n-# whichever comes first.\n+# With no argument, output until the receiving pipe stops reading.\n generate_zero_bytes () {\n \ttest-tool genzeros \"$@\"\n }\n-- \n2.29.2\n\n"},{"id":"417330","messageId":"CAPig+cRhvh2TpSZ-bzjiuCf-Vaf-wr1umb6EAFna3uQxU=oXyw@mail.gmail.com","threadId":"55169","inReplyTo":"20210218095750.939746-1-rv@rasmusvillemoes.dk","subject":"Re: [PATCH] test-lib-functions.sh: update comment on generate_zero_bytes()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-02-18T17:03:55Z","receivedAt":"2021-02-18T18:53:24Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"[cc:+æver]\n\nOn Thu, Feb 18, 2021 at 7:22 AM Rasmus Villemoes <rv@rasmusvillemoes.dk> wrote:\n> Commit d5cfd142ec (tests: teach the test-tool to generate NUL bytes\n> and use it) changed the implementation of this helper, but didn't\n> preserve the magic meaning of the word 'infinity' - in fact, since\n> strtol() returns 0 when presented with that string, it ends up\n> producing no output at all. Instead, the C implementation interprets\n> lack of optional argument to mean infinity.\n>\n> Since the last and only user that actually passed 'infinity' vanished\n> with d99194822b (Revert \"t5562: replace /dev/zero with a pipe from\n> generate_zero_bytes\"), just update the comment to match the\n> implementation, and while there, short-circuit \"forever or X\" to just\n> X.\n\nMakes sense, but note that generate_zero_bytes() is going away\nentirely[1], and that the patch series which removes it is likely to\nbe merged to \"master\" soon[2].\n\n[1]: https://lore.kernel.org/git/20210212132942.17325-5-avarab@gmail.com/\n[2]: https://lore.kernel.org/git/xmqqr1legm5v.fsf@gitster.g/\n"}]}