From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15483 invoked by alias); 28 Sep 2012 08:11:18 -0000 Received: (qmail 15468 invoked by uid 22791); 28 Sep 2012 08:11:14 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,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; Fri, 28 Sep 2012 08:11:03 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8S8B1Zb019488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Sep 2012 04:11:01 -0400 Received: from host2.jankratochvil.net (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8S8AuYQ023102 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 28 Sep 2012 04:10:59 -0400 Date: Fri, 28 Sep 2012 08:11:00 -0000 From: Jan Kratochvil To: Mark Kettenis Cc: brobecker@adacore.com, siddhesh@redhat.com, gdb-patches@sourceware.org Subject: Re: [commit][obv] Use TYPE_LENGTH directly where possible Message-ID: <20120928081056.GA22720@host2.jankratochvil.net> References: <20120926132621.5f45acb7@spoyarek> <20120926094227.GA4335@adacore.com> <20120926152740.0900e9b7@spoyarek> <20120926105205.GB4335@adacore.com> <201209280400.q8S40iKO021106@glazunov.sibelius.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201209280400.q8S40iKO021106@glazunov.sibelius.xs4all.nl> User-Agent: Mutt/1.5.21 (2010-09-15) 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/msg00670.txt.bz2 On Fri, 28 Sep 2012 06:00:44 +0200, Mark Kettenis wrote: > > Date: Wed, 26 Sep 2012 12:52:06 +0200 > > From: Joel Brobecker > > I agree it's subjective. Just FYI, my tolerance starts at 2. If I need > > to repeat an expression, I often start thinking about factorizing into > > constants, functions, etc (duplication is not the only part of the > > decision process, so I don't necessarily do it). > > I agree with Joel. Actually my tolerance starts at 1, if it avoids > having lines that are too long or if it reduces the number of nested > parentheses to a more manageable level. In my opinion it cannot be so generalized. In a larger code using 'len' variable may be for example less clear because its value may have become stale after its original 'type' has been updated in the meantime etc. Anyway thanks for the opinions, personally I do not have opinion on these differences. Although I found fine this kind of change (which I pre-approved to Siddhesh as [obv] according to my opinion): ULONGEST val; - int len = TYPE_LENGTH (type); - if (len <= 4) + if (TYPE_LENGTH (type) <= 4) { { possibly more uses of 'len' } But I no longer find fine this kind of change contained in this patch: int len = TYPE_LENGTH (type); ULONGEST c, addr; - switch (len) + switch (TYPE_LENGTH (type)) { because one should not check-in patch which brings the codebase to a state which is not acceptable as the final solution, which this second case acceptable is not. Thanks, Jan