Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Aug 2016 15:52:11 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        FreeBSD Current <freebsd-current@FreeBSD.org>
Subject:   amd64-xtoolchain-gcc: small kernel compilation issue
Message-ID:  <0889f99f-b6fd-3768-818e-5b4ca9788229@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
/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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0889f99f-b6fd-3768-818e-5b4ca9788229>