diff options
author | Sam James <sam@gentoo.org> | 2023-11-07 22:30:51 +0000 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-11-07 22:31:05 +0000 |
commit | 08115a4217e0cb783ab391c2d98edcc3f14d51b6 (patch) | |
tree | 352b51b3a7596244ab46c4661256d0bfee5950ac | |
parent | 47a1c3d330cc7ea6ba2fa96eb288f4b2291d011c (diff) |
pixman-bits-image: fix -Walloc-size
GCC 14 introduces a new -Walloc-size included in -Wextra which gives (when forced
to be an error):
```
../pixman/pixman-bits-image.c: In function ‘create_bits’:
../pixman/pixman-bits-image.c:1273:16: error: allocation of insufficient size ‘1’ for type ‘uint32_t’ {aka ‘unsigned int’} with size ‘4’ [-Werror=alloc-size]
1273 | return calloc (buf_size, 1);
| ^~~~~~~~~~~~~~~~~~~~
```
The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```
So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 element of size `buf_size`. GCC then sees we're not
doing anything wrong.
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | pixman/pixman-bits-image.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/pixman/pixman-bits-image.c b/pixman/pixman-bits-image.c index 1698d73..20353cf 100644 --- a/pixman/pixman-bits-image.c +++ b/pixman/pixman-bits-image.c @@ -1270,7 +1270,7 @@ create_bits (pixman_format_code_t format, *rowstride_bytes = stride; if (clear) - return calloc (buf_size, 1); + return calloc (1, buf_size); else return malloc (buf_size); } |