From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjWU3-0007aB-6K for qemu-devel@nongnu.org; Mon, 03 Jun 2013 11:15:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjWTw-00072x-Jy for qemu-devel@nongnu.org; Mon, 03 Jun 2013 11:15:42 -0400 Received: from mail-ve0-x22d.google.com ([2607:f8b0:400c:c01::22d]:54063) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjWTw-00072r-G6 for qemu-devel@nongnu.org; Mon, 03 Jun 2013 11:15:36 -0400 Received: by mail-ve0-f173.google.com with SMTP id jw11so2953986veb.32 for ; Mon, 03 Jun 2013 08:15:36 -0700 (PDT) Sender: Richard Henderson Message-ID: <51ACB313.60007@twiddle.net> Date: Mon, 03 Jun 2013 08:15:31 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1370193044-24535-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1370193044-24535-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] linux-user: Allow getdents to be provided by getdents64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Riku Voipio , Claudio Fontana , qemu-devel@nongnu.org, patches@linaro.org On 06/02/2013 10:10 AM, Peter Maydell wrote: > + tde->d_ino = tswapal(ino); > + tde->d_off = tswapal(off); > + tde->d_reclen = tswap16(treclen); > + memmove(tde->d_name, de->d_name, namelen + 1); Wouldn't it be better to do the memmove first? Then you really are reading all of the dirent64 data first, like your comment says. > + /* The target_dirent type is in what was formerly a padding > + * byte at the end of the structure: > + */ > + *(((char *)tde) + treclen - 1) = type; Maybe easier to read as ((char *)tde)[treclen - 1] = type ? r~