From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11805 invoked by alias); 1 Mar 2011 22:03:29 -0000 Received: (qmail 11796 invoked by uid 22791); 1 Mar 2011 22:03:28 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 01 Mar 2011 22:03:24 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 0AA904F054; Tue, 1 Mar 2011 14:03:23 -0800 (PST) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost4.vmware.com (Postfix) with ESMTP id F3271C9FEC; Tue, 1 Mar 2011 14:03:22 -0800 (PST) Message-ID: <4D6D6D2A.6070008@vmware.com> Date: Tue, 01 Mar 2011 22:03:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20101201) MIME-Version: 1.0 To: Pedro Alves CC: "gdb-patches@sourceware.org" Subject: Re: [commit] linespec.c, decode_line_1, check for null. References: <4D6D5DBA.90604@vmware.com> <201103012125.22093.pedro@codesourcery.com> <4D6D687F.8000102@vmware.com> <201103012150.16696.pedro@codesourcery.com> In-Reply-To: <201103012150.16696.pedro@codesourcery.com> Content-Type: multipart/mixed; boundary="------------070803000801070805030709" X-IsSubscribed: yes 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: 2011-03/txt/msg00061.txt.bz2 This is a multi-part message in MIME format. --------------070803000801070805030709 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Content-length: 595 Pedro Alves wrote: > On Tuesday 01 March 2011 21:43:27, Michael Snyder wrote: >> Pedro Alves wrote: >>> On Tuesday 01 March 2011 20:57:30, Michael Snyder wrote: >>>> If it's worth checking for null, it's worth doing so before the first >>>> dereference. >>> Well, then it may not be worth checking for null. How old is >>> that code? >> It predates me, and I've been on gdb since 1995. ;-) > > :-) > > Then I think it's safe to say that if we haven't seen > a NULL-dereference crash in over 15 years, it's because it's > not really necessary. > Ok then -- you'd prefer it like this? --------------070803000801070805030709 Content-Type: text/plain; name="reversenull8.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="reversenull8.txt" Content-length: 1232 2011-03-01 Michael Snyder * linespec.c (decode_line_1): Remove unnecessary null check. Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.111 diff -u -p -u -p -r1.111 linespec.c --- linespec.c 1 Mar 2011 20:57:52 -0000 1.111 +++ linespec.c 1 Mar 2011 22:01:07 -0000 @@ -726,7 +726,7 @@ decode_line_1 (char **argptr, int funfir char *copy; /* This says whether or not something in *ARGPTR is quoted with completer_quotes (i.e. with single quotes). */ - int is_quoted = 0; + int is_quoted; /* Is *ARGPTR is enclosed in double quotes? */ int is_quote_enclosed; int is_objc_method = 0; @@ -745,14 +745,11 @@ decode_line_1 (char **argptr, int funfir /* See if arg is *PC. */ - if (*argptr) - { - if (**argptr == '*') - return decode_indirect (argptr); + if (**argptr == '*') + return decode_indirect (argptr); - is_quoted = (strchr (get_gdb_completer_quote_characters (), - **argptr) != NULL); - } + is_quoted = (strchr (get_gdb_completer_quote_characters (), + **argptr) != NULL); if (is_quoted) end_quote = skip_quoted (*argptr); --------------070803000801070805030709--