[pacman-dev] [PATCH] libalpm: Do a sanity check before manipulating final DB URL
Allan McRae
allan at archlinux.org
Fri Apr 17 02:52:17 UTC 2015
On 17/04/15 06:34, David Macek wrote:
> On 16. 4. 2015 21:36, Florian Pritz wrote:
>> On 13.04.2015 21:33, David Macek wrote:
>>> + /* if we downloaded a DB, we want the .sig from the same server */
>>> + if(final_db_url != NULL) {
>>> /* print final_db_url into a buffer (leave space for .sig) */
>>> len = strlen(final_db_url) + 5;
>>> } else {
>>> - /* print server + filename into a buffer (leave space for .sig) */
>>> + /* print server + filename into a buffer (leave space for .db.sig) */
>>> len = strlen(server) + strlen(db->treename) + 9;
>>
>> Comment changed, but not the code?
>
> The comment was copied when the code was split into the two cases and the parenthesized part apparently wasn't correctly updated.
>
>> 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,
>
> I didn't know gcc could do that, thanks for the tip.
>
>> but writing it this way makes the
>> whole thing a lot clearer.
>
> First off, isn't this change better suited for a separate patch? If yes -- in order to speed up the potential merge -- the comment change can be removed from this patch and we can talk about the lengths in the context of another patch.
>
Just adjust the comment in a separate patch.
> The 9 there is for "/", ".db.sig", and the null terminator. Would this be a good way of re-writing the line?
>
> strlen(server) + strlen("/") + strlen(db->treename) + strlen(".db.sig") + 1;
>
Just make the comment "leave space for separator and .db.sig"
A
More information about the pacman-dev
mailing list