Re: [PATCH v2 2/3] Adjust stat width calculations to take --graph output into account

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 12, 2012 at 03:17, Zbigniew Jędrzejewski-Szmek
<zbyszek@xxxxxxxxx> wrote:
>>>> +
>>>> +             /*
>>>> +              * If the remaining unreserved space will not accomodate
>>>> the
>>>> +              * filenames, adjust name_width to use all available
>>>> remaining space.
>>>> +              * Otherwise, assign any extra space to graph_width.
>>>> +              */
>>>> +             if (name_width>    width - reserved_character_count -
>>>> graph_width) {
>>>> +                     name_width = width - reserved_character_count -
>>>> graph_width;
>>>> +             } else {
>>>> +                     graph_width = width - reserved_character_count -
>>>> name_width;
>>>> +             }
>>>> +
>>>> +             /*
>>>> +              * If stat-graph-width was specified, limit graph_width to
>>>> its value.
>>>> +              */
>>>>               if (options->stat_graph_width&&
>>>> -                 graph_width>    options->stat_graph_width)
>>>> +                             graph_width>    options->stat_graph_width)
>>>> {
>>>>                       graph_width = options->stat_graph_width;
>>>> -             if (name_width>    width - number_width - 6 - graph_width)
>>>> -                     name_width = width - number_width - 6 -
>>>> graph_width;
>>>> -             else
>>>> -                     graph_width = width - number_width - 6 -
>>>> name_width;
>>>> +             }
>>>
>>> Here, the order of the two tests
>>> (1) if (options->stat_graph_width&&  graph_width>
>>>  options->stat_graph_width)
>>>
>>> (2) if (name_width>  width - number_width - 6 - graph_width)
>>> is reversed. This is not OK, because this means that
>>> options->stat_graph_width will be used unconditionally, while
>>> before it was subject to limiting by total width.
>>
>>
>> If options->stat_graph_width is specified, it should always limit the
>> value of graph_width, correct? Since (1) is the last test, it can only
>> decrease the value of graph_width, which would already be limited by
>> the total width.
>
> Right, but the way the tests are ordered now, we could end up decreasing
> name_width first (after (2)) and then graph_width (after (1)), actually
> using less than full width.

Ahh, I didn't think about that.

I just reverted the order back to the original.

>> I just noticed that name_width isn't being limited to stat_name_width,
>> if it is specified. I'll add a check for that.
>
> Sounds good.

FYI, in patch v3, I reverted the check for stat_graph_width as previously
mentioned, and I ended up not adding a check for stat_name_width.
It remains the case that in certain scenarios, name_width & graph_width
could be set to values greater than stat_name_width & stat_graph_width.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]