diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-07-11 16:15:37 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2012-07-11 16:29:34 +0200 |
commit | f16520755d7e03df220a5600c30cb41a866e742b (patch) | |
tree | 8e7b11fb9adbd9eaf67034a16f649c9e256d5e76 | |
parent | 748b42ecc4fffaf158c8355107f269a355955aa8 (diff) |
usbutil: be more explicit about usbids_vendor_count usage
I introduced a regression in the previous patch, counting the
usbids_vendor_count from -1 if the previous attempt failed.
-rw-r--r-- | gtk/usbutil.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gtk/usbutil.c b/gtk/usbutil.c index 0649794..18fb14c 100644 --- a/gtk/usbutil.c +++ b/gtk/usbutil.c @@ -56,8 +56,8 @@ typedef struct _usb_vendor_info { } usb_vendor_info; static GStaticMutex usbids_load_mutex = G_STATIC_MUTEX_INIT; -static int usbids_vendor_count; -static usb_vendor_info *usbids_vendor_info; +static int usbids_vendor_count = 0; /* < 0: failed, 0: empty, > 0: loaded */ +static usb_vendor_info *usbids_vendor_info = NULL; G_GNUC_INTERNAL const char *spice_usbutil_libusb_strerror(enum libusb_error error_code) @@ -128,6 +128,7 @@ static gboolean spice_usbutil_parse_usbids(gchar *path) usb_product_info *product_info; int i, j, id, product_count = 0; + usbids_vendor_count = 0; if (!g_file_get_contents(path, &contents, NULL, NULL)) { usbids_vendor_count = -1; return FALSE; @@ -151,7 +152,7 @@ static gboolean spice_usbutil_parse_usbids(gchar *path) usbids_vendor_count++; } - usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count + 1); + usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count); product_info = g_new(usb_product_info, product_count); usbids_vendor_count = 0; @@ -220,7 +221,7 @@ static gboolean spice_usbutil_load_usbids(void) g_static_mutex_lock(&usbids_load_mutex); if (usbids_vendor_count) { - success = TRUE; + success = usbids_vendor_count > 0; goto leave; } |