Skip to content

Commit 3d91352

Browse files
meyeringgitster
authored andcommitted
use write_str_in_full helper to avoid literal string lengths
This is the same fix to use write_str_in_full() helper to write a constant string out without counting the length of it ourselves. Signed-off-by: Jim Meyering <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd03eeb commit 3d91352

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

transport-helper.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ static struct child_process *get_helper(struct transport *transport)
3737
die("Unable to run helper: git %s", helper->argv[0]);
3838
data->helper = helper;
3939

40-
strbuf_addstr(&buf, "capabilities\n");
41-
write_in_full(helper->in, buf.buf, buf.len);
42-
strbuf_reset(&buf);
40+
write_str_in_full(helper->in, "capabilities\n");
4341

4442
file = fdopen(helper->out, "r");
4543
while (1) {
@@ -58,7 +56,7 @@ static int disconnect_helper(struct transport *transport)
5856
{
5957
struct helper_data *data = transport->data;
6058
if (data->helper) {
61-
write_in_full(data->helper->in, "\n", 1);
59+
write_str_in_full(data->helper->in, "\n");
6260
close(data->helper->in);
6361
finish_command(data->helper);
6462
free((char *)data->helper->argv[0]);
@@ -124,9 +122,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
124122

125123
helper = get_helper(transport);
126124

127-
strbuf_addstr(&buf, "list\n");
128-
write_in_full(helper->in, buf.buf, buf.len);
129-
strbuf_reset(&buf);
125+
write_str_in_full(helper->in, "list\n");
130126

131127
file = fdopen(helper->out, "r");
132128
while (1) {

0 commit comments

Comments
 (0)