diff options
author | walter harms <wharms@bfs.de> | 2017-09-08 20:03:03 +0200 |
---|---|---|
committer | Emil Velikov <emil.l.velikov@gmail.com> | 2017-09-14 12:43:32 +0100 |
commit | f66955f7250d7c150dfb97862878acc2222781e5 (patch) | |
tree | ba3233bbba646e7d40659b591b879da0121e05da /src/shutdown.c | |
parent | 936dcaac07f7db569ed91a34e0a4b5944aac205f (diff) |
make IceProtocolShutdown() more readable
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@bfs.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
[Emil Velikov: whitespace fixes]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'src/shutdown.c')
-rw-r--r-- | src/shutdown.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/shutdown.c b/src/shutdown.c index 3f0880b..f27c876 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -40,45 +40,37 @@ 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; - 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; - } + /* + * Make sure this majorOpcode is really being used. + */ - if (i > iceConn->his_max_opcode) - { - return (0); - } - else + for (i = iceConn->his_min_opcode; i <= iceConn->his_max_opcode; i++) + { + int n = i - iceConn->his_min_opcode; + if (iceConn->process_msg_info[n].in_use && + iceConn->process_msg_info[n].my_opcode == majorOpcode) { + /* * OK, we can shut down the protocol. */ - iceConn->process_msg_info[ - i - iceConn->his_min_opcode].in_use = False; + iceConn->process_msg_info[n].in_use = False; iceConn->proto_ref_count--; - return (1); } } + + return (0); } |