From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Buesch Date: Sun, 06 Feb 2005 09:54:15 +0000 Subject: Re: [PATCH, UDEV] change no_trailing_slash() to remove all trailing slashes Message-Id: <200502061054.20512.mbuesch@freenet.de> MIME-Version: 1 Content-Type: multipart/mixed; boundary="nextPart4060613.TJvIRoXmq3" List-Id: References: <200502051818.54277.mbuesch@freenet.de> In-Reply-To: <200502051818.54277.mbuesch@freenet.de> To: linux-hotplug@vger.kernel.org --nextPart4060613.TJvIRoXmq3 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Quoting Paul Jackson : > What if someone does: >=20 > strcpy(buf, "/"); > no_trailing_slash(buf); > strcat(buf, "foo"); >=20 > 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] =3D=3D '\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. >=20 > I would have expected it to be called after the final > construction, following the concatenation of a variable > string. >=20 > And I would have expected it to scrupulously avoid changing > the meaning of the path - just cosmetic trimming. >=20 > But apparently my expectations are confused. Feel free to > dismiss my comments. >=20 =2D-=20 Regards Michael Buesch [ http://www.tuxsoft.de.vu ] --nextPart4060613.TJvIRoXmq3 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBCBelMFGK1OIvVOP4RAkmLAKDEwIIuzItNZ1JBABQkaaM38GEruQCggYUo 2k4YNcH6w2csnfCkBTvlRog= =0Z1t -----END PGP SIGNATURE----- --nextPart4060613.TJvIRoXmq3-- ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel