Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1299891 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2016-01-01 13:20 +0100 |
| Last post | 2016-01-02 04:20 +0100 |
| Articles | 10 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-01 13:20 +0100
[PATCH 2/3] net-gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-01 13:30 +0100
[PATCH 3/3] net-gianfar: Extend an initialisation clause of a for loop in gfar_ethflow_to_filer_table() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-01 13:30 +0100
[PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-01 13:30 +0100
Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection Julia Lawall <julia.lawall@lip6.fr> - 2016-01-01 13:40 +0100
Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-01 14:00 +0100
Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection Julia Lawall <julia.lawall@lip6.fr> - 2016-01-01 14:10 +0100
Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection Francois Romieu <romieu@fr.zoreil.com> - 2016-01-01 15:50 +0100
[PATCH v2 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-01 14:10 +0100
Re: [PATCH v2 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection David Miller <davem@davemloft.net> - 2016-01-02 04:20 +0100
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-01-01 13:20 +0100 |
| Subject | [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() |
| Message-ID | <qM6Qy-2kR-5@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Fri, 1 Jan 2016 13:15:34 +0100 A few update suggestions were taken into account from static source code analysis. Markus Elfring (3): Less function calls after error detection Delete unnecessary variable initialisations Extend an initialisation clause of a for loop drivers/net/ethernet/freescale/gianfar_ethtool.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-01-01 13:30 +0100 |
| Subject | [PATCH 2/3] net-gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() |
| Message-ID | <qM70d-2ob-1@gated-at.bofh.it> |
| In reply to | #1299891 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 12:56:23 +0100
Omit explicit initialisation at the beginning for four local variables
which are redefined before their first use.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index be4941e..508be89 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
u64 class)
{
- unsigned int last_rule_idx = priv->cur_filer_idx;
+ unsigned int last_rule_idx;
unsigned int cmp_rqfpr;
unsigned int *local_rqfpr;
unsigned int *local_rqfcr;
- int i = 0x0, k = 0x0;
- int j = MAX_FILER_IDX, l = 0x0;
+ int i, k, l;
+ int j = MAX_FILER_IDX;
int ret = 1;
local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-01-01 13:30 +0100 |
| Subject | [PATCH 3/3] net-gianfar: Extend an initialisation clause of a for loop in gfar_ethflow_to_filer_table() |
| Message-ID | <qM70e-2ob-9@gated-at.bofh.it> |
| In reply to | #1299891 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 13:00:06 +0100
Move the assignment for the variable "j" from the beginning
into an initialisation clause of a for loop.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 508be89..6a7b035 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -772,8 +772,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
unsigned int cmp_rqfpr;
unsigned int *local_rqfpr;
unsigned int *local_rqfcr;
- int i, k, l;
- int j = MAX_FILER_IDX;
+ int i, j, k, l;
int ret = 1;
local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
@@ -807,7 +806,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
goto free_fcr;
}
- for (i = 0; i < MAX_FILER_IDX + 1; i++) {
+ for (i = 0, j = MAX_FILER_IDX; i < MAX_FILER_IDX + 1; i++) {
local_rqfpr[j] = priv->ftp_rqfpr[i];
local_rqfcr[j] = priv->ftp_rqfcr[i];
j--;
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-01-01 13:30 +0100 |
| Subject | [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection |
| Message-ID | <qM70e-2ob-13@gated-at.bofh.it> |
| In reply to | #1299891 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 11:16:04 +0100
The kfree() function was called in one case by the
gfar_ethflow_to_filer_table() function during error handling
even if a passed variable contained a null pointer.
* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 4b0ee85..be4941e 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
GFP_KERNEL);
+ if (!local_rqfpr)
+ return 1;
local_rqfcr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
GFP_KERNEL);
- if (!local_rqfpr || !local_rqfcr) {
+ if (!local_rqfcr) {
ret = 0;
- goto err;
+ goto free_fpr;
}
switch (class) {
@@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
netdev_err(priv->ndev,
"Right now this class is not supported\n");
ret = 0;
- goto err;
+ goto free_fcr;
}
for (i = 0; i < MAX_FILER_IDX + 1; i++) {
@@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
netdev_err(priv->ndev,
"No parse rule found, can't create hash rules\n");
ret = 0;
- goto err;
+ goto free_fcr;
}
/* If a match was found, then it begins the starting of a cluster rule
@@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
break;
priv->cur_filer_idx = priv->cur_filer_idx - 1;
}
-
-err:
+free_fcr:
kfree(local_rqfcr);
+free_fpr:
kfree(local_rqfpr);
return ret;
}
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2016-01-01 13:40 +0100 |
| Subject | Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection |
| Message-ID | <qM79U-2rl-7@gated-at.bofh.it> |
| In reply to | #1299894 |
On Fri, 1 Jan 2016, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 11:16:04 +0100
>
> The kfree() function was called in one case by the
> gfar_ethflow_to_filer_table() function during error handling
> even if a passed variable contained a null pointer.
>
> * Return directly if a memory allocation failed at the beginning.
>
> * Adjust jump targets according to the Linux coding style convention.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> index 4b0ee85..be4941e 100644
> --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> @@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
>
> local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
> GFP_KERNEL);
> + if (!local_rqfpr)
> + return 1;
Why return 1? Previously 0 was returned.
Normally, one returns -ENOMEM for this case, but it looks like this
function is returning 0 on failure.
julia
> local_rqfcr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
> GFP_KERNEL);
> - if (!local_rqfpr || !local_rqfcr) {
> + if (!local_rqfcr) {
> ret = 0;
> - goto err;
> + goto free_fpr;
> }
>
> switch (class) {
> @@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
> netdev_err(priv->ndev,
> "Right now this class is not supported\n");
> ret = 0;
> - goto err;
> + goto free_fcr;
> }
>
> for (i = 0; i < MAX_FILER_IDX + 1; i++) {
> @@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
> netdev_err(priv->ndev,
> "No parse rule found, can't create hash rules\n");
> ret = 0;
> - goto err;
> + goto free_fcr;
> }
>
> /* If a match was found, then it begins the starting of a cluster rule
> @@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
> break;
> priv->cur_filer_idx = priv->cur_filer_idx - 1;
> }
> -
> -err:
> +free_fcr:
> kfree(local_rqfcr);
> +free_fpr:
> kfree(local_rqfpr);
> return ret;
> }
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-01-01 14:00 +0100 |
| Subject | Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection |
| Message-ID | <qM7tf-2y5-1@gated-at.bofh.it> |
| In reply to | #1299897 |
>> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c >> @@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, >> >> local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int), >> GFP_KERNEL); >> + if (!local_rqfpr) >> + return 1; > > Why return 1? Previously 0 was returned. You are right. - Unfortunately, I made a mistake at this place of my update suggestion. > Normally, one returns -ENOMEM for this case, but it looks like this > function is returning 0 on failure. Should a symbol like "false" be used instead of such a special number? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2016-01-01 14:10 +0100 |
| Subject | Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection |
| Message-ID | <qM7CW-2R6-7@gated-at.bofh.it> |
| In reply to | #1299901 |
On Fri, 1 Jan 2016, SF Markus Elfring wrote: > >> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c > >> @@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow, > >> > >> local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int), > >> GFP_KERNEL); > >> + if (!local_rqfpr) > >> + return 1; > > > > Why return 1? Previously 0 was returned. > > You are right. - Unfortunately, I made a mistake at this place > of my update suggestion. > > > > Normally, one returns -ENOMEM for this case, but it looks like this > > function is returning 0 on failure. > > Should a symbol like "false" be used instead of such a special number? Maybe it's better than 0 and 1... julia -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Francois Romieu <romieu@fr.zoreil.com> |
|---|---|
| Date | 2016-01-01 15:50 +0100 |
| Subject | Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection |
| Message-ID | <qM9bI-3FN-23@gated-at.bofh.it> |
| In reply to | #1299904 |
Julia Lawall <julia.lawall@lip6.fr> :
> On Fri, 1 Jan 2016, SF Markus Elfring wrote:
[...]
> > > Normally, one returns -ENOMEM for this case, but it looks like this
> > > function is returning 0 on failure.
> >
> > Should a symbol like "false" be used instead of such a special number?
>
> Maybe it's better than 0 and 1...
Your suggestion about -ENOMEM is consistent with the callchain. Nothing
else is needed.
Btw:
1. kfree does not care about NULL parameter, especially in this hardly
timing sensitive path.
2. kmalloc_array for small kernel controlled arrays of integers (see
drivers/net/ethernet/freescale/gianfar.h), seriously ?
I'd suggest the janitor to introduce a dedicated struct to embed both
gfar_private.ftp_rqf{p, c}r then use a single, plain kmalloc in
gfar_ethflow_to_filer_table.
Happy tasteful 2016 :o)
--
Ueimor
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-01-01 14:10 +0100 |
| Subject | [PATCH v2 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection |
| Message-ID | <qM7CW-2R6-17@gated-at.bofh.it> |
| In reply to | #1299897 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 13:56:09 +0100
The kfree() function was called in one case by the
gfar_ethflow_to_filer_table() function during error handling
even if a passed variable contained a null pointer.
* Return directly if a memory allocation failed at the beginning.
* Adjust jump targets according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 4b0ee85..825b051 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
GFP_KERNEL);
+ if (!local_rqfpr)
+ return 0;
local_rqfcr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
GFP_KERNEL);
- if (!local_rqfpr || !local_rqfcr) {
+ if (!local_rqfcr) {
ret = 0;
- goto err;
+ goto free_fpr;
}
switch (class) {
@@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
netdev_err(priv->ndev,
"Right now this class is not supported\n");
ret = 0;
- goto err;
+ goto free_fcr;
}
for (i = 0; i < MAX_FILER_IDX + 1; i++) {
@@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
netdev_err(priv->ndev,
"No parse rule found, can't create hash rules\n");
ret = 0;
- goto err;
+ goto free_fcr;
}
/* If a match was found, then it begins the starting of a cluster rule
@@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
break;
priv->cur_filer_idx = priv->cur_filer_idx - 1;
}
-
-err:
+free_fcr:
kfree(local_rqfcr);
+free_fpr:
kfree(local_rqfpr);
return ret;
}
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-01-02 04:20 +0100 |
| Subject | Re: [PATCH v2 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection |
| Message-ID | <qMkTw-2KQ-13@gated-at.bofh.it> |
| In reply to | #1299905 |
This is not the proper way to resubmit patches when you are asked to make changes to some portion of a multi-patch series. You must always resubmit the entire series when this happens, not just the patch that changes. And in the revised cover "0/N" posting you list the revisions that were made. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web