From nobody Thu Jan 26 19:47:53 2023 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 4P2rpd4Z8Sz3bn9t; Thu, 26 Jan 2023 19:47:53 +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 4P2rpd3Y8pz3D18; Thu, 26 Jan 2023 19:47:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762473; 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=JKYQTLnPcZYyaLmFhuW8sB0D5aX5bra5ryQxsenQM+g=; b=Y6gx2mXI+qx5XNSz/mlON9i5znsOFlSKHHWKoizKDuWEpErJdyaK3MG3dQPIc9hykriGqy UXXIc+vGins3n58NCOtw4XJ6W0QAuLtani0UVYc1j67T16WAaYvTmFStapBcXOwxNCPH2R pju3mDi66h3RNiXrLnBBmezjEUtxVVwQrCdXkP0ozCMhtYRwsG+afq+fnBnZwkJsgOtbQR 29R+OwKxJ3hN8tm4Fy9oht9XP4zLPlMjicsRCsVfERwwTizCfGr+Xk1ozxXwzpR24j9Iux UVm75AzkObh7PeRBb8HDRfMybScMD5Z8s3Iu2aPD/yoo2cVLzDvSNHx2AQPN6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674762473; 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=JKYQTLnPcZYyaLmFhuW8sB0D5aX5bra5ryQxsenQM+g=; b=cR79URgT8K1pnawmwIPMkcf+Vevy6pzNmZ6GCYNWjCnWPtWhsueTtyAlCL7oLntVrbDAQ7 qt4pr8eGx+THorVGHMEEmQftoeqXA9dCdYm4MbTJTrFFSvleXLa7CWHn+anqK5zDBiNFWG 2i6dgFF2+r3jXeyzpygEBVgyeFEILM9vvKdbAHGA8DhO3Rv9sRzuAyZR001RE1DhnzRhl2 bXCtuztNuYx+PD7OdWEawG248XvNLBX91LBXjAprpr79L3oEdFzfIX3aAYJexO890hgM18 5g4PPQVSlPk/agzsYFowS0ldpdrJwsOPF7hSlI8OKv3DY092+5TKvnUHcZv38A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674762473; a=rsa-sha256; cv=none; b=QofOWOfTQd6/tmRNQ3lhm20ccGCHIW7HgEEXJ6YvniMrWCDAsRTGOd8uRr/6Ibg2nlKOxW lOXCWlbU4SnnUhh/DGbXR3C+uAEXp0yeZdY8kZ2ITgdaDD/gGF8NeaBipFQkqTUUjH2IGs 4VoT3m3FM9RfngaOGmQVye5kswdRzAW6cjtSOpErga9vPy8zrgRo2Yi/ka+sPnnpcFu40S zuxsmeYy1mahH6lwFbA0jDF/DGxaKTY0YvlmJjkkSLG+FqloosuPxviPZ8XQP2RSI4+l6U 09xzZOky9asz9uMzAOnFub3DxdXlGsi55BJiDGdn/wsQOkeevDajTBK4UUFntw== 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 4P2rpd2NTfzhky; Thu, 26 Jan 2023 19:47:53 +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 30QJlrmr007216; Thu, 26 Jan 2023 19:47:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QJlrGx007215; Thu, 26 Jan 2023 19:47:53 GMT (envelope-from git) Date: Thu, 26 Jan 2023 19:47:53 GMT Message-Id: <202301261947.30QJlrGx007215@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 826a7bf96193 - stable/13 - 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 826a7bf961935b054b3df98de55843c08ea11bdb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=826a7bf961935b054b3df98de55843c08ea11bdb commit 826a7bf961935b054b3df98de55843c08ea11bdb Author: Mark Johnston AuthorDate: 2022-10-22 17:41:33 +0000 Commit: John Baldwin CommitDate: 2023-01-26 19:31:17 +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 (cherry picked from commit c9faf6987406781debb06ec5e40aa1de6d11ac4f) --- 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 8129ed4c8a44..7c2372a290c6 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;