[PATCH libICE 2/2] make IceProtocolShutdown() more readable

Emil Velikov emil.l.velikov at gmail.com
Thu Sep 14 11:56:39 UTC 2017


On 12 September 2017 at 10:27, Eric Engestrom <eric.engestrom at imgtec.com> wrote:
> On Friday, 2017-09-08 20:03:03 +0200, walter harms wrote:
>> I found IceProtocolShutdown() hard to read only to find that was
>> it does it aktually very simple. So i rearranged the code to make
>> it more readable.
>>
>> Signed-off-by: Walter Harms <wharms at bfs.de>
>> ---
>>  src/shutdown.c | 47 ++++++++++++++++++++---------------------------
>>  1 file changed, 20 insertions(+), 27 deletions(-)
>>
>> diff --git a/src/shutdown.c b/src/shutdown.c
>> index 90e9ded..98376a7 100644
>> --- a/src/shutdown.c
>> +++ b/src/shutdown.c
>> @@ -40,45 +40,38 @@ IceProtocolShutdown (
>>       int     majorOpcode
>>  )
>>  {
>> +    int i;
>> +
>>      if (iceConn->proto_ref_count == 0 || iceConn->process_msg_info == NULL ||
>>          majorOpcode < 1 || majorOpcode > _IceLastMajorOpcode)
>>      {
>>       return (0);
>>      }
>> -    else
>> -    {
>> -     /*
>> -      * Make sure this majorOpcode is really being used.
>> -      */
>> -
>> -     int i;
>> +
>> +
>> +    /*
>> +     * Make sure this majorOpcode is really being used.
>> +     */
>>
>> -     for (i = iceConn->his_min_opcode; i <= iceConn->his_max_opcode; i++)
>> -     {
>> -         if (iceConn->process_msg_info[
>> -             i - iceConn->his_min_opcode].in_use &&
>> -                iceConn->process_msg_info[
>> -             i - iceConn->his_min_opcode].my_opcode == majorOpcode)
>> -             break;
>> -     }
>> +    for (i = iceConn->his_min_opcode; i <= iceConn->his_max_opcode; i++)
>> +      {
>> +     int n=i - iceConn->his_min_opcode;
>
> spaces around `=`, and can you be more consistent with the indentation?
> (mostly avoid mixing tabs and spaces).
>
libICE is fairly consistent on its tabs/spaces use. Namely tab is used
as a shorthand for eight spaces.
I've updated the patch to follow it and pushed the lot.

Thanks for the help gents.
Emil


More information about the xorg-devel mailing list