* [PATCH] staging: lustre: Use kasprintf.
@ 2015-02-28 22:29 Navya Sri Nizamkari
2015-03-01 6:07 ` Navya Sri Nizamkari
0 siblings, 1 reply; 2+ messages in thread
From: Navya Sri Nizamkari @ 2015-02-28 22:29 UTC (permalink / raw)
To: outreachy-kernel
This patch uses kasprintf as it combines kmalloc and
sprintf, and takes care of the size calculation itself.
The semantic patch that makes this change is as follows:
// <smpl>
@@
expression a,flag;
expression list args;
statement S;
@@
a =
- \(kmalloc\|kzalloc\)(...,flag)
+ kasprintf(flag,args)
<... when != a
if (a == NULL || ...) S
...>
- sprintf(a,args);
Signed-off-by: Navya Sri Nizamkari <navyasri.tech@gmail.com>
---
drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 0c1b583..52daba9 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -978,19 +978,17 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
lprof->lp_md, lprof->lp_dt);
- dt = kzalloc(strlen(lprof->lp_dt) + instlen + 2, GFP_NOFS);
+ dt = kasprintf(strlen(lprof->lp_dt) + instlen + 2, GFP_NOFS);
if (!dt) {
err = -ENOMEM;
goto out_free;
}
- sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
- md = kzalloc(strlen(lprof->lp_md) + instlen + 2, GFP_NOFS);
+ md = kasprintf(strlen(lprof->lp_md) + instlen + 2, GFP_NOFS);
if (!md) {
err = -ENOMEM;
goto out_free;
}
- sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
/* connections, registrations, sb setup */
err = client_common_fill_super(sb, md, dt, mnt);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: lustre: Use kasprintf.
2015-02-28 22:29 [PATCH] staging: lustre: Use kasprintf Navya Sri Nizamkari
@ 2015-03-01 6:07 ` Navya Sri Nizamkari
0 siblings, 0 replies; 2+ messages in thread
From: Navya Sri Nizamkari @ 2015-03-01 6:07 UTC (permalink / raw)
To: outreachy-kernel
[-- Attachment #1.1: Type: text/plain, Size: 116 bytes --]
Hi,
This produces a build error. Sorry, I'll send a newer version of this patch
after fixing it.
Thanks,
Navya
[-- Attachment #1.2: Type: text/html, Size: 304 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-01 6:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-28 22:29 [PATCH] staging: lustre: Use kasprintf Navya Sri Nizamkari
2015-03-01 6:07 ` Navya Sri Nizamkari
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.