# [PATCH] test-lib-functions.sh: update comment on generate_zero_bytes()

2 messages from 2021-02-18 to 2021-02-18. Participants: Rasmus Villemoes, Eric Sunshine.
Thread: https://gitlist.dev/t/55169

## Rasmus Villemoes, 2021-02-18 09:57

Subject: [PATCH] test-lib-functions.sh: update comment on generate_zero_bytes()
Message-ID: <20210218095750.939746-1-rv@rasmusvillemoes.dk>
URL: https://gitlist.dev/e/20210218095750.939746-1-rv%40rasmusvillemoes.dk

```
Commit d5cfd142ec (tests: teach the test-tool to generate NUL bytes
and use it) changed the implementation of this helper, but didn't
preserve the magic meaning of the word 'infinity' - in fact, since
strtol() returns 0 when presented with that string, it ends up
producing no output at all. Instead, the C implementation interprets
lack of optional argument to mean infinity.

Since the last and only user that actually passed 'infinity' vanished
with d99194822b (Revert "t5562: replace /dev/zero with a pipe from
generate_zero_bytes"), just update the comment to match the
implementation, and while there, short-circuit "forever or X" to just
X.

Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
---
I wasn't actually sure what "$@" would expand to if a shell function
is passed no positional arguments (i.e., whether it would end up
passing a single empty string as argument), but at least the bash man
page says

    When there are no positional parameters, "$@" and $@ expand to
    nothing (i.e., they are removed).

 t/test-lib-functions.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 07976af81c..0a1e008767 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -117,8 +117,7 @@ remove_cr () {
 }
 
 # Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
-# If $1 is 'infinity', output forever or until the receiving pipe stops reading,
-# whichever comes first.
+# With no argument, output until the receiving pipe stops reading.
 generate_zero_bytes () {
 	test-tool genzeros "$@"
 }
-- 
2.29.2


```

## Eric Sunshine, 2021-02-18 17:03

Subject: Re: [PATCH] test-lib-functions.sh: update comment on generate_zero_bytes()
Message-ID: <CAPig+cRhvh2TpSZ-bzjiuCf-Vaf-wr1umb6EAFna3uQxU=oXyw@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcRhvh2TpSZ-bzjiuCf-Vaf-wr1umb6EAFna3uQxU%3DoXyw%40mail.gmail.com
In-Reply-To: <20210218095750.939746-1-rv@rasmusvillemoes.dk>

```
[cc:+æver]

On Thu, Feb 18, 2021 at 7:22 AM Rasmus Villemoes <rv@rasmusvillemoes.dk> wrote:
> Commit d5cfd142ec (tests: teach the test-tool to generate NUL bytes
> and use it) changed the implementation of this helper, but didn't
> preserve the magic meaning of the word 'infinity' - in fact, since
> strtol() returns 0 when presented with that string, it ends up
> producing no output at all. Instead, the C implementation interprets
> lack of optional argument to mean infinity.
>
> Since the last and only user that actually passed 'infinity' vanished
> with d99194822b (Revert "t5562: replace /dev/zero with a pipe from
> generate_zero_bytes"), just update the comment to match the
> implementation, and while there, short-circuit "forever or X" to just
> X.

Makes sense, but note that generate_zero_bytes() is going away
entirely[1], and that the patch series which removes it is likely to
be merged to "master" soon[2].

[1]: https://lore.kernel.org/git/20210212132942.17325-5-avarab@gmail.com/
[2]: https://lore.kernel.org/git/xmqqr1legm5v.fsf@gitster.g/

```
