Commit 95745e9b authored by Navya Sri Nizamkari's avatar Navya Sri Nizamkari Committed by Greg Kroah-Hartman

staging: lustre: Use kasprintf.

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: default avatarNavya Sri Nizamkari <navyasri.tech@gmail.com>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f40e06f0
...@@ -977,19 +977,17 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) ...@@ -977,19 +977,17 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm, CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
lprof->lp_md, lprof->lp_dt); lprof->lp_md, lprof->lp_dt);
dt = kzalloc(strlen(lprof->lp_dt) + instlen + 2, GFP_NOFS); dt = kasprintf(GFP_NOFS, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
if (!dt) { if (!dt) {
err = -ENOMEM; err = -ENOMEM;
goto out_free; 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(GFP_NOFS, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
if (!md) { if (!md) {
err = -ENOMEM; err = -ENOMEM;
goto out_free; goto out_free;
} }
sprintf(md, "%s-%p", lprof->lp_md, cfg->cfg_instance);
/* connections, registrations, sb setup */ /* connections, registrations, sb setup */
err = client_common_fill_super(sb, md, dt, mnt); err = client_common_fill_super(sb, md, dt, mnt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment