From owner-freebsd-bugs@FreeBSD.ORG Sun May 18 22:10:01 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 36C68BBC for ; Sun, 18 May 2014 22:10:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 22483201F for ; Sun, 18 May 2014 22:10:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s4IMA0ui086059 for ; Sun, 18 May 2014 22:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s4IMA0tL086058; Sun, 18 May 2014 22:10:00 GMT (envelope-from gnats) Date: Sun, 18 May 2014 22:10:00 GMT Message-Id: <201405182210.s4IMA0tL086058@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Jilles Tjoelker Subject: Re: kern/189845: [kvm] UnNecessary Copy of Error Buffer in _kvm_open Reply-To: Jilles Tjoelker X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2014 22:10:01 -0000 The following reply was made to PR kern/189845; it has been noted by GNATS. From: Jilles Tjoelker To: bug-followup@FreeBSD.org, myron.walker@emc.com Cc: Subject: Re: kern/189845: [kvm] UnNecessary Copy of Error Buffer in _kvm_open Date: Mon, 19 May 2014 00:05:07 +0200 In FreeBSD PR kern/189845, you wrote: > _kvm_open in libkvm always returns 0 on a failure. So writing a > message to kd is pointless because it is immediately passed to > kvm_close() and the memory is freed. Se the code snippet below from > _kvm_open. > /* > * Copy out the error if doing sane error semantics. > */ > if (errout != 0) > strlcpy(errout, kd->errbuf, _POSIX2_LINE_MAX); > (void)kvm_close(kd); > return (0); The error message is written to errout (if _kvm_open() was called via kvm_openfiles()), which stays around. It may be a bit strange to write an error message to kd->errbuf first and then copy it to the user's buffer, but it works fine and may slightly reduce code duplication from the two types of error handling available to the API client. -- Jilles Tjoelker