mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 10:04:12 +08:00
mISDN: use kstrdup() in dsp_pipeline_build
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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4bdc3d6614
commit
c3643885aa
@ -235,7 +235,7 @@ void dsp_pipeline_destroy(struct dsp_pipeline *pipeline)
|
|||||||
|
|
||||||
int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
|
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;
|
char *dup, *tok, *name, *args;
|
||||||
struct dsp_element_entry *entry, *n;
|
struct dsp_element_entry *entry, *n;
|
||||||
struct dsp_pipeline_entry *pipeline_entry;
|
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))
|
if (!list_empty(&pipeline->list))
|
||||||
_dsp_pipeline_destroy(pipeline);
|
_dsp_pipeline_destroy(pipeline);
|
||||||
|
|
||||||
if (!cfg)
|
dup = kstrdup(cfg, GFP_ATOMIC);
|
||||||
return 0;
|
|
||||||
|
|
||||||
len = strlen(cfg);
|
|
||||||
if (!len)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
dup = kmalloc(len + 1, GFP_ATOMIC);
|
|
||||||
if (!dup)
|
if (!dup)
|
||||||
return 0;
|
return 0;
|
||||||
strcpy(dup, cfg);
|
|
||||||
while ((tok = strsep(&dup, "|"))) {
|
while ((tok = strsep(&dup, "|"))) {
|
||||||
if (!strlen(tok))
|
if (!strlen(tok))
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user