All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through
@ 2019-03-29 23:38 Jeff Kirsher
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 2/6] " Jeff Kirsher
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Jeff Kirsher @ 2019-03-29 23:38 UTC (permalink / raw)
  To: intel-wired-lan

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

This patch fixes the following warning:

drivers/net/ethernet/intel/igb/igb_main.c: In function ?__igb_notify_dca?:
drivers/net/ethernet/intel/igb/igb_main.c:6694:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (dca_add_requester(dev) == 0) {
      ^
drivers/net/ethernet/intel/igb/igb_main.c:6701:2: note: here
  case DCA_PROVIDER_REMOVE:
  ^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

Notice that, in this particular case, the code comment is modified
in accordance with what GCC is expecting to find.

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 834e879e1d57..e8042b0254bc 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6701,7 +6701,7 @@ static int __igb_notify_dca(struct device *dev, void *data)
 			igb_setup_dca(adapter);
 			break;
 		}
-		/* Fall Through since DCA is disabled. */
+		/* Fall Through - since DCA is disabled. */
 	case DCA_PROVIDER_REMOVE:
 		if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
 			/* without this a class_device is left
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 2/6] igb: mark expected switch fall-through
  2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
@ 2019-03-29 23:38 ` Jeff Kirsher
  2019-04-02 19:24   ` Brown, Aaron F
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 3/6] ice: Use struct_size() helper Jeff Kirsher
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jeff Kirsher @ 2019-03-29 23:38 UTC (permalink / raw)
  To: intel-wired-lan

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

This patch fixes the following warning:

drivers/net/ethernet/intel/igb/e1000_82575.c: In function ?igb_get_invariants_82575?:
drivers/net/ethernet/intel/igb/e1000_82575.c:636:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (igb_sgmii_uses_mdio_82575(hw)) {
      ^
drivers/net/ethernet/intel/igb/e1000_82575.c:642:2: note: here
  case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
  ^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

Notice that, in this particular case, the code comment is modified
in accordance with what GCC is expecting to find.

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
---
 drivers/net/ethernet/intel/igb/e1000_82575.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c
index bafdcf70a353..3ec2ce0725d5 100644
--- a/drivers/net/ethernet/intel/igb/e1000_82575.c
+++ b/drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -638,7 +638,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
 			dev_spec->sgmii_active = true;
 			break;
 		}
-		/* fall through for I2C based SGMII */
+		/* fall through - for I2C based SGMII */
 	case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
 		/* read media type from SFP EEPROM */
 		ret_val = igb_set_sfp_media_type_82575(hw);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 3/6] ice: Use struct_size() helper
  2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 2/6] " Jeff Kirsher
@ 2019-03-29 23:38 ` Jeff Kirsher
  2019-04-02 18:45   ` Bowers, AndrewX
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 4/6] iavf: use struct_size() in kzalloc() Jeff Kirsher
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jeff Kirsher @ 2019-03-29 23:38 UTC (permalink / raw)
  To: intel-wired-lan

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>

One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
instance = alloc(size, GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

size = struct_size(instance, entry, count);

This code was detected with the help of Coccinelle.

Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
---
 drivers/net/ethernet/intel/ice/ice_sched.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
index 8d49f83be7a5..2a232504379d 100644
--- a/drivers/net/ethernet/intel/ice/ice_sched.c
+++ b/drivers/net/ethernet/intel/ice/ice_sched.c
@@ -683,10 +683,10 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
 	u16 i, num_groups_added = 0;
 	enum ice_status status = 0;
 	struct ice_hw *hw = pi->hw;
-	u16 buf_size;
+	size_t buf_size;
 	u32 teid;
 
-	buf_size = sizeof(*buf) + sizeof(*buf->generic) * (num_nodes - 1);
+	buf_size = struct_size(buf, generic, num_nodes - 1);
 	buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL);
 	if (!buf)
 		return ICE_ERR_NO_MEMORY;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 4/6] iavf: use struct_size() in kzalloc()
  2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 2/6] " Jeff Kirsher
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 3/6] ice: Use struct_size() helper Jeff Kirsher
@ 2019-03-29 23:38 ` Jeff Kirsher
  2019-04-02 18:44   ` Bowers, AndrewX
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 5/6] i40e: Use " Jeff Kirsher
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jeff Kirsher @ 2019-03-29 23:38 UTC (permalink / raw)
  To: intel-wired-lan

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>

