From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756555AbcIGMR1 (ORCPT ); Wed, 7 Sep 2016 08:17:27 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:53217 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbcIGMRZ (ORCPT ); Wed, 7 Sep 2016 08:17:25 -0400 From: Arnd Bergmann To: Yuval Mintz Cc: Baoyou Xie , netdev , linux-kernel , "xie.baoyou@zte.com.cn" , Ariel Elior Subject: Re: [PATCH] qed: add missing header dependencies Date: Wed, 07 Sep 2016 14:17:41 +0200 Message-ID: <4989831.9c6WyUak3s@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <1473246420-1035-1-git-send-email-baoyou.xie@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:ln9YbcZldkpqZvmcA0LrjMB4A1g0WoBrdMrut4wQjuVMSL3MkHF S/q8wytLCYygLp7yqsfZAlx17IWtekqCcYPx4Jjd7g9lVE4gn7GSs2OESmTHhxPR3z6CTIu Y6vX/1+haIhtIS+WDpJ+xG3+iYgTim4II2bL4A45eIjBla6RqpYYHp2VyfByDr2oSRYulkW 9Pqz/bk/L40DJWkcOuSNw== X-UI-Out-Filterresults: notjunk:1;V01:K0:OjVnjVn+7k8=:G8N7Xa8CD3NAizNoQNBsTg krAzAxNIB0vyym1wfEePsocfRKW3bsoPivrdXr2dUIF7Po3ceRHm8gKdT/pe0PUFULb4q3NoD rFRLAxuzUqkozPRuZraJ4kaB+6f1JBVAPDTfa2PpgKIkbzpoQ/2WIDYyHqDy6ltISRL7CMvEf esTCg9JofrQNRAFWzHSYDSvlKpjGR+rZ8NqZUla5n8B4YxU3qg8vkU5soP98/dKv262CWCqn5 QIbFZqULJ7cdPWCTFo0LLQA5iVcVRjdjYAQAj4zinx9foh36wPsm1BtBwU7Js1dROMfGV8V6V AKKSMa9jm5JhvuKEv3sCaXYabz6eA2I6QVk22HWtlbXVo1/znNCO2xuD9wHbRkHOrEpaX0RWw Lt7wathXYq18fS2OXfbY273A5Hxmh+BvpoTUuMFx9CF9HOvFMLt9YuyXECH0CORU7IgvLgg5O vQYyAVEkAGHA5BHPnGoPvhiU915dEAN2RnNMDgdW+ZKz0Q7BNULVgNTT2AHYss1c/abmbmQLg xc7C+TKdXUf9FWWhQUKtWPkWgeLJO/GVBlcpwf4AR1+3ImxXxA/pI2udJsEiD37TKWYVdoaT8 tX4He1FoNnZgHTgbzBp3Zp4/Wh7pA1N3yUby0S45GqIvAZ7HDiX77hTKBSaku5WCCo5P+0j0x oAnywx7wCRomo64PYKk901SgdCEweJTmP7Zu0bXenk5DY0wz9FDM9VmSowmQL2UcPurHcGvHd 1MXtF5Sa+hGnheiP Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, September 7, 2016 11:37:07 AM CEST Yuval Mintz wrote: > > We get 4 warnings when building kernel with W=1: > > drivers/net/ethernet/qlogic/qed/qed_selftest.c:6:5: warning: no previous > > prototype for 'qed_selftest_memory' [-Wmissing-prototypes] > > drivers/net/ethernet/qlogic/qed/qed_selftest.c:19:5: warning: no previous > > prototype for 'qed_selftest_interrupt' [-Wmissing-prototypes] > > drivers/net/ethernet/qlogic/qed/qed_selftest.c:32:5: warning: no previous > > prototype for 'qed_selftest_register' [-Wmissing-prototypes] > > drivers/net/ethernet/qlogic/qed/qed_selftest.c:55:5: warning: no previous > > prototype for 'qed_selftest_clock' [-Wmissing-prototypes] > > > > In fact, these functions are declared in qed_selftest.h, so this patch add missing > > header dependencies. > > > > Signed-off-by: Baoyou Xie > > While I obviously have no strong objection for including qed_selftest.h > from qed_selftest.c, I'm not sure I understand which C standard dictates > this requirement. > Why should a function definition [not call] be preceded by a prototype? This rule addresses two problems: - some functions should be marked static as they are never used outside of the file that declares them. Marking them static give the compiler better opportunities for optimization and lets you see when a function becomes unused, and if there is no external declaration that is often an indication that there are no other users. - When a function is defined in one file and used in another, you want both files to include the same header that has the declaration to ensure that the types are identical. There are cases where the prototype is changed after the fact in an incompatible way, causing silent data corruption on some configurations but maybe not on others. Arnd