Re: [PATCH 2/3] CLD: switch network proto from UDP to TCP

Jeff Garzik <[email protected]> Mon, 03 Jan 2011 13:00:30 -0500
Newsgroups org.kernel.vger.hail-devel
Message-ID <[email protected]>
On 01/02/2011 06:32 PM, Pete Zaitcev wrote:
> On Fri, 31 Dec 2010 05:57:28 -0500
> Jeff Garzik<[email protected]>  wrote:
>
>> +	struct cldc_tcp *tcp = private;
>> +	ssize_t rc;
>> +	struct ubbp_header ubbp;
>> +
>> +	memcpy(ubbp.magic, "CLD1", 4);
>> +	ubbp.op_size = (buflen<<  8) | 1;
>> +#ifdef WORDS_BIGENDIAN
>> +	swab32(ubbp.op_size);
>> +#endif
>> +
>> +	rc = write(tcp->fd,&ubbp, sizeof(ubbp));
>
> Why not this:
>
> 	unsigned int n;
>
> 	n = (buflen<<  8) | 1;
> 	ubbp.op_size = GUINT32_TO_LE(n);

Yep.

I used the #ifdef on the read(2) side, where I did not want to create an 
additional var...  then I copied that onto the write(2) side, where it 
is less efficient as you point out.

	Jeff