One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
instance = kzalloc(size, GFP_KERNEL)

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)

Notice that, in this case, variable bufsz is not necessary, hence it
is removed.

This code was detected with the help of Coccinelle.

Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 4569d69a2b55..78340b297dab 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -3353,7 +3353,7 @@ static void iavf_init_task(struct work_struct *work)
 	struct net_device *netdev = adapter->netdev;
 	struct iavf_hw *hw = &adapter->hw;
 	struct pci_dev *pdev = adapter->pdev;
-	int err, bufsz;
+	int err;
 
 	switch (adapter->state) {
 	case __IAVF_STARTUP:
@@ -3423,10 +3423,9 @@ static void iavf_init_task(struct work_struct *work)
 	case __IAVF_INIT_GET_RESOURCES:
 		/* aq msg sent, awaiting reply */
 		if (!adapter->vf_res) {
-			bufsz = sizeof(struct virtchnl_vf_resource) +
-				(IAVF_MAX_VF_VSI *
-				 sizeof(struct virtchnl_vsi_resource));
-			adapter->vf_res = kzalloc(bufsz, GFP_KERNEL);
+			adapter->vf_res = kzalloc(struct_size(adapter->vf_res,
+						  vsi_res, IAVF_MAX_VF_VSI),
+						  GFP_KERNEL);
 			if (!adapter->vf_res)
 				goto err;
 		}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 5/6] i40e: Use struct_size() in kzalloc()
  2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
                   ` (2 preceding siblings ...)
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 4/6] iavf: use struct_size() in kzalloc() Jeff Kirsher
@ 2019-03-29 23:38 ` Jeff Kirsher
  2019-04-02 18:45   ` Bowers, AndrewX
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 6/6] iavf: iavf_client: use struct_size() helper Jeff Kirsher
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Jeff Kirsher @ 2019-03-29 23:38 UTC (permalink / raw)
  To: intel-wired-lan

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>

One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
instance = kzalloc(size, GFP_KERNEL)

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)

Notice that, in this case, variable size is not necessary, hence it
is removed.

This code was detected with the help of Coccinelle.

Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
---
 drivers/net/ethernet/intel/i40e/i40e_client.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_client.c b/drivers/net/ethernet/intel/i40e/i40e_client.c
index 5f3b8b9ff511..e81530ca08d0 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_client.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_client.c
@@ -578,11 +578,9 @@ static int i40e_client_setup_qvlist(struct i40e_info *ldev,
 	struct i40e_hw *hw = &pf->hw;
 	struct i40e_qv_info *qv_info;
 	u32 v_idx, i, reg_idx, reg;
-	u32 size;
 
-	size = sizeof(struct i40e_qvlist_info) +
-	       (sizeof(struct i40e_qv_info) * (qvlist_info->num_vectors - 1));
-	ldev->qvlist_info = kzalloc(size, GFP_KERNEL);
+	ldev->qvlist_info = kzalloc(struct_size(ldev->qvlist_info, qv_info,
+				    qvlist_info->num_vectors - 1), GFP_KERNEL);
 	if (!ldev->qvlist_info)
 		return -ENOMEM;
 	ldev->qvlist_info->num_vectors = qvlist_info->num_vectors;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 6/6] iavf: iavf_client: use struct_size() helper
  2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
                   ` (3 preceding siblings ...)
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 5/6] i40e: Use " Jeff Kirsher
@ 2019-03-29 23:38 ` Jeff Kirsher
  2019-04-02 18:45   ` Bowers, AndrewX
  2019-04-02 19:24 ` [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Brown, Aaron F
  2019-04-24 16:42 ` Gustavo A. R. Silva
  6 siblings, 1 reply; 16+ messages in thread
From: Jeff Kirsher @ 2019-03-29 23:38 UTC (permalink / raw)
  To: intel-wired-lan

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>

One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
    int stuff;
    struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

size = struct_size(instance, entry, count);

This code was detected with the help of Coccinelle.

Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
---
 drivers/net/ethernet/intel/iavf/iavf_client.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_client.c b/drivers/net/ethernet/intel/iavf/iavf_client.c
