Message ID | aad3b9659ba36e372ddf213a5fcc10c30960bf07.1592119902.git.liu.denton@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/3] remote-curl: use strlen() instead of magic numbers | expand |
diff --git a/remote-curl.c b/remote-curl.c index 75532a8bae..5536372b34 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -596,10 +596,10 @@ static int rpc_read_from_out(struct rpc_state *rpc, int options, set_packet_header(buf - 4, *appended); break; case PACKET_READ_DELIM: - memcpy(buf - 4, "0001", 4); + memcpy(buf - strlen("0001"), "0001", strlen("0001")); break; case PACKET_READ_FLUSH: - memcpy(buf - 4, "0000", 4); + memcpy(buf - strlen("0000"), "0000", strlen("0000")); break; case PACKET_READ_RESPONSE_END: die(_("remote server sent stateless separator"));
When we are memcpy()ing the length header, we use the magic literal `4`, representing the length of "0000" and "0001", the packet line length headers. Use `strlen("000x")` so that we do not have to use the magic literal. Signed-off-by: Denton Liu <liu.denton@gmail.com> --- remote-curl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)