Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document and improve abstract reader/writer interface #208

Open
wants to merge 26 commits into
base: dev
Choose a base branch
from

Commits on Jun 21, 2024

  1. CI: add dependabot configuration

    Dependabot can provide automatic pull requests
    for things in the repository that should
    be updated.
    
    Example PR from dependabot against a repo owned
    by the github organization:
    
    github/opensource.guide#2248
    
    Documentation:
    
    https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates
    pjonsson authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    0ff814d View commit details
    Browse the repository at this point in the history
  2. CI: add Github CI

    pjonsson authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    2265e82 View commit details
    Browse the repository at this point in the history
  3. follow-up commit to 75eaa19

    facilitate replacement of malloc/free functions
    
    open_memstream functions are left out of this change as they require
    other functions from stdlib.
    lightyear15 authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    ad60cea View commit details
    Browse the repository at this point in the history
  4. Tests: disable the C90 test

    We don't support this any more.
    ```
    ../../src/cbor.h:255:69: error: '_Bool' is a C99 extension [-Werror,-Wc99-extensions]
    CBOR_INLINE_API CborError cbor_encode_boolean(CborEncoder *encoder, bool value)
                                                                        ^
    ```
    
    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    8907f20 View commit details
    Browse the repository at this point in the history
  5. CI: Get Homebrew to use a bottle (precompiled) Qt

    Homebrew no longer carries precompiled versions of Qt for macos-11, so
    switch to macos-13, the last on x86 CPUs (so we can still run
    Valgrind). It's also going away after the end of June.
    
    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    89723e2 View commit details
    Browse the repository at this point in the history
  6. CI: remove Valgrind on macOS: it doesn't work

    ```
    ==21147== Valgrind: debuginfo reader: ensure_valid failed:
    ==21147== Valgrind:   during call to ML_(img_get)
    ==21147== Valgrind:   request for range [18446744069408125024, +16) exceeds
    ==21147== Valgrind:   valid image size of 140733057859584 for image:
    ==21147== Valgrind:   "/usr/local/Cellar/icu4c/74.2/lib/libicudata.74.2.dylib"
    ```
    
    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    f9fd089 View commit details
    Browse the repository at this point in the history
  7. CI/Makefile: do allow Qt 6

    I don't think we need to worry about Qt 4 any more.
    
    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    e9963de View commit details
    Browse the repository at this point in the history
  8. CI: unbreak macOS: need to have CXX set

    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    6550f66 View commit details
    Browse the repository at this point in the history
  9. CI: Run the configure step in verbose mode and print the config output

    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    a38a520 View commit details
    Browse the repository at this point in the history
  10. Makefile: disable cJSON support when building without math support

    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    5d167a0 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    722318d View commit details
    Browse the repository at this point in the history
  12. CI: add 'permissions' token to the GitHub actions file

    Intel says this is needed
    
    Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
    thiagomacieira authored and sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    b4e1cc7 View commit details
    Browse the repository at this point in the history
  13. cborparser: Move parser initialisation to common routine.

    `cbor_parser_init` and `cbor_parser_init_reader` are substantially
    similar, however the latter misses clearing out `it->flags`, leaving it
    uninitialised so possibly unsafe.
    
    Rather than copying & pasting that from `cbor_parser_init`, lets just
    use one routine that does the "common" part, then each routine can focus
    on the specifics needed.
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    f994144 View commit details
    Browse the repository at this point in the history
  14. cborparser: Document cbor_parser_init_reader.

    Describe the input parameters for the function and how they are used as
    best we understand from on-paper analysis of the C code.
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    167eef6 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    286d132 View commit details
    Browse the repository at this point in the history
  16. cborparser: Pass CborValue to operation routines.

    The `token` parameter is not sufficient since it is effectively shared
    by all `CborValue` instances.  Since `tinycbor` often uses a temporary
    `CborValue` context to perform some operation, we need to store our
    context inside that `CborValue` so that we don't pollute the global
    state of the reader.
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    3394f51 View commit details
    Browse the repository at this point in the history
  17. cborparser: Move ops outside of union

    In its place, put an arbitrary `void *` pointer for reader context.  The
    reader needs to store some context information which is specific to the
    `CborParser` instance it is serving.  Right now, `CborValue::source::token`
    serves this purpose, but the problem is that we also need a
    per-`CborValue` context and have nowhere to put it.
    
    Better to spend an extra pointer (4 bytes on 32-bit platforms) in the
    `CborParser` (which there'll be just one of), then to do it in the
    `CborValue` (which there may be several of) or to use a `CborReader`
    object that itself carries two pointers (`ops` and the context, thus
    we'd need an extra 3 pointers).
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    b7287ff View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    da482b2 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    72d59f1 View commit details
    Browse the repository at this point in the history
  20. reader unit tests: Simplify the example reader

    We simplify this reader in two ways:
    1. we remove the `consumed` member of `struct Input`, and instead use
       the `CborValue`'s `source.token` member, which we treat as an
       unsigned integer offset into our `QByteArray`.
    2. we replace the reader-specific `struct Input` with the `QByteArray`
       it was wrapping, since that's the only thing now contained in our
       `struct Input`.
    
    If a `CborValue` gets cloned, the pointer referred to by `source.token`
    similarly gets cloned, thus when we advance the pointer on the clone, it
    leaves the original alone, so computing the length of unknown-length
    entities in the CBOR document can be done safely.
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    1ef9a05 View commit details
    Browse the repository at this point in the history
  21. cborencoder: Document the write callback function.

    What is not known, is what the significance is of
    `CborEncoderAppendType`.  It basically tells the writer the nature of
    the data being written, but the default implementation ignores this and
    just blindly appends it no matter what.
    
    That raises the question of why it's important enough that the writer
    function needs to know about it.
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    b4b41d3 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    914bee9 View commit details
    Browse the repository at this point in the history
  23. examples: Add buffered reader example

    This reads a CBOR file piece-wise, seeking backward and forward through
    the file if needed.  Some seeking can be avoided by tuning the block
    size used in reads so that the read window shifts by smaller amounts.
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    34e931e View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    0c17e0f View commit details
    Browse the repository at this point in the history
  25. cbor.h, cborparser.c: Migrate parser documentation.

    Not 100% sure of the syntax for documenting struct-members outside of
    the struct as I'm too used to doing it inline, hopefully this works as
    expected. :-)
    sjlongland committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    a4a6364 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    427e009 View commit details
    Browse the repository at this point in the history