[pacman-dev] [PATCH] rewrite strreplace

Dan McGee dpmcgee at gmail.com
Mon Sep 7 13:57:34 EDT 2009


On Mon, Sep 7, 2009 at 12:50 PM, Xavier<shiningxc at gmail.com> wrote:
> On Mon, Sep 7, 2009 at 2:08 AM, Dan McGee<dpmcgee at gmail.com> wrote:
>> On Sun, Sep 6, 2009 at 6:47 PM, Xavier Chantry<shiningxc at gmail.com> wrote:
>>> +
>>> +       if(!list) {
>>> +               return(strdup(str));
>>> +       }
>>> +       newstr = malloc(strlen(str) + 1 +
>>> +                       alpm_list_count(list) * (replacesz - needlesz));
>> Maybe an explanation comment here? And there should be no way to trick
>> this up by having needlesize > replacesize, or the other way around
>> (replacesize > needlesize), since those are declared as unsigned?
>>
>
> All situations should be handled, needlesize >= replacesize or
> needlesize <= replacesize
>
> But I don't understand what the problem is with unsigned ? I guess
> it's probably a good thing that size/legnth are positive.

You are doing math on two unsigned integers, and you need a signed
result. I just want to make sure the result is sane.

-Dan


More information about the pacman-dev mailing list