@matheusbsbs / matheus-bagliano / commits / 3d913526b1
Fork 0

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 <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jim Meyering committed Sep 12, 2009 at 10:54 UTC 3d913526b19545eb4e463f96d2f3b8db8daae6ef
1 file changed +3 -7
transport-helper.c
+3 -7
@@ -37,9 +37,7 @@ static struct child_process *get_helper(struct transport *transport)
37 die("Unable to run helper: git %s", helper->argv[0]);
38 data->helper = helper;
39
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");
41
42 file = fdopen(helper->out, "r");
43 while (1) {
@@ -58,7 +56,7 @@ static int disconnect_helper(struct transport *transport)
56 {
57 struct helper_data *data = transport->data;
58 if (data->helper) {
61 - write_in_full(data->helper->in, "\n", 1);
59 + write_str_in_full(data->helper->in, "\n");
60 close(data->helper->in);
61 finish_command(data->helper);
62 free((char *)data->helper->argv[0]);
@@ -124,9 +122,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
122
123 helper = get_helper(transport);
124
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");
126
127 file = fdopen(helper->out, "r");
128 while (1) {