Thanks for the feedback, just send to list with examples. Ivana ----- Original Message ----- From: "Dhaval Giani" <dhaval.gi...@gmail.com> To: "Ivana Hutarova Varekova" <varek...@redhat.com> Cc: libcg-devel@lists.sourceforge.net Sent: Saturday, June 16, 2012 7:58:42 PM Subject: Re: [Libcg-devel] [PATCH 1/2] cg_build_path adds needless "/" character in cases when the input path
On Sat, Jun 16, 2012 at 6:30 PM, Ivana Hutarova Varekova <varek...@redhat.com> wrote: > ends/starts with character "/" itself. This character is added now only in > cases it is wanted and it was not set. > > Changelog > - incorporate Jan's feedback - fix typo in patch description, use snprintf > instead of sprintf > - deal with the situation if directory name is empty as well > > Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com> Can you please include an example as well in the patch description > --- > > src/api.c | 14 ++++++++++++-- > 1 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/src/api.c b/src/api.c > index 29de777..b8045a1 100644 > --- a/src/api.c > +++ b/src/api.c > @@ -1125,8 +1125,18 @@ static char *cg_build_path_locked(const char *name, > char *path, > > /* FIXME: missing OOM check here! */ > > - snprintf(path, FILENAME_MAX, "%s%s/", > - tmp, name); /* * name = "abc/" or, (name = null and tmp = "abc/") */ > + if ((name[strlen(name)-1] == '/') || > + ((strlen(name) == 0) && > + (tmp[strlen(tmp)-1] == '/'))) > + snprintf(path, FILENAME_MAX, > + "%s%s", tmp, > + name+((name[0] == '/') ? > + 1 : 0)); > + else > + snprintf(path, FILENAME_MAX, > + "%s%s/", tmp, > + name+((name[0] == '/') ? > + 1 : 0)); while not needed, can we please have {} surrounding the if conditions. It makes the code readable. Also, maybe we could just move this if condition to another static function. And then see if it can be simplified. Dhaval ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel