Review Request: Fix handling of FTP urls whose path name ends with a type code

Andreas Hartmetz ahartmetz at gmail.com
Sat Mar 19 17:19:20 GMT 2011


On Friday 18 March 2011 20:58:52 David Faure wrote:
> On Wednesday 16 March 2011, Thiago Macieira wrote:
> >     Suggestion:
> >         path.left(path.length() - sizeof ";type=");
> 
> Unreadable.
> 
> >     sizeof(";type=") == strlen(";type=X")
> 
> A hidden off-by-one, how nice to have in our code ;)

The best solution is... strlen(), actually. GCC [-O2] optimizes out strlen() 
with a constant argument and replaces it with the result. If you copy the 
string, say one for strcpy() and once for strlen(), that's fine because the 
instances will either be merged or the instance passed to strlen() disappears 
anyway due to strlen() being replaced with its result.




More information about the kde-core-devel mailing list