From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS75X-0006ZD-Lq for qemu-devel@nongnu.org; Wed, 09 May 2012 09:38:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SS75R-0001kA-Eu for qemu-devel@nongnu.org; Wed, 09 May 2012 09:37:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SS75R-0001jz-6z for qemu-devel@nongnu.org; Wed, 09 May 2012 09:37:49 -0400 Date: Wed, 9 May 2012 10:37:49 -0300 From: Luiz Capitulino Message-ID: <20120509103749.02b4b62a@doriath.home> In-Reply-To: <1336555446-20180-17-git-send-email-jim@meyering.net> References: <1336555446-20180-1-git-send-email-jim@meyering.net> <1336555446-20180-17-git-send-email-jim@meyering.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 16/22] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jim Meyering Cc: Jim Meyering , Michal Privoznik , qemu-devel@nongnu.org, Michael Roth On Wed, 9 May 2012 11:24:00 +0200 Jim Meyering wrote: > From: Jim Meyering > > NUL-termination of the .ifr_name field is not required, but is fine > (and preferable to using strncpy and leaving the reader to wonder), > since the first thing the linux kernel does is to clear the last byte. > Besides, using pstrcpy here makes this setting of ifr_name consistent > with the other code (e.g., net/tap-linux.c) that does the same thing. > > Signed-off-by: Jim Meyering Reviewed-by: Luiz Capitulino > --- > qga/commands-posix.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/qga/commands-posix.c b/qga/commands-posix.c > index d58730a..7112984 100644 > --- a/qga/commands-posix.c > +++ b/qga/commands-posix.c > @@ -786,7 +786,7 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) > } > > memset(&ifr, 0, sizeof(ifr)); > - strncpy(ifr.ifr_name, info->value->name, IF_NAMESIZE); > + pstrcpy(ifr.ifr_name, IF_NAMESIZE, info->value->name); > if (ioctl(sock, SIOCGIFHWADDR, &ifr) == -1) { > snprintf(err_msg, sizeof(err_msg), > "failed to get MAC addres of %s: %s",