linux: Guard against devices with no serial

Avoid warning if one of the devices doesn't have a serial:
GLib-CRITICAL **: g_ascii_strcasecmp: assertion 's2 != NULL' failed

 #1  0x00007fbe1b7c0b6d in g_log (log_domain=log_domain@entry=0x7fbe1b81300e "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7fbe1b81e9dd "%s: assertion '%s' failed") at ../../../../Projects/jhbuild/glib/glib/gmessages.c:1460
 #2  0x00007fbe1b7c1af9 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7fbe1b81300e "GLib", pretty_function=pretty_function@entry=0x7fbe1b8238c0 <__func__.24> "g_ascii_strcasecmp", expression=expression@entry=0x7fbe1b815e0e "s2 != NULL") at ../../../../Projects/jhbuild/glib/glib/gmessages.c:2930
 #3  0x00007fbe1b7dad3a in g_ascii_strcasecmp (s1=<optimized out>, s2=<optimized out>) at ../../../../Projects/jhbuild/glib/glib/gstrfuncs.c:1878
 #4  0x0000000000411025 in find_duplicate_device (backend=backend@entry=0xc3dc00, device=device@entry=0xc782e0) at ../../../../Projects/jhbuild/upower/src/linux/up-backend.c:139
This commit is contained in:
Bastien Nocera 2023-04-18 12:31:19 +02:00
parent b83b0ff568
commit 5aabeb7067

View file

@ -126,6 +126,8 @@ find_duplicate_device (UpBackend *backend,
guint i;
g_object_get (G_OBJECT (device), "serial", &serial, NULL);
if (!serial)
return NULL;
array = up_device_list_get_array (backend->priv->device_list);
for (i = 0; i < array->len; i++) {