From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33327 invoked by alias); 16 Feb 2017 02:09:18 -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 33240 invoked by uid 89); 16 Feb 2017 02:09:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:7458110, H*MI:sk:7458110, H*i:sk:7458110, Hx-languages-length:1086 X-Spam-User: qpsmtpd, 2 recipients 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; Thu, 16 Feb 2017 02:09:13 +0000 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF4BE3A769A; Thu, 16 Feb 2017 02:09:13 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D06984D0C; Thu, 16 Feb 2017 02:09:06 +0000 (UTC) Subject: Re: [PATCH, updated] Add support for setting disassembler-options in GDB for POWER, ARM and S390 To: Peter Bergner References: <867f4uccky.fsf@gmail.com> <65f2f8ce-450b-297a-dcab-7a8bc0ebc256@vnet.ibm.com> <77996338-961a-5a69-e41a-f1adbb3b23da@redhat.com> <7458110b-366a-ee02-9668-3ebef0dfd8cf@vnet.ibm.com> Cc: Yao Qi , gdb-patches@sourceware.org, Alan Modra , Ulrich Weigand , Eli Zaretskii , Nick Clifton , binutils From: Pedro Alves Message-ID: <265f32d1-d913-068c-6716-37b3e55da849@redhat.com> Date: Thu, 16 Feb 2017 02:09:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <7458110b-366a-ee02-9668-3ebef0dfd8cf@vnet.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-02/txt/msg00434.txt.bz2 On 02/16/2017 01:58 AM, Peter Bergner wrote: > On 2/15/17 6:21 PM, Pedro Alves wrote: >>> Easily done, as I've been doing just that internally. >>> I'm frightened to say that I'm at v25 and counting. :-( >> >> Internal revisions don't count, only public submissions. :-) > > Well the number of public submissions isn't too far off my > internal patches. :-) :-) >>> Eg: "e500" & "e500mc", "ppc" & "ppc32" and "ppc64", etc. >>> >>> ...which strncmp cannot disambiguate, because it doesn't enforce the >>> two strings have the same length. >> >> You could handle that with: >> >> if (optlen == strlen (valid_options->name[i]) >> && strncmp (opt, optlen, valid_options->name[i]) == 0) > > Yes, but that involves two scans over the string, so... This is far from performance critical code, but if you're worried about the double-scan, then you could write it like this: if (strncmp (opt, valid_options->name[i], optlen) == 0 && valid_options->name[optlen] == '\0') Thanks, Pedro Alves