From nobody Sun Oct 23 15:18:41 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MwMKt1LgBz4gdKL; Sun, 23 Oct 2022 15:18:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MwMKt0W4Vz3fhG; Sun, 23 Oct 2022 15:18:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666538322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T91bMvf1G+4Eq5gBtQhpfaw+i8UD5DSg4xVwLjyh4Gs=; b=gHNuMZO4Uvg+TAXv9d3m4M3dcsmoPzC92g6IaaEC8pyHOYktquDmpyxqyawxNEgyvNfR+n vWV9HnWuxaY8Y9Lfw3q17mMolkO4zIBs/nT4xsoP+YqK6a4rmQBKntiII8H0qpUObsfFvj S6qE5vSZzSDTrvh06bCKMjTSlDvXr2H/8ALB6Ze6GHGrQ0eJ2DlSlDNGLHdePkBkcJatKj 765R9TY25JtqKvvkPXU1Va9qnqq587mUT1abXOfr6dfkK61Ll6fwEhloNAiGjaGNWXZDPF KmMDakLnudf42O7kBqY8t3HF8E3nfOA3x0QWkJYjoMECTcFUlA4sqCWHN/srKQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MwMKs6k2qzwT1; Sun, 23 Oct 2022 15:18:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29NFIfdl076326; Sun, 23 Oct 2022 15:18:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29NFIfah076325; Sun, 23 Oct 2022 15:18:41 GMT (envelope-from git) Date: Sun, 23 Oct 2022 15:18:41 GMT Message-Id: <202210231518.29NFIfah076325@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c9faf6987406 - main - bhyve: Fix some warnings in the snapshot code List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c9faf6987406781debb06ec5e40aa1de6d11ac4f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666538322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T91bMvf1G+4Eq5gBtQhpfaw+i8UD5DSg4xVwLjyh4Gs=; b=qgI3oUOn052IebCqTFoVm2JnXDzuEISB6Eyp6cOOPOFxJMd2vNiFklhvnBNuJD4aMy1FTw gN1PqinXyocGbxMkDAW3uvpcoc3ranhnXAMkaqUI7JAUUpPkno0jmUfWEvnlTBKTJAaayv 1xpOoEhfl79nnW6NIjWZcvowZGpFz8C6a9qEjvwolpZbrGZ5C+UqRf62dl6Mlf0yv7QUfx KRZ/crYXQEOdoy+wmMUIRtv9J+i6O1sCQ4AV9OQ5PojL1K5/6Z7vSPzy01hjc/9ACiKTxd i070AsNytAhxRHEzZaf5EBEMNHcaB1IteR0UXUXYGbpGK2nDklM6KanJcPE4wA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666538322; a=rsa-sha256; cv=none; b=SC6fDZK6URI6BDRcTiqxlb9l9BDl6kQRpT+0agDj8erZQg+QxvfoSAcvkSz9pW/1g5EwhX MF2carb27ZCrTpwPUAG5odQCzPdZdaYOTfmmEp22PEZpJjghR06clK6A/EbGLKWH3FAkSt K8qZmQQUrg1tEUh/QZoSRpvX1rnkB0zwbpLFC7CAYXHrYGvFT7e1j0kHuUa6MrsAMTNb4N 6cHtzBgxiBHMpcp5CsHoHOv9lIH+dafD5B8f0+mRab/dDTgNi/TmREnrxaIfysJVvcWg5Z 7GJTo39WnSTHmQ4LP9yGdUgKA8JjGgOBbGC7cNKDM/KcDNuFSKwRx5VT1Q89sA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c9faf6987406781debb06ec5e40aa1de6d11ac4f commit c9faf6987406781debb06ec5e40aa1de6d11ac4f Author: Mark Johnston AuthorDate: 2022-10-22 17:41:33 +0000 Commit: Mark Johnston CommitDate: 2022-10-23 15:11:33 +0000 bhyve: Fix some warnings in the snapshot code - Qualify unexported symbols with "static". - Drop some unnecessary and incorrect casts. - Avoid arithmetic on void pointers. - Avoid signed/unsigned comparisons in loops which use nitems() as a bound. No functional change intended. MFC after: 1 week --- usr.sbin/bhyve/pci_emul.c | 2 +- usr.sbin/bhyve/snapshot.c | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c index 2087c6597852..6e584d0b6626 100644 --- a/usr.sbin/bhyve/pci_emul.c +++ b/usr.sbin/bhyve/pci_emul.c @@ -2622,7 +2622,7 @@ pci_emul_dior(struct vmctx *ctx __unused, int vcpu __unused, } #ifdef BHYVE_SNAPSHOT -int +static int pci_emul_snapshot(struct vm_snapshot_meta *meta __unused) { return (0); diff --git a/usr.sbin/bhyve/snapshot.c b/usr.sbin/bhyve/snapshot.c index 881c91973a02..7ec923d6faec 100644 --- a/usr.sbin/bhyve/snapshot.c +++ b/usr.sbin/bhyve/snapshot.c @@ -138,7 +138,7 @@ static sig_t old_winch_handler; _a < _b ? _a : _b; \ }) -const struct vm_snapshot_dev_info snapshot_devs[] = { +static const struct vm_snapshot_dev_info snapshot_devs[] = { { "atkbdc", atkbdc_snapshot, NULL, NULL }, { "virtio-net", pci_snapshot, pci_pause, pci_resume }, { "virtio-blk", pci_snapshot, pci_pause, pci_resume }, @@ -152,7 +152,7 @@ const struct vm_snapshot_dev_info snapshot_devs[] = { { "ahci-cd", pci_snapshot, pci_pause, pci_resume }, }; -const struct vm_snapshot_kern_info snapshot_kern_structs[] = { +static const struct vm_snapshot_kern_info snapshot_kern_structs[] = { { "vhpet", STRUCT_VHPET }, { "vm", STRUCT_VM }, { "vmx", STRUCT_VMX }, @@ -298,13 +298,14 @@ err_load_kdata: static int load_metadata_file(const char *filename, struct restore_state *rstate) { - const ucl_object_t *obj; + ucl_object_t *obj; struct ucl_parser *parser; int err; parser = ucl_parser_new(UCL_PARSER_DEFAULT); if (parser == NULL) { fprintf(stderr, "Failed to initialize UCL parser.\n"); + err = -1; goto err_load_metadata; } @@ -430,7 +431,7 @@ lookup_struct(enum snapshot_req struct_id, struct restore_state *rstate, return (NULL); } - if (ucl_object_type((ucl_object_t *)structs) != UCL_ARRAY) { + if (ucl_object_type(structs) != UCL_ARRAY) { fprintf(stderr, "Object '%s' is not an array.\n", JSON_STRUCT_ARR_KEY); return (NULL); @@ -502,7 +503,7 @@ lookup_dev(const char *dev_name, struct restore_state *rstate, return (NULL); } - if (ucl_object_type((ucl_object_t *)devs) != UCL_ARRAY) { + if (ucl_object_type(devs) != UCL_ARRAY) { fprintf(stderr, "Object '%s' is not an array.\n", JSON_DEV_ARR_KEY); return (NULL); @@ -530,7 +531,7 @@ lookup_basic_metadata_object(struct restore_state *rstate) return (NULL); } - if (ucl_object_type((ucl_object_t *)basic_meta_obj) != UCL_OBJECT) { + if (ucl_object_type(basic_meta_obj) != UCL_OBJECT) { fprintf(stderr, "Object '%s' is not a JSON object.\n", JSON_BASIC_METADATA_KEY); return (NULL); @@ -620,7 +621,7 @@ print_progress(size_t crtval, const size_t maxval) static const size_t len = sizeof(prog_buf); static size_t div; - static char *div_str; + static const char *div_str; static char wip_bar[] = { '/', '-', '\\', '|' }; static int wip_idx = 0; @@ -777,7 +778,7 @@ vm_snapshot_mem_part(const int snapfd, const size_t foff, void *src, return (-1); } - src += done; + src = (uint8_t *)src + done; part_done += done; rem -= done; } @@ -912,8 +913,8 @@ done: int vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate) { + size_t i; int ret; - int i; for (i = 0; i < nitems(snapshot_kern_structs); i++) { ret = vm_restore_kern_struct(ctx, rstate, @@ -925,7 +926,7 @@ vm_restore_kern_structs(struct vmctx *ctx, struct restore_state *rstate) return (0); } -int +static int vm_restore_user_dev(struct vmctx *ctx, struct restore_state *rstate, const struct vm_snapshot_dev_info *info) { @@ -975,8 +976,8 @@ vm_restore_user_dev(struct vmctx *ctx, struct restore_state *rstate, int vm_restore_user_devs(struct vmctx *ctx, struct restore_state *rstate) { + size_t i; int ret; - int i; for (i = 0; i < nitems(snapshot_devs); i++) { ret = vm_restore_user_dev(ctx, rstate, &snapshot_devs[i]); @@ -991,8 +992,8 @@ int vm_pause_user_devs(struct vmctx *ctx) { const struct vm_snapshot_dev_info *info; + size_t i; int ret; - int i; for (i = 0; i < nitems(snapshot_devs); i++) { info = &snapshot_devs[i]; @@ -1011,8 +1012,8 @@ int vm_resume_user_devs(struct vmctx *ctx) { const struct vm_snapshot_dev_info *info; + size_t i; int ret; - int i; for (i = 0; i < nitems(snapshot_devs); i++) { info = &snapshot_devs[i]; @@ -1070,8 +1071,8 @@ done: static int vm_snapshot_kern_structs(struct vmctx *ctx, int data_fd, xo_handle_t *xop) { - int ret, i, error; - size_t offset, buf_size; + int ret, error; + size_t buf_size, i, offset; char *buffer; struct vm_snapshot_meta *meta; @@ -1185,10 +1186,10 @@ vm_snapshot_user_dev(const struct vm_snapshot_dev_info *info, static int vm_snapshot_user_devs(struct vmctx *ctx, int data_fd, xo_handle_t *xop) { - int ret, i; + int ret; off_t offset; void *buffer; - size_t buf_size; + size_t buf_size, i; struct vm_snapshot_meta *meta; buf_size = SNAPSHOT_BUFFER_SIZE;