⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259814 in webkit


Ignore:
Timestamp:
Apr 9, 2020, 12:33:20 PM (6 years ago)
Author:
ddkilzer@apple.com
Message:

WTF::Persistence::Coder and WTF::Persistence::Decoder should use WARN_UNUSED_RETURN
<https://webkit.org/b/210238>
<rdar://problem/61491575>

Reviewed by Darin Adler.

Source/WebKit:

  • NetworkProcess/cache/NetworkCacheEntry.cpp:

(WebKit::NetworkCache::Entry::decodeStorageRecord):

  • Add missing return value check for decode.decode().

Source/WTF:

  • wtf/persistence/PersistentCoders.cpp:

(WTF::Persistence::decodeStringText):

  • Add WARN_UNUSED_RETURN.
  • wtf/persistence/PersistentCoders.h:

(WTF::Persistence::Coder<Optional<T>>::decode):
(WTF::Persistence::Coder<Seconds>::decode):
(WTF::Persistence::Coder<WallTime>::decode):

  • Add WARN_UNUSED_RETURN.
  • Add missing return value check for decode.decodeFixedLengthData().
  • wtf/persistence/PersistentDecoder.h:

(WTF::Persistence::Decoder::decode):
(WTF::Persistence::Decoder::decodeEnum):
(WTF::Persistence::Decoder::bufferIsLargeEnoughToContain const):

  • Add WARN_UNUSED_RETURN.
Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r259788 r259814  
     12020-04-09  David Kilzer  <ddkilzer@apple.com>
     2
     3        WTF::Persistence::Coder and WTF::Persistence::Decoder should use WARN_UNUSED_RETURN
     4        <https://webkit.org/b/210238>
     5        <rdar://problem/61491575>
     6
     7        Reviewed by Darin Adler.
     8
     9        * wtf/persistence/PersistentCoders.cpp:
     10        (WTF::Persistence::decodeStringText):
     11        - Add WARN_UNUSED_RETURN.
     12
     13        * wtf/persistence/PersistentCoders.h:
     14        (WTF::Persistence::Coder<Optional<T>>::decode):
     15        (WTF::Persistence::Coder<Seconds>::decode):
     16        (WTF::Persistence::Coder<WallTime>::decode):
     17        - Add WARN_UNUSED_RETURN.
     18        - Add missing return value check for
     19          decode.decodeFixedLengthData().
     20
     21        * wtf/persistence/PersistentDecoder.h:
     22        (WTF::Persistence::Decoder::decode):
     23        (WTF::Persistence::Decoder::decodeEnum):
     24        (WTF::Persistence::Decoder::bufferIsLargeEnoughToContain const):
     25        - Add WARN_UNUSED_RETURN.
     26
    1272020-04-09  David Kilzer  <ddkilzer@apple.com>
    228
  • trunk/Source/WTF/wtf/persistence/PersistentCoders.cpp

    r246490 r259814  
    107107
    108108template <typename CharacterType>
    109 static inline bool decodeStringText(Decoder& decoder, uint32_t length, String& result)
     109static inline WARN_UNUSED_RETURN bool decodeStringText(Decoder& decoder, uint32_t length, String& result)
    110110{
    111111    // Before allocating the string, make sure that the decoder buffer is big enough.
  • trunk/Source/WTF/wtf/persistence/PersistentCoders.h

    r259788 r259814  
    4747    }
    4848
    49     static bool decode(Decoder& decoder, std::pair<T, U>& pair)
     49    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, std::pair<T, U>& pair)
    5050    {
    5151        T first;
     
    7575    }
    7676   
    77     static bool decode(Decoder& decoder, Optional<T>& optional)
     77    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Optional<T>& optional)
    7878    {
    7979        bool isEngaged;
     
    101101    }
    102102
    103     static bool decode(Decoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair)
     103    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair)
    104104    {
    105105        KeyType key;
     
    127127    }
    128128
    129     static bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
     129    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
    130130    {
    131131        uint64_t size;
     
    155155    }
    156156   
    157     static bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
     157    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
    158158    {
    159159        uint64_t decodedSize;
     
    175175        temp.grow(size);
    176176
    177         decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T));
     177        if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T)))
     178            return false;
    178179
    179180        vector.swap(temp);
     
    194195    }
    195196
    196     static bool decode(Decoder& decoder, HashMapType& hashMap)
     197    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashMapType& hashMap)
    197198    {
    198199        uint64_t hashMapSize;
     
    231232    }
    232233
    233     static bool decode(Decoder& decoder, HashSetType& hashSet)
     234    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashSetType& hashSet)
    234235    {
    235236        uint64_t hashSetSize;
     
    260261    }
    261262
    262     static bool decode(Decoder& decoder, Seconds& result)
     263    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Seconds& result)
    263264    {
    264265        double value;
     
    277278    }
    278279
    279     static bool decode(Decoder& decoder, WallTime& result)
     280    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WallTime& result)
    280281    {
    281282        double value;
     
    290291template<> struct Coder<AtomString> {
    291292    WTF_EXPORT_PRIVATE static void encode(Encoder&, const AtomString&);
    292     WTF_EXPORT_PRIVATE static bool decode(Decoder&, AtomString&);
     293    WTF_EXPORT_PRIVATE static bool decode(Decoder&, AtomString&) WARN_UNUSED_RETURN;
    293294};
    294295
    295296template<> struct Coder<CString> {
    296297    WTF_EXPORT_PRIVATE static void encode(Encoder&, const CString&);
    297     WTF_EXPORT_PRIVATE static bool decode(Decoder&, CString&);
     298    WTF_EXPORT_PRIVATE static bool decode(Decoder&, CString&) WARN_UNUSED_RETURN;
    298299};
    299300
    300301template<> struct Coder<String> {
    301302    WTF_EXPORT_PRIVATE static void encode(Encoder&, const String&);
    302     WTF_EXPORT_PRIVATE static bool decode(Decoder&, String&);
     303    WTF_EXPORT_PRIVATE static bool decode(Decoder&, String&) WARN_UNUSED_RETURN;
    303304};
    304305
    305306template<> struct Coder<SHA1::Digest> {
    306307    WTF_EXPORT_PRIVATE static void encode(Encoder&, const SHA1::Digest&);
    307     WTF_EXPORT_PRIVATE static bool decode(Decoder&, SHA1::Digest&);
     308    WTF_EXPORT_PRIVATE static bool decode(Decoder&, SHA1::Digest&) WARN_UNUSED_RETURN;
    308309};
    309310
  • trunk/Source/WTF/wtf/persistence/PersistentDecoder.h

    r255846 r259814  
    4242    size_t currentOffset() const { return m_bufferPosition - m_buffer; }
    4343
    44     WTF_EXPORT_PRIVATE bool verifyChecksum();
     44    WTF_EXPORT_PRIVATE bool verifyChecksum() WARN_UNUSED_RETURN;
    4545
    46     WTF_EXPORT_PRIVATE bool decodeFixedLengthData(uint8_t*, size_t);
     46    WTF_EXPORT_PRIVATE bool decodeFixedLengthData(uint8_t*, size_t) WARN_UNUSED_RETURN;
    4747
    48     WTF_EXPORT_PRIVATE bool decode(bool&);
    49     WTF_EXPORT_PRIVATE bool decode(uint8_t&);
    50     WTF_EXPORT_PRIVATE bool decode(uint16_t&);
    51     WTF_EXPORT_PRIVATE bool decode(uint32_t&);
    52     WTF_EXPORT_PRIVATE bool decode(uint64_t&);
    53     WTF_EXPORT_PRIVATE bool decode(int16_t&);
    54     WTF_EXPORT_PRIVATE bool decode(int32_t&);
    55     WTF_EXPORT_PRIVATE bool decode(int64_t&);
    56     WTF_EXPORT_PRIVATE bool decode(float&);
    57     WTF_EXPORT_PRIVATE bool decode(double&);
     48    WTF_EXPORT_PRIVATE bool decode(bool&) WARN_UNUSED_RETURN;
     49    WTF_EXPORT_PRIVATE bool decode(uint8_t&) WARN_UNUSED_RETURN;
     50    WTF_EXPORT_PRIVATE bool decode(uint16_t&) WARN_UNUSED_RETURN;
     51    WTF_EXPORT_PRIVATE bool decode(uint32_t&) WARN_UNUSED_RETURN;
     52    WTF_EXPORT_PRIVATE bool decode(uint64_t&) WARN_UNUSED_RETURN;
     53    WTF_EXPORT_PRIVATE bool decode(int16_t&) WARN_UNUSED_RETURN;
     54    WTF_EXPORT_PRIVATE bool decode(int32_t&) WARN_UNUSED_RETURN;
     55    WTF_EXPORT_PRIVATE bool decode(int64_t&) WARN_UNUSED_RETURN;
     56    WTF_EXPORT_PRIVATE bool decode(float&) WARN_UNUSED_RETURN;
     57    WTF_EXPORT_PRIVATE bool decode(double&) WARN_UNUSED_RETURN;
    5858
    59     template<typename E> auto decode(E& e) -> std::enable_if_t<std::is_enum<E>::value, bool>
     59    template<typename E> WARN_UNUSED_RETURN
     60    auto decode(E& e) -> std::enable_if_t<std::is_enum<E>::value, bool>
    6061    {
    6162        uint64_t value;
     
    6970    }
    7071
    71     template<typename T> bool decodeEnum(T& result)
     72    template<typename T> WARN_UNUSED_RETURN
     73    bool decodeEnum(T& result)
    7274    {
    7375        static_assert(sizeof(T) <= 8, "Enum type T must not be larger than 64 bits!");
     
    8183    }
    8284
    83     template<typename T> auto decode(T& t) -> std::enable_if_t<!std::is_enum<T>::value, bool>
     85    template<typename T> WARN_UNUSED_RETURN
     86    auto decode(T& t) -> std::enable_if_t<!std::is_enum<T>::value, bool>
    8487    {
    8588        return Coder<T>::decode(*this, t);
    8689    }
    8790
    88     template<typename T>
     91    template<typename T> WARN_UNUSED_RETURN
    8992    bool bufferIsLargeEnoughToContain(size_t numElements) const
    9093    {
     
    100103
    101104private:
    102     WTF_EXPORT_PRIVATE bool bufferIsLargeEnoughToContain(size_t) const;
    103     template<typename Type> bool decodeNumber(Type&);
     105    WTF_EXPORT_PRIVATE bool bufferIsLargeEnoughToContain(size_t) const WARN_UNUSED_RETURN;
     106    template<typename Type> bool decodeNumber(Type&) WARN_UNUSED_RETURN;
    104107
    105108    const uint8_t* m_buffer;
  • trunk/Source/WebKit/ChangeLog

    r259812 r259814  
     12020-04-09  David Kilzer  <ddkilzer@apple.com>
     2
     3        WTF::Persistence::Coder and WTF::Persistence::Decoder should use WARN_UNUSED_RETURN
     4        <https://webkit.org/b/210238>
     5        <rdar://problem/61491575>
     6
     7        Reviewed by Darin Adler.
     8
     9        * NetworkProcess/cache/NetworkCacheEntry.cpp:
     10        (WebKit::NetworkCache::Entry::decodeStorageRecord):
     11        - Add missing return value check for decode.decode().
     12
    1132020-04-09  Per Arne Vollan  <pvollan@apple.com>
    214
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheEntry.cpp

    r254514 r259814  
    136136    }
    137137
    138     decoder.decode(entry->m_maxAgeCap);
    139    
     138    if (!decoder.decode(entry->m_maxAgeCap))
     139        return nullptr;
     140
    140141    if (!decoder.verifyChecksum()) {
    141142        LOG(NetworkCache, "(NetworkProcess) checksum verification failure\n");
Note: See TracChangeset for help on using the changeset viewer.