From nobody Tue May 7 23:13:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1488750332213265.5273174825669; Sun, 5 Mar 2017 13:45:32 -0800 (PST) Received: from localhost ([::1]:40498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckdy5-0003fE-K7 for importer@patchew.org; Sun, 05 Mar 2017 16:45:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckdxf-0003ec-9a for qemu-devel@nongnu.org; Sun, 05 Mar 2017 16:45:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ckdxe-00051L-GQ for qemu-devel@nongnu.org; Sun, 05 Mar 2017 16:45:03 -0500 Received: from mail.kernel.org ([198.145.29.136]:56490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ckdxZ-000509-Kg; Sun, 05 Mar 2017 16:44:57 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5945420212; Sun, 5 Mar 2017 21:44:53 +0000 (UTC) Received: from localhost.localdomain (bzq-109-67-52-244.red.bezeqint.net [109.67.52.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02FD420125; Sun, 5 Mar 2017 21:44:48 +0000 (UTC) From: Krzysztof Kozlowski To: Kevin Wolf , Max Reitz , qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Sun, 5 Mar 2017 23:44:35 +0200 Message-Id: <20170305214435.19656-1-krzk@kernel.org> X-Mailer: git-send-email 2.9.3 X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 198.145.29.136 Subject: [Qemu-devel] [PATCH] block: Constify data passed by pointer to blk_name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Krzysztof Kozlowski Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" blk_name() is not modifying data passed to it through pointer and it returns also a pointer to const so the argument can be made const for code safeness. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- block/block-backend.c | 2 +- include/sysemu/block-backend.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index daa7908d0151..2d2169a5dfb0 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -409,7 +409,7 @@ void monitor_remove_blk(BlockBackend *blk) * Return @blk's name, a non-null string. * Returns an empty string iff @blk is not referenced by the monitor. */ -const char *blk_name(BlockBackend *blk) +const char *blk_name(const BlockBackend *blk) { return blk->name ?: ""; } diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 096c17fce064..d16c85d67b5c 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -91,7 +91,7 @@ int blk_get_refcnt(BlockBackend *blk); void blk_ref(BlockBackend *blk); void blk_unref(BlockBackend *blk); void blk_remove_all_bs(void); -const char *blk_name(BlockBackend *blk); +const char *blk_name(const BlockBackend *blk); BlockBackend *blk_by_name(const char *name); BlockBackend *blk_next(BlockBackend *blk); bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp); --=20 2.9.3