Displaying 1 50 of 312,791 commits (0.027s)

FreeBSD — stable/10/sys/dev/cxgbe t4_main.c, stable/10/sys/dev/cxgbe/iw_cxgbe cm.c iw_cxgbe.h

MFC r315201, r315920, r315921, r315922, r316008, and r316062.

r315201:
cxgbe(4):  Fix an always-true assertion (reported by PVS-Studio).

sys/dev/cxgbe/t4_main.c: PVS-Studio: Expression is Always True (CWE-571) (3)

r315920:
cxgbe/iw_cxgbe: c4iw_connect should always returns a -ve errno on failure.

r315921:

cxgbe/iw_cxgbe: alloc_ep expects a gfp_t, and it's always ok to sleep during
alloc_ep.

r315922:
cxgbe/iw_cxgbe: allocations that use GFP_KERNEL (which is M_WAITOK on
FreeBSD) cannot fail.

r316008:
cxgbe/iw_cxgbe: Remove unused code.

r316062:
cxgbe/iw_cxgbe: Defer the handling of error CQEs and RDMA_TERMINATE to
the thread that deals with socket state changes.  This eliminates
various bad races with the ithread.

FreeBSD — stable/11/sys/dev/cxgbe t4_main.c, stable/11/sys/dev/cxgbe/iw_cxgbe cm.c iw_cxgbe.h

MFC r315201, r315920, r315921, r315922, r316008, and r316062.

r315201:
cxgbe(4):  Fix an always-true assertion (reported by PVS-Studio).

sys/dev/cxgbe/t4_main.c: PVS-Studio: Expression is Always True (CWE-571) (3)

r315920:
cxgbe/iw_cxgbe: c4iw_connect should always returns a -ve errno on failure.

r315921:

cxgbe/iw_cxgbe: alloc_ep expects a gfp_t, and it's always ok to sleep during
alloc_ep.

r315922:
cxgbe/iw_cxgbe: allocations that use GFP_KERNEL (which is M_WAITOK on
FreeBSD) cannot fail.

r316008:
cxgbe/iw_cxgbe: Remove unused code.

r316062:
cxgbe/iw_cxgbe: Defer the handling of error CQEs and RDMA_TERMINATE to
the thread that deals with socket state changes.  This eliminates
various bad races with the ithread.

FreeBSD — stable/10/etc ntp.conf

MFC r311103 (ian):

Update ntp.conf to use the ntpd pool feature.

Our previous ntp.conf file configured 3 servers from freebsd.pool.ntp.org
using 3 separate 'server' config lines.  That is now replaced with a single
'pool' line which causes ntpd to add multiple servers from the pool.

More than just making the config smaller, the pool feature in ntpd has one
major advantage over configuring 3 separate servers from a pool: if a server
that was added using a 'pool' statement provides bad time (initially or at
some later date), ntpd automatically discards it and configures a new
different server from the pool without needing to be restarted.

