From owner-svn-src-head@freebsd.org Wed Apr 20 00:48:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF237B13899; Wed, 20 Apr 2016 00:48:08 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-oi0-x22b.google.com (mail-oi0-x22b.google.com [IPv6:2607:f8b0:4003:c06::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 73BF5176A; Wed, 20 Apr 2016 00:48:08 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-oi0-x22b.google.com with SMTP id x201so26247161oif.3; Tue, 19 Apr 2016 17:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc; bh=Crca7+39QE3MZfgnby7i5aVBWEtJyOZoEqw2H3KXPQ0=; b=u+/uyCiO0KMKyJQPGTjAwuSYHVqc8HckMvbeY/o//kooxVcxsbHd0ClQD1GvOL102X 0qV7AnMQpIIB7ZTG5cN066gH2WFP+raJPnlMRNsbXVrB9lgVUwb/M5D5w4e3OkLGfIPG TpIFc4x8vQO4yBoAUCd+KtvVARdFqpGooYoKKI2RvC2UPRKLvdZucRx/Rq5ZTYTkiSpl HEQVE3fdu1uSkSq8LLiDDkquVSUddjlMYbUIWqzCkWg6/glmb8iE/OuvedlI6eRZ8tK2 WfHyOzC4EexD96KFh8MoSR5JDyhM5sB/d/i3sb7l1sfAPEcnbS2GlCaAQR9brDdUqiEs hcCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to:cc; bh=Crca7+39QE3MZfgnby7i5aVBWEtJyOZoEqw2H3KXPQ0=; b=frltztjy3XKJ2x3xvRW1cpmrCes++GkKMmZOEoqeF0CcSBm1+GR03jqnGIUNtUbslh 9GXcnkQkPcI/4TpcQGKvwHwrSpMKUC7X5k5yZ2XtLhiQsvKkNqoImsXkfXoPz7UYYR7z JBEmS97HeZlk0TwWaEKZeLWsBm33dMmXqyJ+iaBMCT3mZ1Nbf2IBReNzH8wL861EJCBG KSnnX88itlQtXmffMZDuCTkqeF8X8pDiYLnME2DDwvFkFO0LBclp6JOqBUKZNEpidLXA gfDZFDU3eX/q5BqEvQRBlkjkNELR7fu2ZEGotxOfkoNaJ720fQDHu8/Xs4u4m9WhVaVM rn+Q== X-Gm-Message-State: AOPr4FVgo4HBeQxij3/3vUyMeHYIDe0qjoIRuMXgy1aE5dsN5SpsvWZcByeswXALISlK1e41Oha8T7nfJyS3Mw== MIME-Version: 1.0 X-Received: by 10.157.3.97 with SMTP id 88mr2776859otv.137.1461113287648; Tue, 19 Apr 2016 17:48:07 -0700 (PDT) Received: by 10.182.156.65 with HTTP; Tue, 19 Apr 2016 17:48:07 -0700 (PDT) Reply-To: araujo@FreeBSD.org In-Reply-To: <4114217.PtcV9LDMal@ralph.baldwin.cx> References: <201604190446.u3J4kD9G050780@repo.freebsd.org> <4114217.PtcV9LDMal@ralph.baldwin.cx> Date: Wed, 20 Apr 2016 08:48:07 +0800 Message-ID: Subject: Re: svn commit: r298247 - head/sbin/fdisk_pc98 From: Marcelo Araujo To: John Baldwin Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Apr 2016 00:48:08 -0000 2016-04-20 0:16 GMT+08:00 John Baldwin : > On Tuesday, April 19, 2016 04:46:13 AM Marcelo Araujo wrote: > > Author: araujo > > Date: Tue Apr 19 04:46:13 2016 > > New Revision: 298247 > > URL: https://svnweb.freebsd.org/changeset/base/298247 > > > > Log: > > Remove redundant parenthesis. > > > > Submitted by: pfg > > MFC after: 2 weeks. > > For this case, it might be better to remove numentries and use > nitems() directly in the one place it is used. I would probably > even do this as a for-loop: > > struct part_type *ptr; > int counter; > > for (counter = 0, ptr = part_types; counter < nitems(part_types); > counter++, ptr++) { > if (ptr->type == (type & 0x7f)) > return (ptr->name); > } > return ("unknown"); > > If you renamed 'counter' to 'i' you could probably fit it all on one line. > > -- > John Baldwin > Hi John, Yeap, make sense! I came up with something like: struct part_type *ptr = part_types; for (int i = 0; i < nitems(part_types); i++) { if (ptr->type == (type & 0x7f)) return (ptr->name); ptr++; } return("unknown"); What do you think? Best, -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_)