index aea45364fd1c..ab9db7e9f09d 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_client.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_client.c
@@ -451,7 +451,7 @@ static int iavf_client_setup_qvlist(struct i40e_info *ldev,
 	struct i40e_qv_info *qv_info;
 	iavf_status err;
 	u32 v_idx, i;
-	u32 msg_size;
+	size_t msg_size;
 
 	if (adapter->aq_required)
 		return -EAGAIN;
@@ -469,9 +469,8 @@ static int iavf_client_setup_qvlist(struct i40e_info *ldev,
 	}
 
 	v_qvlist_info = (struct virtchnl_iwarp_qvlist_info *)qvlist_info;
-	msg_size = sizeof(struct virtchnl_iwarp_qvlist_info) +
-			(sizeof(struct virtchnl_iwarp_qv_info) *
-			(v_qvlist_info->num_vectors - 1));
+	msg_size = struct_size(v_qvlist_info, qv_info,
+			       v_qvlist_info->num_vectors - 1);
 
 	adapter->client_pending |= BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP);
 	err = iavf_aq_send_msg_to_pf(&adapter->hw,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 4/6] iavf: use struct_size() in kzalloc()
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 4/6] iavf: use struct_size() in kzalloc() Jeff Kirsher
@ 2019-04-02 18:44   ` Bowers, AndrewX
  0 siblings, 0 replies; 16+ messages in thread
From: Bowers, AndrewX @ 2019-04-02 18:44 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Jeff Kirsher
> Sent: Friday, March 29, 2019 4:39 PM
> To: intel-wired-lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH 4/6] iavf: use struct_size() in kzalloc()
> 
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> 
> One of the more common cases of allocation size calculations is finding the
> size of a structure that has a zero-sized array at the end, along with memory
> for some number of elements for that array. For example:
> 
> struct foo {
>     int stuff;
>     struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo); instance = kzalloc(size,
> GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
> 
> Notice that, in this case, variable bufsz is not necessary, hence it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_main.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 3/6] ice: Use struct_size() helper
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 3/6] ice: Use struct_size() helper Jeff Kirsher
@ 2019-04-02 18:45   ` Bowers, AndrewX
  0 siblings, 0 replies; 16+ messages in thread
From: Bowers, AndrewX @ 2019-04-02 18:45 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Jeff Kirsher
> Sent: Friday, March 29, 2019 4:39 PM
> To: intel-wired-lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH 3/6] ice: Use struct_size() helper
> 
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> 
> One of the more common cases of allocation size calculations is finding the
> size of a structure that has a zero-sized array at the end, along with memory
> for some number of elements for that array. For example:
> 
> struct foo {
>     int stuff;
>     struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo); instance = alloc(size,
> GFP_KERNEL);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> size = struct_size(instance, entry, count);
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_sched.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 5/6] i40e: Use struct_size() in kzalloc()
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 5/6] i40e: Use " Jeff Kirsher
@ 2019-04-02 18:45   ` Bowers, AndrewX
  0 siblings, 0 replies; 16+ messages in thread
From: Bowers, AndrewX @ 2019-04-02 18:45 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Jeff Kirsher
> Sent: Friday, March 29, 2019 4:39 PM
> To: intel-wired-lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH 5/6] i40e: Use struct_size() in kzalloc()
> 
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> 
> One of the more common cases of allocation size calculations is finding the
> size of a structure that has a zero-sized array at the end, along with memory
> for some number of elements for that array. For example:
> 
> struct foo {
>     int stuff;
>     struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo); instance = kzalloc(size,
> GFP_KERNEL)
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)
> 
> Notice that, in this case, variable size is not necessary, hence it is removed.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_client.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 6/6] iavf: iavf_client: use struct_size() helper
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 6/6] iavf: iavf_client: use struct_size() helper Jeff Kirsher
@ 2019-04-02 18:45   ` Bowers, AndrewX
  0 siblings, 0 replies; 16+ messages in thread
From: Bowers, AndrewX @ 2019-04-02 18:45 UTC (permalink / raw)
  To: intel-wired-lan