These changes also add a 'tos' line to control how many pool servers get
added, a 'restrict source' line that is required to allow ntpd to add new
peers from the pool, and it deletes a 'restrict 127.127.1.0' line that does
nothing and should never have been there (127.127.1.0 is not a valid IP
address, it's a refclock identifier).

Reviewed by:                cy
MFC requested by:        ache
Differential Revision:  https://reviews.freebsd.org/D9011
Delta File
+36 -16 stable/10/etc/ntp.conf
+36 -16 1 file

FreeBSD — stable/11/share/man/man9 sleep.9, stable/11/sys/kern subr_sleepqueue.c kern_umtx.c

MFC r315280 r315287

When the RTC is adjusted, reevaluate absolute sleep times based on the RTC

POSIX 2008 says this about clock_settime(2):

    If the value of the CLOCK_REALTIME clock is set via clock_settime(),
    the new value of the clock shall be used to determine the time
    of expiration for absolute time services based upon the
    CLOCK_REALTIME clock.  This applies to the time at which armed
    absolute timers expire.  If the absolute time requested at the
    invocation of such a time service is before the new value of
    the clock, the time service shall expire immediately as if the
    clock had reached the requested time normally.

    Setting the value of the CLOCK_REALTIME clock via clock_settime()
    shall have no effect on threads that are blocked waiting for
    a relative time service based upon this clock, including the
    nanosleep() function; nor on the expiration of relative timers
    based upon this clock.  Consequently, these time services shall
    expire when the requested relative interval elapses, independently
    of the new or old value of the clock.

When the real-time clock is adjusted, such as by clock_settime(3),
wake any threads sleeping until an absolute real-clock time.

    [18 lines not shown]

FreeBSD — head/sys/boot/arm/uboot Makefile, head/sys/boot/efi/boot1 Makefile

self_reloc.c: Pass -Wno-error=maybe-uninitialized to gcc versions greater than 4.2.1

self_reloc.c doesn't initialize `rel` in all cases in the C code, however, the value
might be initialized properly on the stack in the assembly code.

For right now (because this doesn't seem to be breaking anything and my initializing
the stack value could break something since it's called from assembly code) disable
the warning for self_reloc.c. More investigation should be done to determine the
appropriate response to this warning (either intialize the value or find a smarter
way to deal with the warning).

A long MFC timeout is being set for this change to allow a better solution for the
issue to be developed in that time period.

MFC after:        2 months
Reported by:        Jenkins (FreeBSD-head-amd64-gcc job)
Tested with:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon

FreeBSD — head/sys/dev/cxgbe/iw_cxgbe mem.c

cxgbe/iw_cxgbe: T6 has no limit on the amount of memory that can be
registered in one ib_reg_phys_mr.
Delta File
+5 -2 head/sys/dev/cxgbe/iw_cxgbe/mem.c
+5 -2 1 file

FreeBSD — head/sys/cam/ata ata_da.c

In r289137 the legacy_aliases compatibility shims for ata were removed,
also remove a leftover define used for implementing them.

Reviewed by:        mav
Differential Revision:        https://reviews.freebsd.org/D6726
Delta File
+0 -4 head/sys/cam/ata/ata_da.c
+0 -4 1 file

FreeBSD — head/sys/dev/iwn if_iwn.c

iwn: remove unneeded cast.
Delta File
+4 -4 head/sys/dev/iwn/if_iwn.c
+4 -4 1 file

FreeBSD — head/lib/libcam camlib.c

libcam: use __func__ instead of hardcoding the function name as `func_name`

MFC after:        3 days
Tested with:        `cam_device_copy(NULL, NULL)` // ;)..
Sponsored by:        Dell EMC Isilon
Delta File
+30 -36 head/lib/libcam/camlib.c
+30 -36 1 file

FreeBSD — head/sys/dev/iwn if_iwn.c

iwn: drop duplicate synchronization requests.

Rx descriptor / payload is already synchronized in iwn_notif_intr()
(before accessing desc->type / desc->qid fields).

Tested with Intel 6205, STA mode.
Delta File
+12 -39 head/sys/dev/iwn/if_iwn.c
+12 -39 1 file

FreeBSD — head/sys/dev/ichsmb ichsmb_pci.c

Remove #define PCIS_SERIALBUS_SMBUS_PROGIF, unused since r200091
Delta File
+0 -2 head/sys/dev/ichsmb/ichsmb_pci.c
+0 -2 1 file

FreeBSD — head/sys/boot/common ls.c

loader: ls command should display file types properly

With some file system the ls is unable to display file types.

Reviewed by:        allanjude
Approved by:        allanjude (mentor)
Differential Revision:        https://reviews.freebsd.org/D10066
Delta File
+43 -18 head/sys/boot/common/ls.c
+43 -18 1 file

FreeBSD — head/sys/boot/i386/libi386 time.c pxe.c

loader: move bios getsecs into time.c

Move the time related function into time.c, keep the same logic as libefi.

Reviewed by:        allanjude
Approved by:        allanjude (mentor)
Differential Revision:        https://reviews.freebsd.org/D10058

FreeBSD — head/sys/boot/efi/boot1 Makefile

Use `-Wno-missing-declarations` with CWARNFLAGS for skein.c

`-Wno-missing-variable-declarations` is a clang-specific flag,
so gcc (not 4.2.1, in particular 6.3.0 in my case) dies when
it's passed the flag.

X-MFC with:        r304321
Reported by:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon
Delta File
+4 -0 head/sys/boot/efi/boot1/Makefile
+4 -0 1 file

FreeBSD — head/sys/boot/efi/boot1 Makefile, head/sys/boot/i386/boot2 Makefile

Don't hardcode input files for stage 1/2 bootloaders; use .ALLSRC instead

This is a better pattern to follow when creating the bootloaders and doing
the relevant space checks to make sure that the sizes aren't exceeded (and
thus, copy-pasting is a bit less error prone).

MFC after:        3 days
Sponsored by:        Dell EMC Isilon

FreeBSD — head/sys/boot/common ls.c

Remove -Wunused-but-set variable, `tail` in `ls_getdir(..)`

This variable has been unused since its inception in r40106.

MFC after:        3 days
Reported by:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon
Delta File
+1 -2 head/sys/boot/common/ls.c
+1 -2 1 file

FreeBSD — head/sys/boot/zfs zfsimpl.c

Remove redundant declaration for `zfs_crc64_table`

zfssubr.c already defines this statically. Besides, zfsimpl.c defined it, but
didn't use it.

This fixes a -Wredundant-decls warning.

MFC after:        3 days
Reported by:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon
Delta File
+0 -1 head/sys/boot/zfs/zfsimpl.c
+0 -1 1 file

FreeBSD — head/sys/boot/zfs zfsimpl.c

Don't shadow read(2) definition with `read` argument in vdev_{create,probe}

This fixes several -Wshadow warnings introduced in r192194, but now errors
with gcc 6.3.0.

MFC after:        3 days
Reported by:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon
Delta File
+5 -5 head/sys/boot/zfs/zfsimpl.c
+5 -5 1 file

FreeBSD — head/sbin/nvmecontrol wdc.c

Don't use K&R style prototypes; ANSIfy them

This fixes several -Wold-style-definition warnings.

X-MFC with:        313191
Reported by:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon
Delta File
+3 -3 head/sbin/nvmecontrol/wdc.c
+3 -3 1 file

FreeBSD — head/sys/boot/i386/gptzfsboot Makefile

Use `NO_WCAST_ALIGN` instead of spelling it out as -Wno-cast-align in CFLAGS

MFC after:        3 days
Sponsored by:        Dell EMC Isilon

FreeBSD — head/sys/boot/efi/boot1 boot_module.h boot1.c

Remove redundant declarations

They're already defined in libstand.h

MFC after:        1 week
Reported by:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon

FreeBSD — head/sys/boot/common part.c

Wrap bootcamp DEBUG statement with curly braces

This fixes a -Wempty-body warning with gcc 6.3.0 when PART_DEBUG is undefined.

MFC after:        3 days
Reported by:        Jenkins (FreeBSD-head-amd64-gcc job)
Tested with:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon
Delta File
+2 -1 head/sys/boot/common/part.c
+2 -1 1 file

FreeBSD — head/lib/libgcc_s Makefile

Apply r315689 to lib/libgcc_s as well to unbreak the gcc xtoolchain build

lib/libgcc_s consumes lib/libcompiler_rt/Makefile*. The NO_WERROR.gcc in
lib/libcompiler_rt/Makefile doesn't seem to have made a difference in being
able to build this, so sprinkle NO_WERROR.gcc here as well.

MFC after:        3 days
Reported by:        Jenkins (FreeBSD-head-amd64-gcc)
Tested with:        amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
Sponsored by:        Dell EMC Isilon
Delta File
+4 -0 head/lib/libgcc_s/Makefile
+4 -0 1 file

FreeBSD — head/sys/boot/i386/boot2 Makefile

Remove -fno-guess-branch-probability and -fno-unit-at-a-time.

bde enabled -fno-guess-branch-probability in 2003, well before our
current compiler was imported. At the time it produced weirdly orded
code. It no longer does that. It also saves 0-4 bytes depending on
other options.

kan disabled unit-at-a-time in 2004 because it badly mangled boot2 so
it wouldn't work. That too was before the 4.2.1 compiler, where it no
longer does that. This saves 44 bytes.

I had planned to document why they were needed, but when I discovered
their antiquity, I removed them and boot2 still works and is
smaller. In qemu, the old and new boot2's behaved identically.

These are gcc specific hacks, and won't affect clang-built boot2
at all.
Delta File
+0 -2 head/sys/boot/i386/boot2/Makefile
+0 -2 1 file

FreeBSD — head/etc/mtree BSD.tests.dist, head/lib/libkvm Makefile tests

lib/libkvm: start adding basic tests for kvm(3)

- kvm_close: add a testcase to verify support for errno = EINVAL / -1
  (see D10065) when kd == NULL is provided to the libcall.
- kvm_geterr:
-- Add a negative testcase for kd == NULL returning "" (see D10022).
-- Add two positive testcases:
--- test the error case using kvm_write on a O_RDONLY descriptor.
--- test the "no error" case using kvm_read(3) and kvm_nlist(3) as
    helper routines and by injecting a bogus error message via
    _kvm_err (an internal API) _kvm_err was used as there isn't a
    formalized way to clear the error output, and because
    kvm_nlist always returns ENOENT with the NULL terminator today.
- kvm_open, kvm_open2:
-- Add some basic negative tests for kvm_open(3) and kvm_open2(3).
   Testing positive cases with a specific
   `corefile`/`execfile`/`resolver` requires more work and would require
   user intervention today in order to reliably test this out.

Reviewed by:        markj
MFC after:        2 months
Sponsored by:        Dell EMC Isilon
Differential Revision:        D10024

FreeBSD — stable/11/lib/libnetbsd sockaddr_snprintf.c Makefile, stable/11/usr.bin Makefile getaddrinfo

MFC r315640

Port the getaddrinfo(1) utility from NetBSD.

PR:                183148
Submitted by:        Lohith Bellad <lohithbsd at gmail.com>
Obtained from:        NetBSD
Relnotes:        yes
Sponsored by:        Dell EMC

FreeBSD — stable/10/sbin/swapon swapon.c

MFC r315242: Fix late and noauto with geli swap

With the following in /etc/fstab:

/dev/gpt/swap.eli none swap sw,late 0 0

swap will not be enabled, with `swapon -aL' complaining:

swapon: Invalid option: late

This happens because swap_on_geli_args() which parses geli arguments
out of all mount options does not expect late or noauto among them.
Fix this by explicitly allowing these arguments.

Reviewed by:        jilles
Approved by:        jilles
Differential Revision:        D9835
Delta File
+4 -0 stable/10/sbin/swapon/swapon.c
+4 -0 1 file

FreeBSD — stable/11/sbin/swapon swapon.c

MFC r315242: Fix late and noauto with geli swap

With the following in /etc/fstab:

/dev/gpt/swap.eli none swap sw,late 0 0

swap will not be enabled, with `swapon -aL' complaining:

swapon: Invalid option: late

This happens because swap_on_geli_args() which parses geli arguments
out of all mount options does not expect late or noauto among them.
Fix this by explicitly allowing these arguments.

Reviewed by:        jilles
Approved by:        jilles
Differential Revision:        D9835
Delta File
+5 -1 stable/11/sbin/swapon/swapon.c
+5 -1 1 file

FreeBSD — head/contrib/libarchive FREEBSD-Xlist, head/contrib/libarchive/libarchive archive_disk_acl_freebsd.c archive_read_disk_acl_freebsd.c

MFV r316083,316094:
Sync libarchive with vendor

Vendor changes (FreeBSD-related):
- constify variables in several places
- unify platform ACL code in a single source file
- fix unused variable if compiling on FreeBSD without NFSv4 ACL support

MFC after:        3 days
X-MFC-with:        315636, 315876

FreeBSD — vendor/libarchive/dist Makefile.am, vendor/libarchive/dist/libarchive archive_disk_acl_darwin.c archive_disk_acl_freebsd.c

Update vendor/libarchive to git a04b5adede4022dd593af76cb2fc2e96cb34df91

Vendor changes (FreeBSD-related):
- add missing file from previous merge
- encapsulate platform ACL code in an #ifdef

FreeBSD — stable/10/sys/dev/isp isp.c ispvar.h

MFC r315279: Remove some dead/broken code paths around async handling

FreeBSD — stable/11/sys/dev/isp isp.c isp_freebsd.c

MFC r315273: Remove tangled isp_mbox_continue() mechanism.

It was implemented to reduce context switches when uploading firmware to
card's RAM.  But this mechanism is not used last 10 years since all mbox
operations are now polled, and it was never used for cards produced in
last 15 years.  Newer cards can use DMA to upload firmware.

FreeBSD — stable/10/sys/dev/isp isp.c

MFC r315236: Remove dangerous and questionable isp_mboxcmd_qnw() call.
Delta File
+4 -17 stable/10/sys/dev/isp/isp.c
+4 -17 1 file

FreeBSD — stable/11/sys/dev/isp isp.c

MFC r315236: Remove dangerous and questionable isp_mboxcmd_qnw() call.
Delta File
+4 -17 stable/11/sys/dev/isp/isp.c
+4 -17 1 file

FreeBSD — stable/10/sys/dev/isp isp_pci.c isp.c

MFC r315234: Improvements around attach, reset and detach.

This change fixes DMA resource leak on driver unload.  Also it removes
DMA resources allocation for hardcoded number of requests before fetching
the real number from firmware.  Also it prepares ground for more flexible
IRQs allocation according to firmware capabilities.

FreeBSD — stable/10/sys/dev/isp isp_pci.c isp_sbus.c

MFC r299849 (by trasz):
Remove NULL checks after M_WAITOK allocations from isp(4).

FreeBSD — stable/11/sys/dev/isp isp_pci.c isp.c

MFC r315234: Improvements around attach, reset and detach.

This change fixes DMA resource leak on driver unload.  Also it removes
DMA resources allocation for hardcoded number of requests before fetching
the real number from firmware.  Also it prepares ground for more flexible
IRQs allocation according to firmware capabilities.

FreeBSD — vendor/libarchive/dist/libarchive archive_disk_acl_sunos.c archive_disk_acl_linux.c

Update vendor/libarchive to git 13b0ed2ba504389c363cd302041fe10afa1837ad

Vendor changes (FreeBSD-related):
- constify variables in several places
- unify platform ACL code in a single source file
- fix unused variable if compiling on FreeBSD without NFSv4 ACL support

FreeBSD — head/share/misc bsd-family-tree

DragonFly BSD 4.8.0 release added.
Delta File
+2 -0 head/share/misc/bsd-family-tree
+2 -0 1 file

FreeBSD — head/lib/libcam camlib.c

Use `sizeof(cam_errbuf)` instead of `CAM_ERRBUF_SIZE` in snprintf calls

Reindent snprintf calls' arguments to match style(9) guidelines with
respect to indentation.

MFC after:        3 days
Sponsored by:        Dell EMC Isilon
Delta File
+79 -80 head/lib/libcam/camlib.c
+79 -80 1 file

FreeBSD — head/lib/libcam camlib.h

Fix some localized style(9) issues and reword CAM_ERRBUF_SIZE description

The CAM_ERRBUF_SIZE description rewording fixes a typo by proxy.

MFC after:        3 days
Sponsored by:        Dell EMC Isilon
Delta File
+2 -2 head/lib/libcam/camlib.h
+2 -2 1 file

FreeBSD — head/sys/boot/i386/boot2 Makefile

Simply retire the sedification of the boot2.s file. It's been obsolete
for years.

clang before 96 free after 100 (+4)
gcc before 163 free after 156 (-7)

Suggested by: bde@
Sponsored by: Netflix
Delta File
+1 -17 head/sys/boot/i386/boot2/Makefile
+1 -17 1 file

FreeBSD — head/sys/boot/i386/gptboot gptboot.c

gpt*boot: Save a bit more memory when LOADER_NO_GELI_SUPPORT is specified

Don't compile geliargs into the image and don't pass geliargs to the respective
bootloader code via __exec(..).

This saves a negligible amount of memory/disk space.

X-MFC with:        r296963
Obtained from:        Isilon OneFS
Sponsored by:        Dell EMC Isilon

FreeBSD — head/sys/boot/i386/gptzfsboot Makefile

Unbreak compilation with gcc 4.2.1

-Wtentative-definition-incomplete-type isn't implemented for 4.2.1

X-MFC with:        r304321
Sponsored by:        Dell EMC Isilon

FreeBSD — head/sys/boot/common Makefile.inc module.c

sys/boot/common: Make geli(4) support optional in MI sources

This saves a negligible amount of memory for non-geli enabled
bootloaders.

MFC after:        1 week
Sponsored by:        Dell EMC Isilon

FreeBSD — stable/11/lib/libutil hexdump.3, stable/11/share/man/man9 Makefile

MFC r313436,r313437,r313438,r314587,r315687:

r313436:

Clarify #includes for hexdump(3) vs sbuf_hexdump(9)

hexdump(3) only requires libutil.h, whereas sbuf_hexdump(9) requires
sys/types.h (for ssize_t) and sys/sbuf.h

r313437:

Create link from hexdump(3) to sbuf_hexdump(9) as the manpage describes
sbuf_hexdump(9)'s behavior

r313438:

Clean up trailing and leading whitespace for variables to make it
consistent with the rest of the file and style.Makefile(9) a bit
more

r314587:

Correct MLINKS for sbuf_hexdump(9)

sbuf_hexdump(9) should be linked to sbuf(9), not hexdump(3). Another

    [11 lines not shown]

FreeBSD — stable/10/lib/libutil hexdump.3, stable/10/share/man/man9 Makefile

MFC r313436,r313437,r313438,r314587,r315687:

r313436:

Clarify #includes for hexdump(3) vs sbuf_hexdump(9)

hexdump(3) only requires libutil.h, whereas sbuf_hexdump(9) requires
sys/types.h (for ssize_t) and sys/sbuf.h

r313437:

Create link from hexdump(3) to sbuf_hexdump(9) as the manpage describes
sbuf_hexdump(9)'s behavior

r313438:

Clean up trailing and leading whitespace for variables to make it
consistent with the rest of the file and style.Makefile(9) a bit
more

r314587:

Correct MLINKS for sbuf_hexdump(9)

sbuf_hexdump(9) should be linked to sbuf(9), not hexdump(3). Another

    [11 lines not shown]

FreeBSD — stable/11/sys/dev/drm drm_scatter.c, stable/11/sys/dev/drm2 drm_scatter.c

MFC r315281:
Use atop() instead of OFF_TO_IDX() for convertion of addresses or
addresses offsets, as intended.

MFC r315580 (by alc):
Simplify the logic for clipping the range returned by the pager to fit
within the map entry.
Use atop() rather than OFF_TO_IDX() on addresses.

FreeBSD — stable/10/lib/libkvm kvm_geterr.3 kvm.c

MFC r315686,r315688:

r315686:

kvm_geterr: handle `kd` == NULL in a deterministic/graceful manner

Return a NUL string instead of just working by accident with kvm_geterr(3)
when MALLOC_PRODUCTION is disabled (I didn't confirm the MALLOC_PRODUCTION
being enabled path).

Document the new explicit return behavior for kvm_geterr(3), as well
as the previous implicit behavior, i.e., the buffer attached to
returned via kvm_geterr(3) would be empty if a previous error hadn't been
stored in `kd`.

r315688:

kvm_write: fix -Wcast-qual warning in pointer arithmetic argument

Cast buf to `const char *` when doing arithmetic operation to match
`cp`'s type [1].

FreeBSD — stable/11/lib/libkvm kvm_geterr.3 kvm.c

MFC r315686,r315688:

r315686:

kvm_geterr: handle `kd` == NULL in a deterministic/graceful manner

Return a NUL string instead of just working by accident with kvm_geterr(3)
when MALLOC_PRODUCTION is disabled (I didn't confirm the MALLOC_PRODUCTION
being enabled path).

Document the new explicit return behavior for kvm_geterr(3), as well
as the previous implicit behavior, i.e., the buffer attached to
returned via kvm_geterr(3) would be empty if a previous error hadn't been
stored in `kd`.

r315688:

kvm_write: fix -Wcast-qual warning in pointer arithmetic argument

Cast buf to `const char *` when doing arithmetic operation to match
`cp`'s type [1].