From mboxrd@z Thu Jan 1 00:00:00 1970 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 F37FEC43462 for ; Mon, 5 Apr 2021 15:57:38 +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 BD753613A3 for ; Mon, 5 Apr 2021 15:57:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD753613A3 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.105400.201803 (Exim 4.92) (envelope-from ) id 1lTRbV-0002LF-09; Mon, 05 Apr 2021 15:57:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 105400.201803; Mon, 05 Apr 2021 15:57:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTRbU-0002Kq-MN; Mon, 05 Apr 2021 15:57:28 +0000 Received: by outflank-mailman (input) for mailman id 105400; Mon, 05 Apr 2021 15:57:27 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTRbT-0002Hp-Ab for xen-devel@lists.xenproject.org; Mon, 05 Apr 2021 15:57:27 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lTRbS-0002oL-Nz; Mon, 05 Apr 2021 15:57:26 +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 1lTRbS-00053b-Fh; Mon, 05 Apr 2021 15:57:26 +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=fSnIgvoSjbUt91Rc+3WKbTs8Y6JmyyNkB+9IjjcALAg=; b=49TpKmuxcFkNIHf0NZn/D91QM liDzLY1pqQul9K2C/SIHFl+oM8o+pki3Cl4fUQm2psyk8/+nCbY6jUqjIBBEBzoI4Zap7OFnIWMr5 UKWnKZ9aH40D6z1jqY5HMTS537E5FENgqwyZiQgXenW3kkRonsxeLecm88Ks4xK7sd1Fk=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: julien@xen.org, Julien Grall , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH 07/14] tools/xl: Use const whenever we point to literal strings Date: Mon, 5 Apr 2021 16:57:06 +0100 Message-Id: <20210405155713.29754-8-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 literal strings are not meant to be modified. So we should use const char * rather than char * when we want to store a pointer to them. Signed-off-by: Julien Grall --- tools/xl/xl.h | 8 ++++---- tools/xl/xl_console.c | 2 +- tools/xl/xl_utils.c | 4 ++-- tools/xl/xl_utils.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 137a29077c1e..3052e3db0072 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -21,13 +21,13 @@ #include struct cmd_spec { - char *cmd_name; + const char *cmd_name; int (*cmd_impl)(int argc, char **argv); int can_dryrun; int modifies; - char *cmd_desc; - char *cmd_usage; - char *cmd_option; + const char *cmd_desc; + const char *cmd_usage; + const char *cmd_option; }; struct domain_create { diff --git a/tools/xl/xl_console.c b/tools/xl/xl_console.c index 4e65d7386733..b27f9e013697 100644 --- a/tools/xl/xl_console.c +++ b/tools/xl/xl_console.c @@ -27,7 +27,7 @@ int main_console(int argc, char **argv) uint32_t domid; int opt = 0, num = 0; libxl_console_type type = 0; - char *console_names = "pv, serial, vuart"; + const char *console_names = "pv, serial, vuart"; SWITCH_FOREACH_OPT(opt, "n:t:", NULL, "console", 1) { case 't': diff --git a/tools/xl/xl_utils.c b/tools/xl/xl_utils.c index 4503ac7ea03c..17489d182954 100644 --- a/tools/xl/xl_utils.c +++ b/tools/xl/xl_utils.c @@ -27,7 +27,7 @@ #include "xl.h" #include "xl_utils.h" -void dolog(const char *file, int line, const char *func, char *fmt, ...) +void dolog(const char *file, int line, const char *func, const char *fmt, ...) { va_list ap; char *s = NULL; @@ -248,7 +248,7 @@ void print_bitmap(uint8_t *map, int maplen, FILE *stream) } } -int do_daemonize(char *name, const char *pidfile) +int do_daemonize(const char *name, const char *pidfile) { char *fullname; pid_t child1; diff --git a/tools/xl/xl_utils.h b/tools/xl/xl_utils.h index d98b419f1075..0c337ede954b 100644 --- a/tools/xl/xl_utils.h +++ b/tools/xl/xl_utils.h @@ -123,7 +123,7 @@ int def_getopt(int argc, char * const argv[], const struct option *longopts, const char* helpstr, int reqargs); -void dolog(const char *file, int line, const char *func, char *fmt, ...) +void dolog(const char *file, int line, const char *func, const char *fmt, ...) __attribute__((format(printf,4,5))); void xvasprintf(char **strp, const char *fmt, va_list ap) @@ -143,7 +143,7 @@ uint32_t find_domain(const char *p) __attribute__((warn_unused_result)); void print_bitmap(uint8_t *map, int maplen, FILE *stream); -int do_daemonize(char *name, const char *pidfile); +int do_daemonize(const char *name, const char *pidfile); #endif /* XL_UTILS_H */ /* -- 2.17.1