From patchwork Mon Apr 5 15:57:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 12183229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFC8BC43460 for ; Mon, 5 Apr 2021 16:14:58 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82A1961025 for ; Mon, 5 Apr 2021 16:14:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82A1961025 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.105453.201861 (Exim 4.92) (envelope-from ) id 1lTRsA-0005Vl-Nb; Mon, 05 Apr 2021 16:14:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 105453.201861; Mon, 05 Apr 2021 16:14:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTRsA-0005VW-G5; Mon, 05 Apr 2021 16:14:42 +0000 Received: by outflank-mailman (input) for mailman id 105453; Mon, 05 Apr 2021 16:14:39 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTRs7-0005U5-PK for xen-devel@lists.xenproject.org; Mon, 05 Apr 2021 16:14:39 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTRs6-0003f0-O5; Mon, 05 Apr 2021 16:14:38 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTRbY-00053b-0I; Mon, 05 Apr 2021 15:57:32 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1rVbgSKi2I81qCiY+TmphdtF7pMSqnTa8m6g9BTXjUI=; b=QZuh8HPVEcn1Kzdt/lFtkO/nW RtCGPYMVw2cVNrH0epDwZ5Eo55VeWcPPnYZT8x4dAa7KnvS6EKNMGh53IcV1wAp0/Y2tMhN95jMbC tD7vY3/eGnfiQp7Tuz+9FF1nTVSjCvFIfTP0BR/89L2N12L2cY/ZBBtCMBXG2pWY291NI=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Ian Jackson , Wei Liu Subject: [PATCH 12/14] tools/top: The string parameter in set_prompt() and set_delay() should be const Date: Mon, 5 Apr 2021 16:57:11 +0100 Message-Id: <20210405155713.29754-13-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210405155713.29754-1-julien@xen.org> References: <20210405155713.29754-1-julien@xen.org> From: Julien Grall Neither string parameter in set_prompt() and set_delay() are meant to be modified. In particular, new_prompt can point to a literal string. So mark the two parameters as const and propagate it. Signed-off-by: Julien Grall Reviewed-by: Anthony PERARD --- tools/xentop/xentop.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c index ebed070c0fa2..950e8935c4c1 100644 --- a/tools/xentop/xentop.c +++ b/tools/xentop/xentop.c @@ -81,8 +81,8 @@ static int current_row(void); static int lines(void); static void print(const char *, ...) __attribute__((format(printf,1,2))); static void attr_addstr(int attr, const char *str); -static void set_delay(char *value); -static void set_prompt(char *new_prompt, void (*func)(char *)); +static void set_delay(const char *value); +static void set_prompt(const char *new_prompt, void (*func)(const char *)); static int handle_key(int); static int compare(unsigned long long, unsigned long long); static int compare_domains(xenstat_domain **, xenstat_domain **); @@ -212,10 +212,10 @@ int show_vbds = 0; int repeat_header = 0; int show_full_name = 0; #define PROMPT_VAL_LEN 80 -char *prompt = NULL; +const char *prompt = NULL; char prompt_val[PROMPT_VAL_LEN]; int prompt_val_len = 0; -void (*prompt_complete_func)(char *); +void (*prompt_complete_func)(const char *); static WINDOW *cwin; @@ -331,7 +331,7 @@ static void attr_addstr(int attr, const char *str) } /* Handle setting the delay from the user-supplied value in prompt_val */ -static void set_delay(char *value) +static void set_delay(const char *value) { int new_delay; new_delay = atoi(value); @@ -341,7 +341,7 @@ static void set_delay(char *value) /* Enable prompting mode with the given prompt string; call the given function * when a value is available. */ -static void set_prompt(char *new_prompt, void (*func)(char *)) +static void set_prompt(const char *new_prompt, void (*func)(const char *)) { prompt = new_prompt; prompt_val[0] = '\0';