From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21039 invoked by alias); 13 Mar 2013 17:29:01 -0000 Received: (qmail 21029 invoked by uid 22791); 13 Mar 2013 17:29:00 -0000 X-SWARE-Spam-Status: No, hits=-7.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Mar 2013 17:28:53 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r2DHSr22025793 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 13 Mar 2013 13:28:53 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r2DHSp2X001899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 13 Mar 2013 13:28:52 -0400 From: Tom Tromey To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [RFC/RFA PATCH] Constify strings in tracepoint.c, lookup_cmd and the completers. References: <20130313123205.31184.43525.stgit@brno.lan> Date: Wed, 13 Mar 2013 17:29:00 -0000 In-Reply-To: <20130313123205.31184.43525.stgit@brno.lan> (Pedro Alves's message of "Wed, 13 Mar 2013 12:32:05 +0000") Message-ID: <87vc8vb44s.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 X-SW-Source: 2013-03/txt/msg00581.txt.bz2 >>>>> "Pedro" == Pedro Alves writes: Pedro> That ended up constifying lookup_cmd/add_cmd and (lots of) friends, Pedro> and the completers. Very nice. I'd like to see it go in. A few trivial nits below. Pedro> I didn't try to constify the command hooks themselves, because I know Pedro> upfront there are commands that write to the command string argument, Pedro> and I think I managed to stop at a nice non-hacky split point already. Yeah, I think changing the commands difficult to do incrementally. I have a trick I'm playing with to let it work file-by-file; but really this just shows that a lot of plumbing has to be constified first... Pedro> I think the only non-really-super-obvious changes are Pedro> tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. In trace_dump_actions, I think that the "line" local variable is now dead, and the code would be clearer if you just removed it. Pedro> +static struct expression * Pedro> +parse_exp_in_context (const char **stringptr, CORE_ADDR pc, const struct block *block, Over-long line. Pedro> +parse_exp_in_context_1 (char **stringptr, CORE_ADDR pc, const struct block *block, Here too. Pedro> @@ -1402,8 +1408,10 @@ x_command (char *exp, int from_tty) Pedro> if (exp && *exp == '/') Pedro> { Pedro> - exp++; Pedro> - fmt = decode_format (&exp, last_format, last_size); Pedro> + const char *tmp = exp + 1; Pedro> + Pedro> + fmt = decode_format (&tmp, last_format, last_size); Pedro> + exp = (char *) tmp; I see x_command can't have the same "char *arg" treatment as display_command: /* Cause expression not to be there any more if this command is repeated with Newline. But don't clobber a user-defined command's definition. */ if (from_tty) *exp = 0; Gross! Tom