From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7475 invoked by alias); 17 Sep 2012 10:33:42 -0000 Received: (qmail 7467 invoked by uid 22791); 17 Sep 2012 10:33:41 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_EG X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 17 Sep 2012 10:33:27 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1TDYdq-0007S9-Js from Yao_Qi@mentor.com ; Mon, 17 Sep 2012 03:33:26 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 17 Sep 2012 03:33:26 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Mon, 17 Sep 2012 03:33:25 -0700 Message-ID: <5056FC44.8090207@codesourcery.com> Date: Mon, 17 Sep 2012 10:33:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Siddhesh Poyarekar CC: Subject: Re: [obv][commit] Replace one/two use variables with their values References: <20120917143102.467b3fce@spoyarek> In-Reply-To: <20120917143102.467b3fce@spoyarek> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit 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: 2012-09/txt/msg00311.txt.bz2 On 09/17/2012 05:01 PM, Siddhesh Poyarekar wrote: > Hi, > > I have committed another obvious patch that replaces variables that are > used just once or twice, directly with their values. > What is your motivation of this change? Does this patch suggest that we'd better use marcro rather than local variables? I understand most of it, but ... > @@ -330,12 +327,11 @@ > if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE > (type)) > 0) { > elttype = check_typedef (TYPE_TARGET_TYPE (type)); > - eltlen = TYPE_LENGTH (elttype); > - len = TYPE_LENGTH (type) / eltlen; > + len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype); > if (options->prettyprint_arrays) > print_spaces_filtered (2 + 2 * recurse, stream); > /* For an array of chars, print with string syntax. */ > - if (eltlen == 1 && > + if (TYPE_LENGTH (elttype) == 1 && > ((TYPE_CODE (elttype) == TYPE_CODE_INT) > || ((current_language->la_language == language_m2) > && (TYPE_CODE (elttype) == TYPE_CODE_CHAR))) > ... this part. We define a local variable 'eltlen', and use it twice. Isn't a common programming practise? I don't object to this patch, but want to know why do we do this change? > =================================================================== > RCS file: /cvs/src/src/gdb/m68k-tdep.c,v > retrieving revision 1.159 > retrieving revision 1.160 > diff -u -r1.159 -r1.160 > --- src/gdb/m68k-tdep.c 2012/07/24 16:37:24 1.159 > +++ src/gdb/m68k-tdep.c 2012/09/17 08:52:18 1.160 > @@ -315,7 +315,6 @@ > m68k_svr4_extract_return_value (struct type *type, struct regcache > *regcache, gdb_byte *valbuf) > { > - int len = TYPE_LENGTH (type); > gdb_byte buf[M68K_MAX_REGISTER_SIZE]; > struct gdbarch *gdbarch = get_regcache_arch (regcache); > struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > @@ -326,7 +325,7 @@ > regcache_raw_read (regcache, M68K_FP0_REGNUM, buf); > convert_typed_floating (buf, fpreg_type, valbuf, type); > } > - else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4) > + else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == > 4) regcache_raw_read (regcache, M68K_A0_REGNUM, valbuf); b.t.w, looks your mailer wrap your patch incorrectly. -- Yao