From owner-freebsd-scsi@FreeBSD.ORG Tue Jul 23 22:29:42 2013 Return-Path: Delivered-To: scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 66E7590E; Tue, 23 Jul 2013 22:29:42 +0000 (UTC) (envelope-from uqs@FreeBSD.org) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2a01:4f8:131:23c2::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 118782974; Tue, 23 Jul 2013 22:29:41 +0000 (UTC) Received: from localhost (acme.spoerlein.net [IPv6:2a01:4f8:131:23c2::1]) by acme.spoerlein.net (8.14.7/8.14.7) with ESMTP id r6NMTd6q024351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 24 Jul 2013 00:29:40 +0200 (CEST) (envelope-from uqs@FreeBSD.org) Date: Wed, 24 Jul 2013 00:29:39 +0200 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: "Justin T. Gibbs" Subject: Re: Please review patch for aic7xxx_pci.c Message-ID: <20130723222939.GH9030@acme.spoerlein.net> References: <20130716094927.GA9030@acme.spoerlein.net> <20130723071129.GD9030@acme.spoerlein.net> <20130723204530.GE9030@acme.spoerlein.net> <86E509ED-694D-49B0-A3D9-C9C7B71F67CE@FreeBSD.org> <20130723214126.GG9030@acme.spoerlein.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: scsi@freebsd.org X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jul 2013 22:29:42 -0000 On Tue, 2013-07-23 at 16:04:04 -0600, Justin T. Gibbs wrote: > On Jul 23, 2013, at 3:41 PM, Ulrich Spörlein wrote: > > > On Tue, 2013-07-23 at 15:15:53 -0600, Justin T. Gibbs wrote: > >> On Jul 23, 2013, at 2:45 PM, Ulrich Spörlein wrote: > >> > >>> Thanks, but maybe it's better to have the discussion here. > >>> > >>> You wrote: > >>> The difference in the argument order between the declaration and definition is > >>> likely what led to this programming error. Your patch should also correct the > >>> argument reversal in the declaration of ahc_9005_subdevinfo_valid(). > >>> > >>> The argument order you've used seems the best choice since it matches what is > >>> used in ahc_compose_id(). > >>> > >>> > >>> > >>> I'm not sure that reversing the arguments in the function definition is > >>> the right way. This would make the patch a no-op. > >> > >> Read the quote again. I said change the "declaration", not the > >> "definition". To be extremely clear, the code currently looks like > >> this: > > > > D'oh, that's what I get for reading too fast. I've opted to change the > > function definition, in the end, so that declaration, definition and > > call-site are in sync, see > > https://github.com/uqs/freebsd-head/commit/e699b2fde01f235a22e1125e9f3aef16623b512f > > > > Thanks! > > Uli > > But now the order of the arguments does not match ahc_compose_id(). > > It seems to me that we want to only have a single convention in how this > data is passed to functions. Ok, back to the first variant then. commit 1afbac36d5a735b91dfb673abad9635b882d9b4d Author: Ulrich Spörlein Date: Tue Jul 16 11:37:17 2013 +0200 Match function definition to declaration and call-site. SVN r95378 refactored ahc_9005_subdevinfo_valid out into a separate function but swapped the vendor/subvendor and device/subdevice pairs of the parameters. Found by: Coverity Prevent, CID 744931 Reviewed by: gibbs diff --git a/sys/dev/aic7xxx/aic7xxx_pci.c b/sys/dev/aic7xxx/aic7xxx_pci.c index 2bf4927..73df372 100644 --- a/sys/dev/aic7xxx/aic7xxx_pci.c +++ b/sys/dev/aic7xxx/aic7xxx_pci.c @@ -673,8 +673,8 @@ const u_int ahc_num_pci_devs = NUM_ELEMENTS(ahc_pci_ident_table); #define STA 0x08 #define DPR 0x01 -static int ahc_9005_subdevinfo_valid(uint16_t vendor, uint16_t device, - uint16_t subvendor, uint16_t subdevice); +static int ahc_9005_subdevinfo_valid(uint16_t device, uint16_t vendor, + uint16_t subdevice, uint16_t subvendor); static int ahc_ext_scbram_present(struct ahc_softc *ahc); static void ahc_scbram_config(struct ahc_softc *ahc, int enable, int pcheck, int fast, int large); @@ -766,7 +766,7 @@ ahc_find_pci_device(aic_dev_softc_t pci) * ID as valid. */ if (aic_get_pci_function(pci) > 0 - && ahc_9005_subdevinfo_valid(vendor, device, subvendor, subdevice) + && ahc_9005_subdevinfo_valid(device, vendor, subdevice, subvendor) && SUBID_9005_MFUNCENB(subdevice) == 0) return (NULL);