ply-buffer: Fix unused-value warning

We currently get warnings during the build like

```
../src/libply/ply-buffer.h:60:20: warning: value computed is not
used [-Wunused-value]
60 |              !_ran && (*bytes = (char *) ply_buffer_get_bytes(buffer),
   |                    ^~
```

This commit changes the macro to use a GCC statement expression with
an if statement to work around the warning.

Closes: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/246
This commit is contained in:
Ray Strode 2024-03-07 15:09:44 -05:00
parent 18691572ee
commit c65d37e4ac

View file

@ -57,10 +57,14 @@ size_t ply_buffer_get_capacity (ply_buffer_t *buffer);
char *ply_buffer_steal_bytes (ply_buffer_t *buffer);
#define ply_buffer_borrow_bytes(buffer, bytes, size, capacity) \
for (bool _ran = false; \
!_ran && (*bytes = (char *) ply_buffer_get_bytes (buffer), \
*size = ply_buffer_get_size (buffer), \
*capacity = ply_buffer_get_capacity (buffer)), \
!_ran; \
({ \
if (!_ran) { \
*bytes = (char *) ply_buffer_get_bytes (buffer); \
*size = ply_buffer_get_size (buffer); \
*capacity = ply_buffer_get_capacity (buffer); \
} \
!_ran; \
}); \
ply_buffer_set_bytes (buffer, *bytes, *size, *capacity), \
_ran = true, \
*bytes = NULL, \