community/millipixels: fix build with gcc 14

This commit is contained in:
mio 2024-09-11 03:37:35 +00:00 committed by Natanael Copa
parent c775c16bdd
commit 5c0d8c4453
2 changed files with 95 additions and 1 deletions

View file

@ -0,0 +1,92 @@
Fix -Wint-conversion, -Wreturn-mismatch and -Wincompatible-pointer-type errors
with gcc 14.
Example errors:
```
../device.c: In function 'mp_device_get_num_interfaces':
/usr/include/glib-2.0/glib/gmessages.h:671:16: error: returning 'void *' from a
function with return type 'size_t' {aka 'long unsigned i nt'} makes integer
from pointer without a cast [-Wint-conversion]
671 | return (val); \
| ^
../device.c:329:9: note: in expansion of macro 'g_return_val_if_fail'
329 | g_return_val_if_fail (device, NULL);
| ^~~~~~~~~~~~~~~~~~~~
../device.c: In function 'mp_device_list_free':
/usr/include/glib-2.0/glib/gmessages.h:671:16: error: 'return' with a value, in
function returning void [-Wreturn-mismatch]
671 | return (val); \
| ^
../device.c:522:9: note: in expansion of macro 'g_return_val_if_fail'
522 | g_return_val_if_fail (device_list, NULL);
| ^~~~~~~~~~~~~~~~~~~~
../device.c:520:1: note: declared here
520 | mp_device_list_free(MPDeviceList *device_list)
| ^~~~~~~~~~~~~~~~~~~
../tools/camera_test.c: In function 'main':
../tools/camera_test.c:188:57: error: passing argument 2 of
'mp_camera_capture_image' from incompatible pointer type [-Wincompatible-pointer-types]
188 | mp_camera_capture_image(camera, on_capture, NULL);
| ^~~~~~~~~~
| |
| void (*)(MPImage, void *)
In file included from ../tools/camera_test.c:1:
../camera.h:96:64: note: expected 'enum bufstate (*)(MPImage, void *)' but
argument is of type 'void (*)(MPImage, void *)'
96 | bool mp_camera_capture_image(MPCamera *camera, enum bufstate (*callback)(MPImage, void *),
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
```
--- millipixels-v0.22.0-origin/device.c
+++ millipixels-v0.22.0/device.c
@@ -326,7 +326,7 @@
size_t
mp_device_get_num_interfaces(const MPDevice *device)
{
- g_return_val_if_fail (device, NULL);
+ g_return_val_if_fail (device, 0);
return device->num_interfaces;
}
@@ -368,7 +368,7 @@
size_t
mp_device_get_num_pads(const MPDevice *device)
{
- g_return_val_if_fail (device, NULL);
+ g_return_val_if_fail (device, 0);
return device->num_pads;
}
@@ -519,7 +519,7 @@
void
mp_device_list_free(MPDeviceList *device_list)
{
- g_return_val_if_fail (device_list, NULL);
+ g_return_if_fail (device_list);
while (device_list) {
MPDeviceList *tmp = device_list;
--- millipixels-v0.22.0-origin/tools/camera_test.c
+++ millipixels-v0.22.0/tools/camera_test.c
@@ -15,7 +15,7 @@
return t.tv_sec + t.tv_usec * 1e-6;
}
-void
+enum bufstate
on_capture(MPImage image, void *user_data)
{
size_t num_bytes =
@@ -27,6 +27,7 @@
printf(" first byte: %d.", data[0]);
free(data);
+ return true;
}
int

View file

@ -2,7 +2,7 @@
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=millipixels
pkgver=0.22.0
pkgrel=7
pkgrel=8
pkgdesc="Camera application for the Librem 5"
url="https://source.puri.sm/Librem5/millipixels"
arch="all"
@ -30,6 +30,7 @@ makedepends="
source="https://source.puri.sm/Librem5/millipixels/-/archive/v$pkgver/millipixels-v$pkgver.tar.gz
0001-Workaround-libtiff-4.5.1.patch
0002-Don-t-pass-length-parameter-for-TIFFSetField-TIFFTAG.patch
0003-gcc14.patch
"
options="!check" # There's no testsuite
builddir="$srcdir/millipixels-v$pkgver"
@ -49,4 +50,5 @@ sha512sums="
2e65125510c6e1618f680032251fc25d327e829dc2d744cdcf08b2a2d3146318847c02d5084fd95c53d49d8f3544cafe4dba303cd164f76ed45e7cb183d8945d millipixels-v0.22.0.tar.gz
cdd8b11515b8bfe8f9b017d28441b5cf9978cd7855a20255e7bb3cbbfd4789d11a081911d3ff387c642a92dfa6cc994d2b960225b938eb512d18a73d013f598e 0001-Workaround-libtiff-4.5.1.patch
5d579fda1eeeb499bf143dcd6b42b1e97b4e12cf3903059a41a1345040a60aa30d5209a4300fe93fa9d6ca726115a4b5dd03f2590366e82aa95e6607b2fb4061 0002-Don-t-pass-length-parameter-for-TIFFSetField-TIFFTAG.patch
3c8a79de43c38c1f45a79794470137f22d325f6946c3ea86a7128d00eaf635ee6b08fb0c2bb3686a68ec826eabeb6d348b64b63a50890d43c34cddc12b4b951e 0003-gcc14.patch
"