[pacman-dev] [PATCH] libalpm: Do a sanity check before manipulating final DB URL

Martti Kühne mysatyre at gmail.com
Sat Apr 18 14:25:07 UTC 2015

On Thu, Apr 16, 2015 at 9:36 PM, Florian Pritz <bluewind at xinu.at> wrote:
> Comment changed, but not the code? If you know where that + 9 comes from
> it might be a good idea to replace it with strlen("whatever") which the
> compile should optimize out later, but writing it this way makes the
> whole thing a lot clearer.

Do the pacman developers trust the compiler with optimizing strlen()?
Because there's sizeof which does a perfectly predictable (off-by-one)
job using but an operator for measuring the length of a string
constant. Furthermore it does so without implying the compiler would
sidestep the standard library's work in a way or another... Who says
you can't have a libc "obscurelibc" that does something else there?

A preprocessor macro branching on (#x == '"') or (sizeof(x) ==
sizeof(char*)) would be the less beautiful alternative, but I think
I'm risking to be yelled back at that way. :-)


More information about the pacman-dev mailing list