> -----Original Message-----
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Jeff Kirsher
> Sent: Friday, March 29, 2019 4:39 PM
> To: intel-wired-lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH 6/6] iavf: iavf_client: use struct_size()
> helper
> 
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> 
> One of the more common cases of allocation size calculations is finding the
> size of a structure that has a zero-sized array at the end, along with memory
> for some number of elements for that array. For example:
> 
> struct foo {
>     int stuff;
>     struct boo entry[];
> };
> 
> size = sizeof(struct foo) + count * sizeof(struct boo);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> size = struct_size(instance, entry, count);
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_client.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Tested-by: Andrew Bowers <andrewx.bowers@intel.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through
  2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
                   ` (4 preceding siblings ...)
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 6/6] iavf: iavf_client: use struct_size() helper Jeff Kirsher
@ 2019-04-02 19:24 ` Brown, Aaron F
  2019-04-24 16:42 ` Gustavo A. R. Silva
  6 siblings, 0 replies; 16+ messages in thread
From: Brown, Aaron F @ 2019-04-02 19:24 UTC (permalink / raw)
  To: intel-wired-lan

> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Jeff Kirsher
> Sent: Friday, March 29, 2019 4:39 PM
> To: intel-wired-lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through
> 
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> 
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
> 
> This patch fixes the following warning:
> 
> drivers/net/ethernet/intel/igb/igb_main.c: In function ?__igb_notify_dca?:
> drivers/net/ethernet/intel/igb/igb_main.c:6694:6: warning: this statement
> may fall through [-Wimplicit-fallthrough=]
>    if (dca_add_requester(dev) == 0) {
>       ^
> drivers/net/ethernet/intel/igb/igb_main.c:6701:2: note: here
>   case DCA_PROVIDER_REMOVE:
>   ^~~~
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> Notice that, in this particular case, the code comment is modified
> in accordance with what GCC is expecting to find.
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Tested-by: Aaron Brown <aaron.f.brown@intel.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 2/6] igb: mark expected switch fall-through
  2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 2/6] " Jeff Kirsher
@ 2019-04-02 19:24   ` Brown, Aaron F
  0 siblings, 0 replies; 16+ messages in thread
From: Brown, Aaron F @ 2019-04-02 19:24 UTC (permalink / raw)
  To: intel-wired-lan

