The following reply was made to PR kern/189845; it has been noted by GNATS.
From: Jilles Tjoelker <jilles@stack.nl>
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
_______________________________________________
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscribe@freebsd.org"