From: Julia Lawall <julia.lawall@lip6.fr>
To: walter harms <wharms@bfs.de>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>,
kernel-janitors@vger.kernel.org, HPDD-discuss@ml01.01.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 8/11] staging: lustre: obdclass: Use kzalloc and kfree
Date: Fri, 1 May 2015 20:42:36 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.02.1505012037550.2092@localhost6.localdomain6> (raw)
In-Reply-To: <5543C660.8000303@bfs.de>
On Fri, 1 May 2015, walter harms wrote:
> hi Julia,
> your patch seems fine.
> I tried to understand the code and it seems that much of it
> can be simplified by using already available functions.
> I have added some comments but i am not sure what to make of it.
Thanks for the review. Comments below.
> >
> > len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1;
> > - OBD_ALLOC(mgcname, len);
> > - OBD_ALLOC(niduuid, len + 2);
> > + mgcname = kzalloc(len, GFP_NOFS);
> > + niduuid = kzalloc(len + 2, GFP_NOFS);
> > if (!mgcname || !niduuid) {
> > rc = -ENOMEM;
> > goto out_free;
>
> this can be simplified by using
> kasprintf(&mgcname,"%s%s", LUSTRE_MGC_OBDNAME, libcfs_nid2str(nid));
>
> is guess the some is true for niduuid
Thanks for the suggestion. I will look into that next. It may be
applicable elsewhere.
> > /* Save the obdname for cleaning the nid uuids, which are
> > obdname_XX */
> > len = strlen(obd->obd_name) + 6;
> > - OBD_ALLOC(niduuid, len);
> > + niduuid = kzalloc(len, GFP_NOFS);
> > if (niduuid) {
> > strcpy(niduuid, obd->obd_name);
> > ptr = niduuid + strlen(niduuid);
>
> i guess kstrdup() would be appropiate
OK, I will check on this too.
> > @@ -895,7 +887,7 @@ static int lmd_parse_mgssec(struct lustr
> > int length;
> >
> > if (lmd->lmd_mgssec != NULL) {
> > - OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
> > + kfree(lmd->lmd_mgssec);
> > lmd->lmd_mgssec = NULL;
> > }
>
> is the check needed hier at all ? just
> kfree(lmd->lmd_mgssec);
> seems to do the same job.
I'm working on that right at the moment. Patch shortly.
>
> >
> > @@ -905,7 +897,7 @@ static int lmd_parse_mgssec(struct lustr
> > else
> > length = tail - ptr;
> >
> > - OBD_ALLOC(lmd->lmd_mgssec, length + 1);
> > + lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS);
> > if (lmd->lmd_mgssec == NULL)
> > return -ENOMEM;
> >
>
> complicated why to say:
> lmd->lmd_mgssec=kstrndup(ptr, length,GFP_NOFS);
OK, I will look into it.
> > @@ -933,7 +925,7 @@ static int lmd_parse_string(char **handl
> > else
> > length = tail - ptr;
> >
> > - OBD_ALLOC(*handle, length + 1);
> > + *handle = kzalloc(length + 1, GFP_NOFS);
> > if (*handle == NULL)
> > return -ENOMEM;
> >
>
> lmd_parse_string() seems more or less the same as lmd_parse_mgssec().
> perhaps this can be merged.
I will check.
> > @@ -971,7 +963,7 @@ static int lmd_parse_mgs(struct lustre_m
> > /* Multiple mgsnid= are taken to mean failover locations */
> > memcpy(mgsnid, lmd->lmd_mgs, oldlen);
> > mgsnid[oldlen - 1] = ':';
> > - OBD_FREE(lmd->lmd_mgs, oldlen);
> > + kfree(lmd->lmd_mgs);
> > }
> > memcpy(mgsnid + oldlen, *ptr, length);
> > mgsnid[oldlen + length] = '\0';
>
> the code lmd_parse_mgs basicly does:
> kasprintf( &lmd->lmd_mgs,"%s:%s",lmd->lmd_mgs,*ptr);
OK.
thanks,
julia
next prev parent reply other threads:[~2015-05-01 18:42 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 15:51 [PATCH 0/11] " Julia Lawall
2015-05-01 15:51 ` [PATCH 11/11] staging: lustre: ptlrpc: " Julia Lawall
2015-05-01 15:51 ` [PATCH 10/11] staging: lustre: osc: " Julia Lawall
2015-05-01 15:51 ` [PATCH 9/11] staging: lustre: obdecho: " Julia Lawall
2015-05-01 15:51 ` [PATCH 8/11] staging: lustre: obdclass: " Julia Lawall
2015-05-01 18:30 ` walter harms
2015-05-01 18:42 ` Julia Lawall [this message]
2015-05-01 15:51 ` [PATCH 7/11] staging: lustre: mgc: " Julia Lawall
2015-05-01 15:51 ` [PATCH 6/11] staging: lustre: mdc: " Julia Lawall
2015-05-01 15:51 ` [PATCH 5/11] staging: lustre: lmv: " Julia Lawall
2015-05-01 15:51 ` [PATCH 4/11] staging: lustre: ldlm: " Julia Lawall
2015-05-01 15:51 ` [PATCH 3/11] staging: lustre: lclient: " Julia Lawall
2015-05-01 15:51 ` [PATCH 2/11] Staging: lustre: fld: " Julia Lawall
2015-05-01 17:38 ` [HPDD-discuss] " Simmons, James A.
2015-05-01 17:48 ` Julia Lawall
2015-05-01 18:49 ` Drokin, Oleg
2015-05-01 20:18 ` Simmons, James A.
2015-05-01 20:47 ` Greg Kroah-Hartman
2015-05-01 22:57 ` Simmons, James A.
2015-05-01 20:49 ` Drokin, Oleg
2015-05-01 22:59 ` Simmons, James A.
2015-05-01 18:05 ` Greg Kroah-Hartman
2015-05-01 20:02 ` Dan Carpenter
2015-05-01 20:12 ` Drokin, Oleg
2015-05-01 20:36 ` Simmons, James A.
2015-05-01 20:49 ` Greg Kroah-Hartman
2015-05-01 20:52 ` Drokin, Oleg
2015-05-01 20:58 ` Greg Kroah-Hartman
2015-05-01 21:13 ` Drokin, Oleg
2015-05-02 6:02 ` Julia Lawall
2015-05-02 8:14 ` Dan Carpenter
2015-05-02 9:05 ` Julia Lawall
2015-05-03 3:12 ` Drokin, Oleg
2015-05-01 15:51 ` [PATCH 1/11] staging: lustre: fid: " Julia Lawall
2015-05-03 18:17 ` [PATCH 0/11] " Greg Kroah-Hartman
2015-05-03 18:39 ` Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.02.1505012037550.2092@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=HPDD-discuss@ml01.01.org \
--cc=devel@driverdev.osuosl.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wharms@bfs.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®