> From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On
> Behalf Of Jeff Kirsher
> Sent: Friday, March 29, 2019 4:39 PM
> To: intel-wired-lan at lists.osuosl.org
> Subject: [Intel-wired-lan] [PATCH 2/6] igb: mark expected switch fall-through
> 
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> 
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
> 
> This patch fixes the following warning:
> 
> drivers/net/ethernet/intel/igb/e1000_82575.c: In function
> ?igb_get_invariants_82575?:
> drivers/net/ethernet/intel/igb/e1000_82575.c:636:6: warning: this statement
> may fall through [-Wimplicit-fallthrough=]
>    if (igb_sgmii_uses_mdio_82575(hw)) {
>       ^
> drivers/net/ethernet/intel/igb/e1000_82575.c:642:2: note: here
>   case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
>   ^~~~
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> Notice that, in this particular case, the code comment is modified
> in accordance with what GCC is expecting to find.
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/intel/igb/e1000_82575.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Tested-by: Aaron Brown <aaron.f.brown@intel.com>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through
  2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
                   ` (5 preceding siblings ...)
  2019-04-02 19:24 ` [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Brown, Aaron F
@ 2019-04-24 16:42 ` Gustavo A. R. Silva
  2019-05-08 17:59   ` Gustavo A. R. Silva
  6 siblings, 1 reply; 16+ messages in thread
From: Gustavo A. R. Silva @ 2019-04-24 16:42 UTC (permalink / raw)
  To: intel-wired-lan

Hi Jeff,

I just wanted to check if this series has already been applied somewhere.

Thanks
--
Gustavo

On 3/29/19 6:38 PM, Jeff Kirsher wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> 
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
> 
> This patch fixes the following warning:
> 
> drivers/net/ethernet/intel/igb/igb_main.c: In function ?__igb_notify_dca?:
> drivers/net/ethernet/intel/igb/igb_main.c:6694:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    if (dca_add_requester(dev) == 0) {
>       ^
> drivers/net/ethernet/intel/igb/igb_main.c:6701:2: note: here
>   case DCA_PROVIDER_REMOVE:
>   ^~~~
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> Notice that, in this particular case, the code comment is modified
> in accordance with what GCC is expecting to find.
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 834e879e1d57..e8042b0254bc 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -6701,7 +6701,7 @@ static int __igb_notify_dca(struct device *dev, void *data)
>  			igb_setup_dca(adapter);
>  			break;
>  		}
> -		/* Fall Through since DCA is disabled. */
> +		/* Fall Through - since DCA is disabled. */
>  	case DCA_PROVIDER_REMOVE:
>  		if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
>  			/* without this a class_device is left
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through
  2019-04-24 16:42 ` Gustavo A. R. Silva
@ 2019-05-08 17:59   ` Gustavo A. R. Silva
  2019-05-16 19:17     ` Jeff Kirsher
  0 siblings, 1 reply; 16+ messages in thread
From: Gustavo A. R. Silva @ 2019-05-08 17:59 UTC (permalink / raw)
  To: intel-wired-lan

Hi Jeff,

I wonder if there is any chance for this series to be queued up for 5.2-rc1.

Thanks
--
Gustavo

On 4/24/19 11:42 AM, Gustavo A. R. Silva wrote:
> Hi Jeff,
> 
> I just wanted to check if this series has already been applied somewhere.
> 
> Thanks
> --
> Gustavo
> 
> On 3/29/19 6:38 PM, Jeff Kirsher wrote:
>> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>>
>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>> where we are expecting to fall through.
>>
>> This patch fixes the following warning:
>>
>> drivers/net/ethernet/intel/igb/igb_main.c: In function ?__igb_notify_dca?:
>> drivers/net/ethernet/intel/igb/igb_main.c:6694:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>>    if (dca_add_requester(dev) == 0) {
>>       ^
>> drivers/net/ethernet/intel/igb/igb_main.c:6701:2: note: here
>>   case DCA_PROVIDER_REMOVE:
>>   ^~~~
>>
>> Warning level 3 was used: -Wimplicit-fallthrough=3
>>
>> Notice that, in this particular case, the code comment is modified
>> in accordance with what GCC is expecting to find.
>>
>> This patch is part of the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
>> ---
>>  drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
>> index 834e879e1d57..e8042b0254bc 100644
>> --- a/drivers/net/ethernet/intel/igb/igb_main.c
>> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
>> @@ -6701,7 +6701,7 @@ static int __igb_notify_dca(struct device *dev, void *data)
>>  			igb_setup_dca(adapter);
>>  			break;
>>  		}
>> -		/* Fall Through since DCA is disabled. */
>> +		/* Fall Through - since DCA is disabled. */
>>  	case DCA_PROVIDER_REMOVE:
>>  		if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
>>  			/* without this a class_device is left
>>
> _______________________________________________
> Intel-wired-lan mailing list
> Intel-wired-lan at osuosl.org
> https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through
  2019-05-08 17:59   ` Gustavo A. R. Silva
@ 2019-05-16 19:17     ` Jeff Kirsher
  2019-05-24 13:40       ` Gustavo A. R. Silva
  0 siblings, 1 reply; 16+ messages in thread
From: Jeff Kirsher @ 2019-05-16 19:17 UTC (permalink / raw)
  To: intel-wired-lan

On Wed, 2019-05-08 at 12:59 -0500, Gustavo A. R. Silva wrote:
> Hi Jeff,
> 
> I wonder if there is any chance for this series to be queued up for
> 5.2-rc1.

Possibly, but since the nature of your patch is to just modify a code
comment because the tools used to check are not sophisticated enough to
realize the code comment already clearly states "Fall through ...", I
do not feel this is *really* necessary to get into 'net'.  If I have
other 'fixes' in my queue that need to get pushed, I may add this
change to the series.  I have not decided yet whether it warrants being
in 'net' or could wait till 'net-next'.

> 
> On 4/24/19 11:42 AM, Gustavo A. R. Silva wrote:
> > Hi Jeff,
> > 
> > I just wanted to check if this series has already been applied
> > somewhere.
> > 
> > Thanks
> > --
> > Gustavo
> > 
> > On 3/29/19 6:38 PM, Jeff Kirsher wrote:
> > > From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> > > 
> > > In preparation to enabling -Wimplicit-fallthrough, mark switch
> > > cases
> > > where we are expecting to fall through.
> > > 
> > > This patch fixes the following warning:
> > > 
> > > drivers/net/ethernet/intel/igb/igb_main.c: In function
> > > ?__igb_notify_dca?:
> > > drivers/net/ethernet/intel/igb/igb_main.c:6694:6: warning: this
> > > statement may fall through [-Wimplicit-fallthrough=]
> > >    if (dca_add_requester(dev) == 0) {
> > >       ^
> > > drivers/net/ethernet/intel/igb/igb_main.c:6701:2: note: here
> > >   case DCA_PROVIDER_REMOVE:
> > >   ^~~~
> > > 
> > > Warning level 3 was used: -Wimplicit-fallthrough=3
> > > 
> > > Notice that, in this particular case, the code comment is
> > > modified
> > > in accordance with what GCC is expecting to find.
> > > 
> > > This patch is part of the ongoing efforts to enable
> > > -Wimplicit-fallthrough.
> > > 
> > > Signed-off-by: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> > > ---
> > >  drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/net/ethernet/intel/igb/igb_main.c
> > > b/drivers/net/ethernet/intel/igb/igb_main.c
> > > index 834e879e1d57..e8042b0254bc 100644
> > > --- a/drivers/net/ethernet/intel/igb/igb_main.c
> > > +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> > > @@ -6701,7 +6701,7 @@ static int __igb_notify_dca(struct device
> > > *dev, void *data)
> > >  			igb_setup_dca(adapter);
> > >  			break;
> > >  		}
> > > -		/* Fall Through since DCA is disabled. */
> > > +		/* Fall Through - since DCA is disabled. */
> > >  	case DCA_PROVIDER_REMOVE:
> > >  		if (adapter->flags & IGB_FLAG_DCA_ENABLED) {
> > >  			/* without this a class_device is left
> > > 
> > _______________________________________________
> > Intel-wired-lan mailing list
> > Intel-wired-lan at osuosl.org
> > https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
> > 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20190516/2801b9e1/attachment-0001.asc>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through
  2019-05-16 19:17     ` Jeff Kirsher
@ 2019-05-24 13:40       ` Gustavo A. R. Silva
  0 siblings, 0 replies; 16+ messages in thread
From: Gustavo A. R. Silva @ 2019-05-24 13:40 UTC (permalink / raw)
  To: intel-wired-lan

Jeff,

On 5/16/19 2:17 PM, Jeff Kirsher wrote:
> On Wed, 2019-05-08 at 12:59 -0500, Gustavo A. R. Silva wrote:
>> Hi Jeff,
>>
>> I wonder if there is any chance for this series to be queued up for
>> 5.2-rc1.
> 
> Possibly, but since the nature of your patch is to just modify a code
> comment because the tools used to check are not sophisticated enough to
> realize the code comment already clearly states "Fall through ...", I
> do not feel this is *really* necessary to get into 'net'.  If I have
> other 'fixes' in my queue that need to get pushed, I may add this
> change to the series.  I have not decided yet whether it warrants being
> in 'net' or could wait till 'net-next'.
> 

I get it, net-next is fine. However, I noticed this series is still in
net-next/dev-queue.

There are only 6 of these fall-through warnings left in linux-next. Half
of them are fixed by this series. We want to add -Wimplicit-fallthrough
to the Makefile and start testing it in linux-next. And it'd be of great
help if you can move this series to your net-next/master, so it can be
merged into linux-next and be part of the test. :)

Thanks!
--
Gustavo

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-05-24 13:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 23:38 [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Jeff Kirsher
2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 2/6] " Jeff Kirsher
2019-04-02 19:24   ` Brown, Aaron F
2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 3/6] ice: Use struct_size() helper Jeff Kirsher
2019-04-02 18:45   ` Bowers, AndrewX
2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 4/6] iavf: use struct_size() in kzalloc() Jeff Kirsher
2019-04-02 18:44   ` Bowers, AndrewX
2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 5/6] i40e: Use " Jeff Kirsher
2019-04-02 18:45   ` Bowers, AndrewX
2019-03-29 23:38 ` [Intel-wired-lan] [PATCH 6/6] iavf: iavf_client: use struct_size() helper Jeff Kirsher
2019-04-02 18:45   ` Bowers, AndrewX
2019-04-02 19:24 ` [Intel-wired-lan] [PATCH 1/6] igb: mark expected switch fall-through Brown, Aaron F
2019-04-24 16:42 ` Gustavo A. R. Silva
2019-05-08 17:59   ` Gustavo A. R. Silva
2019-05-16 19:17     ` Jeff Kirsher
2019-05-24 13:40       ` Gustavo A. R. Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.