_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); Fix: All error message code can be removed from _kvm_open because none of it is used anyway.
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
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped
Closing per comment 1.