From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112699 invoked by alias); 4 Apr 2017 17:26:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 112320 invoked by uid 89); 4 Apr 2017 17:26:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Apr 2017 17:26:06 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED792C04B956 for ; Tue, 4 Apr 2017 17:26:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED792C04B956 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED792C04B956 Received: from cascais.lan (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 795B618247 for ; Tue, 4 Apr 2017 17:26:05 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 09/18] -Wwrite-strings: MI -info-os Date: Tue, 04 Apr 2017 17:26:00 -0000 Message-Id: <1491326751-16180-10-git-send-email-palves@redhat.com> In-Reply-To: <1491326751-16180-1-git-send-email-palves@redhat.com> References: <1491326751-16180-1-git-send-email-palves@redhat.com> X-SW-Source: 2017-04/txt/msg00035.txt.bz2 -Wwrite-strings flags this attempt to convert a string literal to "char *": info_osdata_command ("", 0); info_osdata_command is a command function. We could address this by simply passing NULL instead of "". However, I went a little bit further and added a new function that is called by both the CLI and MI. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * mi/mi-cmd-info.c (mi_cmd_info_os): Call info_osdata instead of info_osdata_command. * osdata.c (info_osdata_command): Rename to ... (info_osdata): ... this. Constify 'type' parameter, and remove the 'from_tty' parameter. Accept NULL TYPE. (info_osdata_command): New function. * osdata.h (info_osdata_command): Remove declaration. (info_osdata): New declaration. --- gdb/mi/mi-cmd-info.c | 4 ++-- gdb/osdata.c | 13 +++++++++++-- gdb/osdata.h | 6 +++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gdb/mi/mi-cmd-info.c b/gdb/mi/mi-cmd-info.c index eba1ca2..1a96d6f 100644 --- a/gdb/mi/mi-cmd-info.c +++ b/gdb/mi/mi-cmd-info.c @@ -106,10 +106,10 @@ mi_cmd_info_os (const char *command, char **argv, int argc) switch (argc) { case 0: - info_osdata_command ("", 0); + info_osdata (NULL); break; case 1: - info_osdata_command (argv[0], 0); + info_osdata (argv[0]); break; default: error (_("Usage: -info-os [INFOTYPE]")); diff --git a/gdb/osdata.c b/gdb/osdata.c index d63ff5a..4b33ccb 100644 --- a/gdb/osdata.c +++ b/gdb/osdata.c @@ -287,7 +287,7 @@ get_osdata_column (struct osdata_item *item, const char *name) } void -info_osdata_command (char *type, int from_tty) +info_osdata (const char *type) { struct ui_out *uiout = current_uiout; struct osdata *osdata = NULL; @@ -297,12 +297,15 @@ info_osdata_command (char *type, int from_tty) int nrows; int col_to_skip = -1; + if (type == NULL) + type = ""; + osdata = get_osdata (type); old_chain = make_cleanup_osdata_free (osdata); nrows = VEC_length (osdata_item_s, osdata->items); - if (!type && nrows == 0) + if (*type == '\0' && nrows == 0) error (_("Available types of OS data not reported.")); if (!VEC_empty (osdata_item_s, osdata->items)) @@ -407,6 +410,12 @@ info_osdata_command (char *type, int from_tty) do_cleanups (old_chain); } +static void +info_osdata_command (char *arg, int from_tty) +{ + info_osdata (arg); +} + extern initialize_file_ftype _initialize_osdata; /* -Wmissing-prototypes */ void diff --git a/gdb/osdata.h b/gdb/osdata.h index bda0112..5921384 100644 --- a/gdb/osdata.h +++ b/gdb/osdata.h @@ -49,6 +49,10 @@ void osdata_free (struct osdata *); struct cleanup *make_cleanup_osdata_free (struct osdata *data); struct osdata *get_osdata (const char *type); const char *get_osdata_column (struct osdata_item *item, const char *name); -void info_osdata_command (char *type, int from_tty); + +/* Dump TYPE info to the current uiout builder. If TYPE is either + NULL or empty, then dump the top level table that lists the + available types of OS data. */ +void info_osdata (const char *type); #endif /* OSDATA_H */ -- 2.5.5