This allocated buffer serves no purpose.
A constant string is copied into it, it is passed to some
function which copies it out again, then the buffer is freed.
Instead, we can pass the constant string to that function.
Change-Id: I83ea8fc839da3933ebc34756fc5c06b86427ce7c
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-on: https://review.whamcloud.com/35273
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
* Lustre is a trademark of Sun Microsystems, Inc.
*/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
-#define MAX_STRING_SIZE 128
-
extern int ldlm_srv_namespace_nr;
extern int ldlm_cli_namespace_nr;
extern struct mutex ldlm_srv_namespace_lock;
extern int ldlm_srv_namespace_nr;
extern int ldlm_cli_namespace_nr;
extern struct mutex ldlm_srv_namespace_lock;
ldlm_add_var(struct lprocfs_vars *vars, struct dentry *debugfs_entry,
const char *name, void *data, const struct file_operations *ops)
{
ldlm_add_var(struct lprocfs_vars *vars, struct dentry *debugfs_entry,
const char *name, void *data, const struct file_operations *ops)
{
- snprintf((char *)vars->name, MAX_STRING_SIZE, "%s", name);
vars->data = data;
vars->fops = ops;
ldebugfs_add_vars(debugfs_entry, vars, NULL);
vars->data = data;
vars->fops = ops;
ldebugfs_add_vars(debugfs_entry, vars, NULL);
struct ldlm_namespace *ns = ldlm_pl2ns(pl);
struct dentry *debugfs_ns_parent;
struct lprocfs_vars pool_vars[2];
struct ldlm_namespace *ns = ldlm_pl2ns(pl);
struct dentry *debugfs_ns_parent;
struct lprocfs_vars pool_vars[2];
- OBD_ALLOC(var_name, MAX_STRING_SIZE + 1);
- if (!var_name)
- RETURN(-ENOMEM);
-
debugfs_ns_parent = ns->ns_debugfs_entry;
if (IS_ERR_OR_NULL(debugfs_ns_parent)) {
CERROR("%s: debugfs entry is not initialized\n",
ldlm_ns_name(ns));
debugfs_ns_parent = ns->ns_debugfs_entry;
if (IS_ERR_OR_NULL(debugfs_ns_parent)) {
CERROR("%s: debugfs entry is not initialized\n",
ldlm_ns_name(ns));
- GOTO(out_free_name, rc = -EINVAL);
+ GOTO(out, rc = -EINVAL);
}
pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent,
NULL, NULL);
}
pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent,
NULL, NULL);
pl->pl_debugfs_entry = NULL;
CERROR("%s: cannot create 'pool' debugfs entry: rc = %d\n",
ldlm_ns_name(ns), rc);
pl->pl_debugfs_entry = NULL;
CERROR("%s: cannot create 'pool' debugfs entry: rc = %d\n",
ldlm_ns_name(ns), rc);
- GOTO(out_free_name, rc);
- var_name[MAX_STRING_SIZE] = '\0';
memset(pool_vars, 0, sizeof(pool_vars));
memset(pool_vars, 0, sizeof(pool_vars));
- pool_vars[0].name = var_name;
ldlm_add_var(&pool_vars[0], pl->pl_debugfs_entry, "state", pl,
&lprocfs_pool_state_fops);
ldlm_add_var(&pool_vars[0], pl->pl_debugfs_entry, "state", pl,
&lprocfs_pool_state_fops);
pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
LDLM_POOL_FIRST_STAT, 0);
if (!pl->pl_stats)
pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
LDLM_POOL_FIRST_STAT, 0);
if (!pl->pl_stats)
- GOTO(out_free_name, rc = -ENOMEM);
+ GOTO(out, rc = -ENOMEM);
lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
-out_free_name:
- OBD_FREE(var_name, MAX_STRING_SIZE + 1);