]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: fix return value when failing devnode detection of ALSA Timer character device
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 12 Jul 2025 08:08:02 +0000 (17:08 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 12 Jul 2025 12:31:59 +0000 (21:31 +0900)
When failing detecting devnode of ALSA Timer character device, the helper
function returns negative value to the callers. This is overlooked in the
previous code refactoring. It should return FALSE.

This bug brings the following compiler warnings:

../src/timer/query.c: In function ‘alsatimer_get_device_id_list’:
../src/timer/query.c:122:13: warning: ‘fd’ may be used uninitialized [-Wmaybe-uninitialized]
  122 |         if (ioctl(fd, SNDRV_TIMER_IOCTL_NEXT_DEVICE, &id) < 0) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/timer/query.c:109:9: note: ‘fd’ was declared here
  109 |     int fd;
      |         ^~

This commit fixes the bug.

Fixes: 487c67a62e99 ("timer: query: rewrite public API to return gboolean according to GNOME convention")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/query.c

index 23f724775b723a3ff4e86f26eeaf9291572e5521..2ca94379f55824d2360c1480829d3ad8262ac58c 100644 (file)
@@ -76,7 +76,7 @@ static gboolean open_fd(int *fd, GError **error)
     gboolean result;
 
     if (!alsatimer_get_devnode(&devname, error))
-        return -1;
+        return FALSE;
 
     result = TRUE;
     *fd = open(devname, O_RDONLY);