Received: from eggs.gnu.org ([208.118.235.92]:59516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJjL3-0002NL-0g for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:11:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJjL1-0003Qe-WD for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:11:32 -0400 Received: from mx.meyering.net ([88.168.87.75]:57037 helo=hx.meyering.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJjL1-0003QV-J4 for qemu-devel@nongnu.org; Thu, 04 Oct 2012 07:11:31 -0400 From: Jim Meyering Date: Thu, 4 Oct 2012 13:09:58 +0200 Message-Id: <1349349003-15672-16-git-send-email-jim@meyering.net> In-Reply-To: <1349349003-15672-1-git-send-email-jim@meyering.net> References: <1349349003-15672-1-git-send-email-jim@meyering.net> Subject: [Qemu-devel] [PATCHv3 15/20] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Jim Meyering 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. Reviewed-by: Luiz Capitulino Signed-off-by: Jim Meyering --- 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 ce90421..b9f357c 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -828,7 +828,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 address of %s: %s", -- 1.8.0.rc0.18.gf84667d