Thread (1 message) 1 message, 1 author, 2016-10-06

Re: [PATCH v9 09/14] pkt-line: add packet_write_gently()

From: Junio C Hamano <hidden>
Date: 2016-10-06 17:26:00

Lars Schneider [off-list ref] writes:
You are right. Would the solution below be acceptable?
I would like to keep the `packet_size` variable as it eases the rest
of the function.

 
 	const size_t packet_size = size + 4;
 
-	if (packet_size > sizeof(packet_write_buffer))
+	if (size > sizeof(packet_write_buffer) - 4)
 		return error("packet write failed - data exceeds max packet size");
Sounds fine; packet_size may have invalid value if size is large
enough but in such a case the function would return without using
it, so no harm is expected, I would say.  I'd prefer to see the
definition of packet_size separate from the assignment of size + 4
to it in a case like this, though.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help