* [PATCH] mISDN: use kstrdup() in dsp_pipeline_build
@ 2015-10-10 9:32 Geliang Tang
2015-10-10 19:22 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Geliang Tang @ 2015-10-10 9:32 UTC (permalink / raw)
To: Karsten Keil; +Cc: Geliang Tang, netdev, linux-kernel
Use kstrdup instead of strlen-kmalloc-strcpy.
Signed-off-by: Geliang Tang <geliangtang@163.com>
---
drivers/isdn/mISDN/dsp_pipeline.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index 8b1a66c..c60722d 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -235,7 +235,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
{
- int len, incomplete = 0, found = 0;
+ int incomplete = 0, found = 0;
char *dup, *tok, *name, *args;
struct dsp_element_entry *entry, *n;
struct dsp_pipeline_entry *pipeline_entry;
@@ -250,14 +250,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
if (!cfg)
return 0;
- len = strlen(cfg);
- if (!len)
- return 0;
-
- dup = kmalloc(len + 1, GFP_ATOMIC);
+ dup = kstrdup(cfg, GFP_ATOMIC);
if (!dup)
return 0;
- strcpy(dup, cfg);
while ((tok = strsep(&dup, "|"))) {
if (!strlen(tok))
continue;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mISDN: use kstrdup() in dsp_pipeline_build
2015-10-10 9:32 [PATCH] mISDN: use kstrdup() in dsp_pipeline_build Geliang Tang
@ 2015-10-10 19:22 ` Joe Perches
2015-10-12 8:19 ` [PATCH v2] " Geliang Tang
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2015-10-10 19:22 UTC (permalink / raw)
To: Geliang Tang; +Cc: Karsten Keil, netdev, linux-kernel
On Sat, 2015-10-10 at 02:32 -0700, Geliang Tang wrote:
> Use kstrdup instead of strlen-kmalloc-strcpy.
Not the same code.
Instead of returning early, a 0 length string will
now set pipeline->inuse to 0.
Maybe that's OK, but you should state why in the
commit log.
> diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
[]
> @@ -250,14 +250,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
> if (!cfg)
> return 0;
>
> - len = strlen(cfg);
> - if (!len)
> - return 0;
> -
> - dup = kmalloc(len + 1, GFP_ATOMIC);
> + dup = kstrdup(cfg, GFP_ATOMIC);
> if (!dup)
> return 0;
> - strcpy(dup, cfg);
> while ((tok = strsep(&dup, "|"))) {
> if (!strlen(tok))
> continue;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] mISDN: use kstrdup() in dsp_pipeline_build
2015-10-10 19:22 ` Joe Perches
@ 2015-10-12 8:19 ` Geliang Tang
2015-10-14 1:30 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Geliang Tang @ 2015-10-12 8:19 UTC (permalink / raw)
To: Joe Perches, Karsten Keil; +Cc: Geliang Tang, netdev, linux-kernel
Use kstrdup instead of strlen-kmalloc-strcpy. Remove unneeded NULL
test, it will be tested inside kstrdup. Remove 0 length string test,
it has been tested in the caller of dsp_pipeline_build.
Signed-off-by: Geliang Tang <geliangtang@163.com>
---
Changes in v2:
- Remove unneeded NULL test.
---
drivers/isdn/mISDN/dsp_pipeline.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index 8b1a66c..e72b4e7 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -235,7 +235,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
{
- int len, incomplete = 0, found = 0;
+ int incomplete = 0, found = 0;
char *dup, *tok, *name, *args;
struct dsp_element_entry *entry, *n;
struct dsp_pipeline_entry *pipeline_entry;
@@ -247,17 +247,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
if (!list_empty(&pipeline->list))
_dsp_pipeline_destroy(pipeline);
- if (!cfg)
- return 0;
-
- len = strlen(cfg);
- if (!len)
- return 0;
-
- dup = kmalloc(len + 1, GFP_ATOMIC);
+ dup = kstrdup(cfg, GFP_ATOMIC);
if (!dup)
return 0;
- strcpy(dup, cfg);
while ((tok = strsep(&dup, "|"))) {
if (!strlen(tok))
continue;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mISDN: use kstrdup() in dsp_pipeline_build
2015-10-12 8:19 ` [PATCH v2] " Geliang Tang
@ 2015-10-14 1:30 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2015-10-14 1:30 UTC (permalink / raw)
To: geliangtang; +Cc: joe, isdn, netdev, linux-kernel
From: Geliang Tang <geliangtang@163.com>
Date: Mon, 12 Oct 2015 01:19:07 -0700
> Use kstrdup instead of strlen-kmalloc-strcpy. Remove unneeded NULL
> test, it will be tested inside kstrdup. Remove 0 length string test,
> it has been tested in the caller of dsp_pipeline_build.
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
> Changes in v2:
> - Remove unneeded NULL test.
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-14 1:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-10 9:32 [PATCH] mISDN: use kstrdup() in dsp_pipeline_build Geliang Tang
2015-10-10 19:22 ` Joe Perches
2015-10-12 8:19 ` [PATCH v2] " Geliang Tang
2015-10-14 1:30 ` David Miller
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.