From: Michael Buesch <mbuesch@freenet.de>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH, UDEV] change no_trailing_slash() to remove all trailing slashes
Date: Sun, 06 Feb 2005 09:54:15 +0000 [thread overview]
Message-ID: <200502061054.20512.mbuesch@freenet.de> (raw)
In-Reply-To: <200502051818.54277.mbuesch@freenet.de>
[-- Attachment #1: Type: text/plain, Size: 1437 bytes --]
Quoting Paul Jackson <pj@sgi.com>:
> What if someone does:
>
> strcpy(buf, "/");
> no_trailing_slash(buf);
> strcat(buf, "foo");
>
> Would you expect "foo", or "/foo" ?
I would expect "foo".
It's the function semantics:
no_trailing_slash means (at least for me) clearly,
that there will be "no trailing slash" under any circumstances in
the string.
It should be the caller's job to ensure, that we have a
valid path after cutting of all trailing slashes.
strcpy(buf, "/");
no_trailing_slash(buf);
if (buf[0] == '\0')
strcat(buf, "/");
strcat(buf, "foo");
But having saied this all, I can't find where this
actually happens in the udev code. I did a very quick
search even before I submitted the code, but I could only
find places like this, which will always result
in a valid path:
no_trailing_slash(buf);
strcat(buf, "/foo");
> Actually, I did not expect this to be called in the middle
> of a construction, after only explicit constant strings
> had been added.
>
> I would have expected it to be called after the final
> construction, following the concatenation of a variable
> string.
>
> And I would have expected it to scrupulously avoid changing
> the meaning of the path - just cosmetic trimming.
>
> But apparently my expectations are confused. Feel free to
> dismiss my comments.
>
--
Regards Michael Buesch [ http://www.tuxsoft.de.vu ]
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
prev parent reply other threads:[~2005-02-06 9:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-05 17:18 [PATCH, UDEV] change no_trailing_slash() to remove all trailing slashes Michael Buesch
2005-02-05 18:15 ` [PATCH, UDEV] change no_trailing_slash() to remove all Kay Sievers
2005-02-05 22:04 ` [PATCH, UDEV] change no_trailing_slash() to remove all trailing Paul Jackson
2005-02-05 22:36 ` [PATCH, UDEV] change no_trailing_slash() to remove all trailing slashes Michael Buesch
2005-02-06 1:11 ` [PATCH, UDEV] change no_trailing_slash() to remove all trailing Paul Jackson
2005-02-06 9:54 ` Michael Buesch [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=200502061054.20512.mbuesch@freenet.de \
--to=mbuesch@freenet.de \
--cc=linux-hotplug@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).