git: 225d3b0771d8 - stable/13 - libvmmapi: Fix warnings and stop overridding WARNS

Mark Johnston markj at FreeBSD.org
Mon Aug 2 19:01:29 UTC 2021


The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=225d3b0771d895a7b101e9349cf607ed86c06f6a

commit 225d3b0771d895a7b101e9349cf607ed86c06f6a
Author:     Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-07-26 20:40:16 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-08-02 19:01:02 +0000

    libvmmapi: Fix warnings and stop overridding WARNS
    
    - Avoid shadowing the global optarg.
    - Sprinkle __unused.
    - Cast nitems() to int.
    - Fix sign in vm_copy_setup().
    
    Reviewed by:    grehan
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 45cd18ec73dcd262612898bf1a263cacde17d348)
---
 lib/libvmmapi/Makefile |  2 --
 lib/libvmmapi/vmmapi.c | 34 +++++++++++++++++-----------------
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/lib/libvmmapi/Makefile b/lib/libvmmapi/Makefile
index bf17566a0d7d..9c410833e09c 100644
--- a/lib/libvmmapi/Makefile
+++ b/lib/libvmmapi/Makefile
@@ -5,8 +5,6 @@ LIB=	vmmapi
 SRCS=	vmmapi.c vmmapi_freebsd.c
 INCS=	vmmapi.h
 
-WARNS?=	2
-
 LIBADD=	util
 
 CFLAGS+= -I${.CURDIR}
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 5810274c9a73..0543c92f4300 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -111,7 +111,7 @@ vm_create(const char *name)
 	/* Try to load vmm(4) module before creating a guest. */
 	if (modfind("vmm") < 0)
 		kldload("vmm");
-	return (CREATE((char *)name));
+	return (CREATE(name));
 }
 
 struct vmctx *
@@ -153,14 +153,14 @@ vm_destroy(struct vmctx *vm)
 }
 
 int
-vm_parse_memsize(const char *optarg, size_t *ret_memsize)
+vm_parse_memsize(const char *opt, size_t *ret_memsize)
 {
 	char *endptr;
 	size_t optval;
 	int error;
 
-	optval = strtoul(optarg, &endptr, 0);
-	if (*optarg != '\0' && *endptr == '\0') {
+	optval = strtoul(opt, &endptr, 0);
+	if (*opt != '\0' && *endptr == '\0') {
 		/*
 		 * For the sake of backward compatibility if the memory size
 		 * specified on the command line is less than a megabyte then
@@ -171,7 +171,7 @@ vm_parse_memsize(const char *optarg, size_t *ret_memsize)
 		*ret_memsize = optval;
 		error = 0;
 	} else
-		error = expand_number(optarg, ret_memsize);
+		error = expand_number(opt, ret_memsize);
 
 	return (error);
 }
@@ -729,7 +729,7 @@ vm_inject_exception(struct vmctx *ctx, int vcpu, int vector, int errcode_valid,
 }
 
 int
-vm_apicid2vcpu(struct vmctx *ctx, int apicid)
+vm_apicid2vcpu(struct vmctx *ctx __unused, int apicid)
 {
 	/*
 	 * The apic id associated with the 'vcpu' has the same numerical value
@@ -907,7 +907,7 @@ vm_capability_name2type(const char *capname)
 {
 	int i;
 
-	for (i = 0; i < nitems(capstrmap); i++) {
+	for (i = 0; i < (int)nitems(capstrmap); i++) {
 		if (strcmp(capstrmap[i], capname) == 0)
 			return (i);
 	}
@@ -918,7 +918,7 @@ vm_capability_name2type(const char *capname)
 const char *
 vm_capability_type2name(int type)
 {
-	if (type >= 0 && type < nitems(capstrmap))
+	if (type >= 0 && type < (int)nitems(capstrmap))
 		return (capstrmap[type]);
 
 	return (NULL);
@@ -1366,8 +1366,8 @@ vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
     int *fault)
 {
 	void *va;
-	uint64_t gpa;
-	int error, i, n, off;
+	uint64_t gpa, off;
+	int error, i, n;
 
 	for (i = 0; i < iovcnt; i++) {
 		iov[i].iov_base = 0;
@@ -1381,7 +1381,7 @@ vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
 			return (error);
 
 		off = gpa & PAGE_MASK;
-		n = min(len, PAGE_SIZE - off);
+		n = MIN(len, PAGE_SIZE - off);
 
 		va = vm_map_gpa(ctx, gpa, n);
 		if (va == NULL)
@@ -1399,14 +1399,14 @@ vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
 }
 
 void
-vm_copy_teardown(struct vmctx *ctx, int vcpu, struct iovec *iov, int iovcnt)
+vm_copy_teardown(struct vmctx *ctx __unused, int vcpu __unused,
+    struct iovec *iov __unused, int iovcnt __unused)
 {
-
-	return;
 }
 
 void
-vm_copyin(struct vmctx *ctx, int vcpu, struct iovec *iov, void *vp, size_t len)
+vm_copyin(struct vmctx *ctx __unused, int vcpu __unused, struct iovec *iov,
+    void *vp, size_t len)
 {
 	const char *src;
 	char *dst;
@@ -1426,8 +1426,8 @@ vm_copyin(struct vmctx *ctx, int vcpu, struct iovec *iov, void *vp, size_t len)
 }
 
 void
-vm_copyout(struct vmctx *ctx, int vcpu, const void *vp, struct iovec *iov,
-    size_t len)
+vm_copyout(struct vmctx *ctx __unused, int vcpu __unused, const void *vp,
+    struct iovec *iov, size_t len)
 {
 	const char *src;
 	char *dst;


More information about the dev-commits-src-branches mailing list