From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Garzik Subject: Re: [PATCH 2/3] CLD: switch network proto from UDP to TCP Date: Mon, 03 Jan 2011 13:00:30 -0500 Message-ID: <4D220EBE.6030902@garzik.org> References: <20101231105634.GA4210@havoc.gtf.org> <20101231105728.GA4239@havoc.gtf.org> <20110102163232.78eec2f3@lembas.zaitcev.lan> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=pYX2Q36yIhx5fF6nROxNLUTVjLg4K4N8yEJG3tQ9uTw=; b=ENIxyPpakV/qWNOPPeeDGhwwOT8OfYGINyXxXKzIdvaguTB48h1nZA/CXw5rG1dWHc 8wQMF5cmSV3FeYD63Fi7vPHVpRY0jAmRPG2gNcys7i89UK5m/wXx1YXCm5vXCUtNyGyG NBMOJrzjTg5dcr94djZg56OpXzT8Eu0kzpcHI= In-Reply-To: <20110102163232.78eec2f3@lembas.zaitcev.lan> Sender: hail-devel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Pete Zaitcev Cc: hail-devel@vger.kernel.org On 01/02/2011 06:32 PM, Pete Zaitcev wrote: > On Fri, 31 Dec 2010 05:57:28 -0500 > Jeff Garzik 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