summaryrefslogtreecommitdiff
path: root/test/lib/abuf.c
AgeCommit message (Collapse)Author
2025-07-23abuf: Remove code that prevented test code runningAndrew Goodbody
When abuf was introduced some test code was prevented from running using a 'return 0' early in the functions. A comment said it crashed on sandbox due to a 'bug' in realloc. Some time later a bug in abuf_realloc was fixed but this test code was never enabled. Remove the early 'return 0' instances so that the test code can run. Also remove some checks that relied on the implementation details of the U-Boot memory code as these can fail on sandbox which uses system memory code. Besides that this code should be testing abuf implementation not the underlying memory code which has its own tests. Finally use a new #define for the allocs that are meant to fail to ensure they do fail on all CI platforms. This issue found by Smatch. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
2025-05-30abuf: Add a way to printf() into a bufferSimon Glass
It is useful to format a string into a buffer, with the sizing handled automatically. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-30abuf: Add a function to copy a bufferSimon Glass
It is useful to be able to copy an abuf, to allow changes while preserving the original. Add a function for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-05-30abuf: Add a helper for initing and allocating a bufferSimon Glass
This construct appears in various places. Reduce code size by adding a function for it. It inits the abuf, then allocates it to the requested size. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-22abuf: Provide a constant bufferSimon Glass
Add a new initialiser which can accept a constant pointer. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-22abuf: Provide a way to get the buffer addressSimon Glass
In many cases it is useful to get the address of a buffer, e.g. when booting from it. Add a function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-06test: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from all "test/" files and when needed add missing include files directly. Signed-off-by: Tom Rini <trini@konsulko.com>
2023-08-25abuf: Allow incrementing the sizeSimon Glass
Provide a convenience function to increment the size of the abuf. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-04-06abuf: Correct a corner case with abuf_realloc()Simon Glass
If the buffer is empty and not allocated, then abuf_realloc() tries to copy invalid data. This happens because an incorrect change to use memdup() was added after the original code was written. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-10-08Add support for an owned bufferSimon Glass
When passing a data buffer back from a function, it is not always clear who owns the buffer, i.e. who is responsible for freeing the memory used. An example of this is where multiple files are decompressed from the firmware image, using a temporary buffer for reading (since the compressed data has to live somewhere) and producing a temporary or permanent buffer with the resuilts. Where the firmware image can be memory-mapped, as on x86, the compressed data does not need to be buffered, but the complexity of having a buffer which is either allocated or not, makes the code hard to understand. Introduce a new 'abuf' which supports simple buffer operations: - encapsulating a buffer and its size - either allocated with malloc() or not - able to be reliably freed if necessary - able to be converted to an allocated buffer if needed This simple API makes it easier to deal with allocated and memory-mapped buffers. Signed-off-by: Simon Glass <sjg@chromium.org>