* [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) @ 2015-06-30 4:55 Maninder Singh 2015-06-30 5:12 ` Joe Perches 2015-06-30 14:53 ` [Intel-wired-lan] " Fujinaka, Todd 0 siblings, 2 replies; 10+ messages in thread From: Maninder Singh @ 2015-06-30 4:55 UTC (permalink / raw) To: jeffrey.t.kirsher, jesse.brandeburg, shannon.nelson, carolyn.wyborny, donald.c.skidmore, matthew.vick, john.ronciak, mitch.a.williams, intel-wired-lan, netdev, linux-kernel Cc: pankaj.m, Maninder Singh Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Reviewed-by: Yogesh Narayan Gaur <yn.gaur@samsung.com> --- drivers/net/ethernet/intel/igb/e1000_phy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c index c1bb64d..e399b3c 100644 --- a/drivers/net/ethernet/intel/igb/e1000_phy.c +++ b/drivers/net/ethernet/intel/igb/e1000_phy.c @@ -37,8 +37,7 @@ static s32 igb_set_master_slave_mode(struct e1000_hw *hw); static const u16 e1000_m88_cable_length_table[] = { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED }; #define M88E1000_CABLE_LENGTH_TABLE_SIZE \ - (sizeof(e1000_m88_cable_length_table) / \ - sizeof(e1000_m88_cable_length_table[0])) + ARRAY_SIZE(e1000_m88_cable_length_table) static const u16 e1000_igp_2_cable_length_table[] = { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, @@ -50,8 +49,7 @@ static const u16 e1000_igp_2_cable_length_table[] = { 83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124, 104, 109, 114, 118, 121, 124}; #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \ - (sizeof(e1000_igp_2_cable_length_table) / \ - sizeof(e1000_igp_2_cable_length_table[0])) + ARRAY_SIZE(e1000_igp_2_cable_length_table) /** * igb_check_reset_block - Check if PHY reset is blocked -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 4:55 [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) Maninder Singh @ 2015-06-30 5:12 ` Joe Perches 2015-06-30 14:53 ` [Intel-wired-lan] " Fujinaka, Todd 1 sibling, 0 replies; 10+ messages in thread From: Joe Perches @ 2015-06-30 5:12 UTC (permalink / raw) To: Maninder Singh Cc: jeffrey.t.kirsher, jesse.brandeburg, shannon.nelson, carolyn.wyborny, donald.c.skidmore, matthew.vick, john.ronciak, mitch.a.williams, intel-wired-lan, netdev, linux-kernel, pankaj.m On Tue, 2015-06-30 at 10:25 +0530, Maninder Singh wrote: > Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) I think all of these #defines should be removed instead as they are all used only once. > diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c [] > @@ -37,8 +37,7 @@ static s32 igb_set_master_slave_mode(struct e1000_hw *hw); > static const u16 e1000_m88_cable_length_table[] = { > 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED }; > #define M88E1000_CABLE_LENGTH_TABLE_SIZE \ > - (sizeof(e1000_m88_cable_length_table) / \ > - sizeof(e1000_m88_cable_length_table[0])) > + ARRAY_SIZE(e1000_m88_cable_length_table) > > static const u16 e1000_igp_2_cable_length_table[] = { > 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, > @@ -50,8 +49,7 @@ static const u16 e1000_igp_2_cable_length_table[] = { > 83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124, > 104, 109, 114, 118, 121, 124}; > #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \ > - (sizeof(e1000_igp_2_cable_length_table) / \ > - sizeof(e1000_igp_2_cable_length_table[0])) > + ARRAY_SIZE(e1000_igp_2_cable_length_table) > > /** > * igb_check_reset_block - Check if PHY reset is blocked ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 4:55 [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) Maninder Singh 2015-06-30 5:12 ` Joe Perches @ 2015-06-30 14:53 ` Fujinaka, Todd 2015-06-30 19:01 ` Richard Weinberger 1 sibling, 1 reply; 10+ messages in thread From: Fujinaka, Todd @ 2015-06-30 14:53 UTC (permalink / raw) To: Maninder Singh, Kirsher, Jeffrey T, Brandeburg, Jesse, Nelson, Shannon, Wyborny, Carolyn, Skidmore, Donald C, Vick, Matthew, Ronciak, John, Williams, Mitch A, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pankaj.m@samsung.com I don't see the reason this is needed so I'm going to say NAK. Todd Fujinaka Software Application Engineer Networking Division (ND) Intel Corporation todd.fujinaka@intel.com (503) 712-4565 -----Original Message----- From: Intel-wired-lan [mailto:intel-wired-lan-bounces@lists.osuosl.org] On Behalf Of Maninder Singh Sent: Monday, June 29, 2015 9:56 PM To: Kirsher, Jeffrey T; Brandeburg, Jesse; Nelson, Shannon; Wyborny, Carolyn; Skidmore, Donald C; Vick, Matthew; Ronciak, John; Williams, Mitch A; intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org Cc: Maninder Singh; pankaj.m@samsung.com Subject: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Reviewed-by: Yogesh Narayan Gaur <yn.gaur@samsung.com> --- drivers/net/ethernet/intel/igb/e1000_phy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c index c1bb64d..e399b3c 100644 --- a/drivers/net/ethernet/intel/igb/e1000_phy.c +++ b/drivers/net/ethernet/intel/igb/e1000_phy.c @@ -37,8 +37,7 @@ static s32 igb_set_master_slave_mode(struct e1000_hw *hw); static const u16 e1000_m88_cable_length_table[] = { 0, 50, 80, 110, 140, 140, E1000_CABLE_LENGTH_UNDEFINED }; #define M88E1000_CABLE_LENGTH_TABLE_SIZE \ - (sizeof(e1000_m88_cable_length_table) / \ - sizeof(e1000_m88_cable_length_table[0])) + ARRAY_SIZE(e1000_m88_cable_length_table) static const u16 e1000_igp_2_cable_length_table[] = { 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 8, 11, 13, 16, 18, 21, @@ -50,8 +49,7 @@ static const u16 e1000_igp_2_cable_length_table[] = { 83, 89, 95, 100, 105, 109, 113, 116, 119, 122, 124, 104, 109, 114, 118, 121, 124}; #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \ - (sizeof(e1000_igp_2_cable_length_table) / \ - sizeof(e1000_igp_2_cable_length_table[0])) + ARRAY_SIZE(e1000_igp_2_cable_length_table) /** * igb_check_reset_block - Check if PHY reset is blocked -- 1.7.9.5 _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@lists.osuosl.org http://lists.osuosl.org/mailman/listinfo/intel-wired-lan ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 14:53 ` [Intel-wired-lan] " Fujinaka, Todd @ 2015-06-30 19:01 ` Richard Weinberger 2015-06-30 20:16 ` Fujinaka, Todd 0 siblings, 1 reply; 10+ messages in thread From: Richard Weinberger @ 2015-06-30 19:01 UTC (permalink / raw) To: Fujinaka, Todd Cc: Maninder Singh, Kirsher, Jeffrey T, Brandeburg, Jesse, Nelson, Shannon, Wyborny, Carolyn, Skidmore, Donald C, Vick, Matthew, Ronciak, John, Williams, Mitch A, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com On Tue, Jun 30, 2015 at 4:53 PM, Fujinaka, Todd <todd.fujinaka@intel.com> wrote: > I don't see the reason this is needed so I'm going to say NAK. Using generic functions is always better than open coded stuff. Linux's ARRAY_SIZE also makes sure that the passed variable is actually an array. -- Thanks, //richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 19:01 ` Richard Weinberger @ 2015-06-30 20:16 ` Fujinaka, Todd 2015-06-30 20:24 ` Richard Weinberger ` (3 more replies) 0 siblings, 4 replies; 10+ messages in thread From: Fujinaka, Todd @ 2015-06-30 20:16 UTC (permalink / raw) To: Richard Weinberger Cc: Maninder Singh, Kirsher, Jeffrey T, Brandeburg, Jesse, Nelson, Shannon, Wyborny, Carolyn, Skidmore, Donald C, Vick, Matthew, Ronciak, John, Williams, Mitch A, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com Sorry for the top-posting, but I'm provided with the tools they give me and bottom posting from Outlook just confuses email threads. Plus, this was crossposted all over creation and cc-ed to anyone with an intel address. I still would say no if I'm allowed, because to guarantee that this change - that I don't think fixes anything - works in all cases, we need to do an incredible amount of regression testing. Every variant of every Intel part that uses this driver (and there are many) should be tested and will end up being used by the community. Plus, you have no idea the number of obscure bugs I have to deal with as the guy answering customer questions. If this triggers some odd embedded compiler bug, I'm going to have to dig it out. Unless there is an actual bug, I'd like to leave it as it is. Todd Fujinaka Software Application Engineer Networking Division (ND) Intel Corporation todd.fujinaka@intel.com (503) 712-4565 -----Original Message----- From: Richard Weinberger [mailto:richard.weinberger@gmail.com] Sent: Tuesday, June 30, 2015 12:01 PM To: Fujinaka, Todd Cc: Maninder Singh; Kirsher, Jeffrey T; Brandeburg, Jesse; Nelson, Shannon; Wyborny, Carolyn; Skidmore, Donald C; Vick, Matthew; Ronciak, John; Williams, Mitch A; intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; pankaj.m@samsung.com Subject: Re: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) On Tue, Jun 30, 2015 at 4:53 PM, Fujinaka, Todd <todd.fujinaka@intel.com> wrote: > I don't see the reason this is needed so I'm going to say NAK. Using generic functions is always better than open coded stuff. Linux's ARRAY_SIZE also makes sure that the passed variable is actually an array. -- Thanks, //richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 20:16 ` Fujinaka, Todd @ 2015-06-30 20:24 ` Richard Weinberger 2015-06-30 20:38 ` Alex Gartrell ` (2 subsequent siblings) 3 siblings, 0 replies; 10+ messages in thread From: Richard Weinberger @ 2015-06-30 20:24 UTC (permalink / raw) To: Fujinaka, Todd Cc: Maninder Singh, Kirsher, Jeffrey T, Brandeburg, Jesse, Nelson, Shannon, Wyborny, Carolyn, Skidmore, Donald C, Vick, Matthew, Ronciak, John, Williams, Mitch A, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com Hi! Am 30.06.2015 um 22:16 schrieb Fujinaka, Todd: > Sorry for the top-posting, but I'm provided with the tools they give me and bottom posting from Outlook just confuses email threads. Plus, this was crossposted all over creation and cc-ed to anyone with an intel address. > > I still would say no if I'm allowed, because to guarantee that this change - that I don't think fixes anything - works in all cases, we need to do an incredible amount of regression testing. Every variant of every Intel part that uses this driver (and there are many) should be tested and will end up being used by the community. > > Plus, you have no idea the number of obscure bugs I have to deal with as the guy answering customer questions. If this triggers some odd embedded compiler bug, I'm going to have to dig it out. Unless there is an actual bug, I'd like to leave it as it is. If you don't dare to touch your driver please update it's maintenance status. "Supported" is definitely not the case, maybe "Odd fixes" would fit better. Thanks, //richard ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 20:16 ` Fujinaka, Todd 2015-06-30 20:24 ` Richard Weinberger @ 2015-06-30 20:38 ` Alex Gartrell 2015-06-30 20:52 ` Joe Perches 2015-06-30 22:25 ` Fujinaka, Todd 3 siblings, 0 replies; 10+ messages in thread From: Alex Gartrell @ 2015-06-30 20:38 UTC (permalink / raw) To: Fujinaka, Todd Cc: Richard Weinberger, Maninder Singh, Kirsher, Jeffrey T, Brandeburg, Jesse, Nelson, Shannon, Wyborny, Carolyn, Skidmore, Donald C, Vick, Matthew, Ronciak, John, Williams, Mitch A, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com On Tue, Jun 30, 2015 at 1:16 PM, Fujinaka, Todd <todd.fujinaka@intel.com> wrote: > I still would say no if I'm allowed, because to guarantee that this change - that I don't think fixes anything - works in all cases, we need to do an incredible amount of regression testing. Every variant of every Intel part that uses this driver (and there are many) should be tested and will end up being used by the community. > Validation is really simple: diff old_module.ko new_module.ko And this is a good defensive measure, as it'll save you when someone screws up and changes your array to a pointer to an array (you'll get a build failure instead of 0). -- Alex Gartrell <agartrell@fb.com> ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 20:16 ` Fujinaka, Todd 2015-06-30 20:24 ` Richard Weinberger 2015-06-30 20:38 ` Alex Gartrell @ 2015-06-30 20:52 ` Joe Perches 2015-06-30 22:25 ` Fujinaka, Todd 3 siblings, 0 replies; 10+ messages in thread From: Joe Perches @ 2015-06-30 20:52 UTC (permalink / raw) To: Fujinaka, Todd Cc: Richard Weinberger, Maninder Singh, Kirsher, Jeffrey T, Brandeburg, Jesse, Nelson, Shannon, Wyborny, Carolyn, Skidmore, Donald C, Vick, Matthew, Ronciak, John, Williams, Mitch A, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.m@samsung.com On Tue, 2015-06-30 at 20:16 +0000, Fujinaka, Todd wrote: > Sorry for the top-posting, but I'm provided with the tools they give me > and bottom posting from Outlook just confuses email threads. Plus, this > was crossposted all over creation and cc-ed to anyone with an intel > address. Not quite. It was posted to the names listed under the MAINTAINERS entry. INTEL ETHERNET DRIVERS M: Jeff Kirsher <jeffrey.t.kirsher@intel.com> R: Jesse Brandeburg <jesse.brandeburg@intel.com> R: Shannon Nelson <shannon.nelson@intel.com> R: Carolyn Wyborny <carolyn.wyborny@intel.com> R: Don Skidmore <donald.c.skidmore@intel.com> R: Matthew Vick <matthew.vick@intel.com> R: John Ronciak <john.ronciak@intel.com> R: Mitch Williams <mitch.a.williams@intel.com> L: intel-wired-lan@lists.osuosl.org btw: You aren't listed there Todd. Should you be? > I still would say no if I'm allowed, because to guarantee that this > change - that I don't think fixes anything Simplicity for the reader is generally a good thing. Removing the macros altogether is likely better. > - works in all cases, we > need to do an incredible amount of regression testing. Compilers should not produce different object code. Verification of no object changes should be good enough. > Every variant of > every Intel part that uses this driver (and there are many) should be > tested and will end up being used by the community. > > Plus, you have no idea the number of obscure bugs I have to deal with > as the guy answering customer questions. If this triggers some odd > embedded compiler bug, I'm going to have to dig it out. Unless there is > an actual bug, I'd like to leave it as it is. If any compiler miscompiles the ARRAY_SIZE macro, there are bound to be real issues with using that compiler in a production environment. ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 20:16 ` Fujinaka, Todd ` (2 preceding siblings ...) 2015-06-30 20:52 ` Joe Perches @ 2015-06-30 22:25 ` Fujinaka, Todd 2015-06-30 22:32 ` Joe Perches 3 siblings, 1 reply; 10+ messages in thread From: Fujinaka, Todd @ 2015-06-30 22:25 UTC (permalink / raw) To: Fujinaka, Todd, Richard Weinberger Cc: linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, Maninder Singh, pankaj.m@samsung.com I've submitted a version to intel-wired-lan that addresses the original issue as well as Joe Perches's suggestion to just delete the define. Todd Fujinaka Software Application Engineer Networking Division (ND) Intel Corporation todd.fujinaka@intel.com (503) 712-4565 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) 2015-06-30 22:25 ` Fujinaka, Todd @ 2015-06-30 22:32 ` Joe Perches 0 siblings, 0 replies; 10+ messages in thread From: Joe Perches @ 2015-06-30 22:32 UTC (permalink / raw) To: Fujinaka, Todd Cc: Richard Weinberger, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, Maninder Singh, pankaj.m@samsung.com On Tue, 2015-06-30 at 22:25 +0000, Fujinaka, Todd wrote: > I've submitted a version to intel-wired-lan that addresses the original > issue as well as Joe Perches's suggestion to just delete the define. Please cc netdev next time too. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-06-30 22:32 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-06-30 4:55 [PATCH 1/1] igb: Use ARRAY_SIZE instead fo sizeof(a)/sizeof(a[0]) Maninder Singh 2015-06-30 5:12 ` Joe Perches 2015-06-30 14:53 ` [Intel-wired-lan] " Fujinaka, Todd 2015-06-30 19:01 ` Richard Weinberger 2015-06-30 20:16 ` Fujinaka, Todd 2015-06-30 20:24 ` Richard Weinberger 2015-06-30 20:38 ` Alex Gartrell 2015-06-30 20:52 ` Joe Perches 2015-06-30 22:25 ` Fujinaka, Todd 2015-06-30 22:32 ` Joe Perches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).