Changeset a35b458 in mainline for uspace/lib/compress/gzip.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/compress/gzip.c

    r3061bc1 ra35b458  
    8989        gzip_header_t header;
    9090        gzip_footer_t footer;
    91        
     91
    9292        if ((srclen < sizeof(header)) || (srclen < sizeof(footer)))
    9393                return EINVAL;
    94        
     94
    9595        /* Decode header and footer */
    96        
     96
    9797        memcpy(&header, src, sizeof(header));
    9898        memcpy(&footer, src + srclen - sizeof(footer), sizeof(footer));
    99        
     99
    100100        if ((header.id1 != GZIP_ID1) ||
    101101            (header.id2 != GZIP_ID2) ||
     
    103103            ((header.flags & (~GZIP_FLAGS_MASK)) != 0))
    104104                return EINVAL;
    105        
     105
    106106        *destlen = uint32_t_le2host(footer.size);
    107        
     107
    108108        /* Ignore extra metadata */
    109        
     109
    110110        void *stream = src + sizeof(header);
    111111        size_t stream_length = srclen - sizeof(header) - sizeof(footer);
    112        
     112
    113113        if ((header.flags & GZIP_FLAG_FEXTRA) != 0) {
    114114                uint16_t extra_length;
    115                
     115
    116116                if (stream_length < sizeof(extra_length))
    117117                        return EINVAL;
    118                
     118
    119119                memcpy(&extra_length, stream, sizeof(extra_length));
    120120                stream += sizeof(extra_length);
    121121                stream_length -= sizeof(extra_length);
    122                
     122
    123123                if (stream_length < extra_length)
    124124                        return EINVAL;
    125                
     125
    126126                stream += extra_length;
    127127                stream_length -= extra_length;
    128128        }
    129        
     129
    130130        if ((header.flags & GZIP_FLAG_FNAME) != 0) {
    131131                while (*((uint8_t *) stream) != 0) {
    132132                        if (stream_length == 0)
    133133                                return EINVAL;
    134                        
     134
    135135                        stream++;
    136136                        stream_length--;
    137137                }
    138                
     138
    139139                if (stream_length == 0)
    140140                        return EINVAL;
    141                
     141
    142142                stream++;
    143143                stream_length--;
    144144        }
    145        
     145
    146146        if ((header.flags & GZIP_FLAG_FCOMMENT) != 0) {
    147147                while (*((uint8_t *) stream) != 0) {
    148148                        if (stream_length == 0)
    149149                                return EINVAL;
    150                        
     150
    151151                        stream++;
    152152                        stream_length--;
    153153                }
    154                
     154
    155155                if (stream_length == 0)
    156156                        return EINVAL;
    157                
     157
    158158                stream++;
    159159                stream_length--;
    160160        }
    161        
     161
    162162        if ((header.flags & GZIP_FLAG_FHCRC) != 0) {
    163163                if (stream_length < 2)
    164164                        return EINVAL;
    165                
     165
    166166                stream += 2;
    167167                stream_length -= 2;
    168168        }
    169        
     169
    170170        /* Allocate output buffer and inflate the data */
    171        
     171
    172172        *dest = malloc(*destlen);
    173173        if (*dest == NULL)
    174174                return ENOMEM;
    175        
     175
    176176        errno_t ret = inflate(stream, stream_length, *dest, *destlen);
    177177        if (ret != EOK) {
     
    179179                return ret;
    180180        }
    181        
     181
    182182        return EOK;
    183183}
Note: See TracChangeset for help on using the changeset viewer.