Ignore:
Timestamp:
2010-09-19T12:55:05Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2fa0ad9, dc94cb2
Parents:
553f430
Message:

Coding style fixes.

This changeset converts the entire TCP code into HelenOS cstyle and improves
its general legibility by adding vertical spacing and removing unnecessary
clutter. It also attempts to suppress too deep nesting of blocks by
functional-equivalent code restructuralization.

This changeset brings no change in functionality (hopefully), but it should make
it easier to understand and eventually fix TCP code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/socket/packet/packet_client.c

    r553f430 r7c8267b  
    122122}
    123123
    124 int packet_set_addr(packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len){
     124int
     125packet_set_addr(packet_t packet, const uint8_t * src, const uint8_t * dest,
     126    size_t addr_len)
     127{
    125128        size_t padding;
    126129        size_t allocated;
    127130
    128         if(! packet_is_valid(packet)){
     131        if (!packet_is_valid(packet))
    129132                return EINVAL;
    130         }
     133
    131134        allocated = PACKET_MAX_ADDRESS_LENGTH(packet);
    132         if(allocated < addr_len){
     135        if (allocated < addr_len)
    133136                return ENOMEM;
    134         }
     137
    135138        padding = allocated - addr_len;
    136139        packet->addr_len = addr_len;
    137         if(src){
     140
     141        if (src) {
    138142                memcpy((void *) packet + packet->src_addr, src, addr_len);
    139                 if(padding){
    140                         bzero((void *) packet + packet->src_addr + addr_len, padding);
    141                 }
    142         }else{
     143                if (padding)
     144                        bzero((void *) packet + packet->src_addr + addr_len,
     145                            padding);
     146        } else {
    143147                bzero((void *) packet + packet->src_addr, allocated);
    144148        }
    145         if(dest){
     149
     150        if (dest) {
    146151                memcpy((void *) packet + packet->dest_addr, dest, addr_len);
    147                 if(padding){
    148                         bzero((void *) packet + packet->dest_addr + addr_len, padding);
    149                 }
    150         }else{
     152                if (padding)
     153                        bzero((void *) packet + packet->dest_addr + addr_len,
     154                            padding);
     155        } else {
    151156                bzero((void *) packet + packet->dest_addr, allocated);
    152157        }
     158
    153159        return EOK;
    154160}
Note: See TracChangeset for help on using the changeset viewer.