All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Minchan Kim <minchan@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@kernel.org>, Paul Mackerras <paulus@samba.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	David Ahern <dsahern@gmail.com>
Subject: Re: [PATCH 1/2] perf tools: Ensure --symfs ends with '/'
Date: Mon, 11 Aug 2014 10:15:48 -0300	[thread overview]
Message-ID: <20140811131548.GA3277@kernel.org> (raw)
In-Reply-To: <87zjfbfpcm.fsf@sejong.aot.lge.com>

Em Mon, Aug 11, 2014 at 04:38:17PM +0900, Namhyung Kim escreveu:
> On Fri, 1 Aug 2014 17:15:38 -0300, Arnaldo Carvalho de Melo wrote:
> > Em Fri, Aug 01, 2014 at 08:38:02AM +0900, Namhyung Kim escreveu:
> >> On Thu, 31 Jul 2014 09:26:21 -0300, Arnaldo Carvalho de Melo wrote:
> >> > Em Thu, Jul 31, 2014 at 01:25:52PM +0900, Namhyung Kim escreveu:
> >> >> Are you still against my approach - adding '/' at the end of the symfs
> >> >> string itself?  It seems that mine is simpler and shorter.

> >> > Yes, I am.

> >> > We are not just concatenating two strings, we are joining two path
> >> > components.

> >> > I think it is more clear and elegant to do it as python os.path.join()
> >> > does.

> >> Then I think you also need to care about trailing and leading '/' in the
> >> components so that, say, joining '/home/' and '/namhyung/' can result in
> >> '/home/namhyung/' not '/home///namhyung/'.

> > Well, "/home/namhyung/" is the same as "/home///namhyung/" for POSIX:
> > http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap03.html#tag_03_266

> > So, when we can easily avoid it, no use to have a sequence of slashes,
> > but otherwise it is harmless.
 
> Yes, I know it's supported.  But I think it'd be better off avoiding it
> in order to be an elegant path joiner. :)

Yeah, when we can do such things with just one or two lines of code,
that is ok, but if not, hey, the kernel will do it for us. I.e. there
_is_ code already to make it sane, to understand the intent. And it is
_always_ in place, since this is a standard.
 
> >> Btw, it seems like python's os.path.join() just use latter if it's an
> >> absolute path.
> >> 
> >>   $ python
> >>   Python 2.7.3 (default, Jul 24 2012, 10:05:38) 
> >>   [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
> >>   Type "help", "copyright", "credits" or "license" for more information.
> >>   >>> import os.path
> >>   >>> os.path.join('/home/', '/namhyung/')
> >>   '/namhyung/'

> > Interesting, wonder what is the rationale for that or if this is a bug.
 
> Hmm.. pydoc os.path.join says below:
 
>  os.path.join = join(a, *p)
> 
>     Join two or more pathname components, inserting '/' as needed.  If
>     any component is an absolute path, all previous path components will
>     be discarded.  An empty last part will result in a path that ends
>     with a separator.

It states the behaviour, but doesn't present the rationale, that left me
wondering :)

- Arnaldo

      reply	other threads:[~2014-08-11 13:15 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-25  1:31 [PATCH 1/2] perf tools: Ensure --symfs ends with '/' Namhyung Kim
2014-07-25  1:31 ` [PATCH 2/2] perf tools: Check validity of --symfs value Namhyung Kim
2014-07-25 13:15 ` [PATCH 1/2] perf tools: Ensure --symfs ends with '/' Arnaldo Carvalho de Melo
2014-07-28  1:04   ` Namhyung Kim
2014-07-29  5:02 ` Minchan Kim
2014-07-29 12:33   ` Arnaldo Carvalho de Melo
2014-07-29 13:26     ` Minchan Kim
2014-07-29 13:43       ` Arnaldo Carvalho de Melo
2014-07-29 15:12       ` Arnaldo Carvalho de Melo
2014-07-29 13:57     ` David Ahern
2014-07-29 23:52     ` Namhyung Kim
2014-07-30 15:19       ` Arnaldo Carvalho de Melo
2014-07-30 20:55         ` Arnaldo Carvalho de Melo
2014-07-30 22:20           ` David Ahern
2014-07-31  4:25           ` Namhyung Kim
2014-07-31 12:26             ` Arnaldo Carvalho de Melo
2014-07-31 23:38               ` Namhyung Kim
2014-08-01 20:15                 ` Arnaldo Carvalho de Melo
2014-08-11  7:38                   ` Namhyung Kim
2014-08-11 13:15                     ` Arnaldo Carvalho de Melo [this message]

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=20140811131548.GA3277@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=dsahern@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    /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 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.