amd64-xtoolchain-gcc: small kernel compilation issue

0 views
Skip to first unread message

Andriy Gapon

unread,
Aug 2, 2016, 8:53:57 AM8/2/16
to
/usr/src/sys/modules/vmm/../../amd64/vmm/vmm_dev.c: In function
'alloc_memseg':
/usr/src/sys/modules/vmm/../../amd64/vmm/vmm_dev.c:261:3: error: null
argument where non-null required (argument 1) [-Werror=nonnull]
error = copystr(VM_MEMSEG_NAME(mseg), name, SPECNAMELEN + 1, 0);

This is with amd64-xtoolchain-gcc-0.1, which seems to install gcc
version 5.3.0, and optimization level set to O1.

It seems that in that case gcc is not smart enough to figure out that if
VM_MEMSEG_NAME(mseg) is not NULL in a condition, then it can not be NULL
in a block guarded by the condition.

So, the following trivial patch should not be necessary but makes gcc a
bit happier:
--- a/sys/amd64/vmm/vmm_dev.c
+++ b/sys/amd64/vmm/vmm_dev.c
@@ -258,7 +258,7 @@ alloc_memseg
if (VM_MEMSEG_NAME(mseg)) {
sysmem = false;
name = malloc(SPECNAMELEN + 1, M_VMMDEV, M_WAITOK);
- error = copystr(VM_MEMSEG_NAME(mseg), name, SPECNAMELEN + 1, 0);
+ error = copystr(mseg->name, name, SPECNAMELEN + 1, 0);
if (error)
goto done;
}


--
Andriy Gapon
_______________________________________________
freebsd...@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-curre...@freebsd.org"

Reply all
Reply to author
Forward
0 new messages