From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753151AbbIJGRO (ORCPT ); Thu, 10 Sep 2015 02:17:14 -0400 Received: from mail-bn1on0119.outbound.protection.outlook.com ([157.56.110.119]:62023 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751594AbbIJGRM convert rfc822-to-8bit (ORCPT ); Thu, 10 Sep 2015 02:17:12 -0400 From: Yuantian Tang To: Tejun Heo CC: "hdegoede@redhat.com" , "linux-ide@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" Subject: RE: [PATCH] ahci: qoriq: fixed using uninitialized variable warnings Thread-Topic: [PATCH] ahci: qoriq: fixed using uninitialized variable warnings Thread-Index: AQHQ6uECEB0oY2K4jk6uDrDQBK+S3p40OksAgAEPh+A= Date: Thu, 10 Sep 2015 06:17:08 +0000 Message-ID: References: <1441790182-20248-1-git-send-email-Yuantian.Tang@freescale.com> <20150909140130.GB22909@mtj.duckdns.org> In-Reply-To: <20150909140130.GB22909@mtj.duckdns.org> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Yuantian.Tang@freescale.com; x-originating-ip: [192.88.168.34] x-microsoft-exchange-diagnostics: 1;DM2PR03MB575;5:mbPSUYMSJWHcjqmRnwwrXlDzNuDn7xZ2U1rMlIN237WJk4aXUAsD1P0F9O2unWZAYeVYqvVOExeGN9kwikDjFbIc6ZeZ9wmy321dFJ0hnikZHBhkpRm38sYKfFNpgi+RgmaMQVqjN0jCf78pKNyF/g==;24:8tX31/AiDG1iYtLl635zdjRCVffD/HUnQBoUAqmMcWCcUda3ZWdvy7z5eo3BsieEoUbCNLSzkh9CmRrCZ0pKDcctRRigUpKnWh9m6xO2Y8A=;20:taIZSAlbhc5BIFu828OcITHWEvZpMOMt6kgt6+SiixZ8SVZ9t2r7HeiwqzMzL8NHjHyVMWRnjiUH5h5wh3ljfw== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB575; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:DM2PR03MB575;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB575; x-forefront-prvs: 06952FC175 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(199003)(377454003)(189002)(24454002)(13464003)(66066001)(110136002)(19580405001)(64706001)(86362001)(33656002)(74316001)(50986999)(92566002)(5001960100002)(54356999)(106356001)(87936001)(2900100001)(76176999)(2950100001)(189998001)(77096005)(5002640100001)(5001920100001)(102836002)(62966003)(5001860100001)(97736004)(101416001)(5004730100002)(5007970100001)(46102003)(19580395003)(77156002)(5003600100002)(68736005)(99286002)(5001830100001)(105586002)(40100003)(76576001)(10400500002)(4001540100001)(11100500001)(81156007)(106116001)(122556002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM2PR03MB575;H:DM2PR03MB574.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Sep 2015 06:17:08.7281 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB575 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Tejun Heo [mailto:htejun@gmail.com] On Behalf Of Tejun Heo > Sent: Wednesday, September 09, 2015 10:02 PM > To: Tang Yuantian-B29983 > Cc: hdegoede@redhat.com; linux-ide@vger.kernel.org; linux- > kernel@vger.kernel.org; devicetree@vger.kernel.org > Subject: Re: [PATCH] ahci: qoriq: fixed using uninitialized variable warnings > > On Wed, Sep 09, 2015 at 05:16:22PM +0800, Yuantian.Tang@freescale.com > wrote: > > From: Tang Yuantian > > > > kbuild test robot reports the warnings: > > drivers/ata/ahci_qoriq.c: In function 'ahci_qoriq_hardreset': > > >> include/asm-generic/io.h:163:2: warning: 'px_is' may be used > > >> uninitialized in this function [-Wuninitialized] > > drivers/ata/ahci_qoriq.c:70:14: note: 'px_is' was declared here > > >> include/asm-generic/io.h:163:2: warning: 'px_cmd' may be used > > >> uninitialized in this function [-Wuninitialized] > > drivers/ata/ahci_qoriq.c:70:6: note: 'px_cmd' was declared here > > > > This patch fixed it by assigning 0 to px_is and px_cmd variables. > > This patch also remove line 'struct ccsr_ahci *reg_base' which is not > > referred by any other codes and thus a dead one. > > Hmm... I think the problem here is that the complier can't know whether > qoriq_priv->type would change across intervening function calls. Maybe a > better solution is caching the type in a local variable so that the compiler can > tell that those two tests will always move together? It generally isn't a good > idea to clear variables unnecessarily as that can hide actual bugs that compiler > can detect. > I am not sure if the warning can be removed this way. But I will send the patch as your suggestion. Unfortunately, I can't produce this warning no matter if I add -Wuninitialized. So please let me know if the new patch is working. Regards, Yuantian > Thanks. > > -- > tejun