[vlc-commits] udev: fix signed overflow

Rémi Denis-Courmont git at videolan.org
Wed Aug 20 20:15:42 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Aug 20 21:15:31 2014 +0300| [4ee185d18115325da2acc10393e353e5ee19a859] | committer: Rémi Denis-Courmont

udev: fix signed overflow

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4ee185d18115325da2acc10393e353e5ee19a859
---

 modules/services_discovery/udev.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c
index e70f5c6..a91dcf8 100644
--- a/modules/services_discovery/udev.c
+++ b/modules/services_discovery/udev.c
@@ -137,11 +137,12 @@ struct services_discovery_sys_t
 static int cmpdev (const void *a, const void *b)
 {
     const dev_t *da = a, *db = b;
-    dev_t delta = *da - *db;
 
-    if (sizeof (delta) > sizeof (int))
-        return delta ? (((signed)delta > 0) ? 1 : -1) : 0;
-    return (signed)delta;
+    if (*da > *db)
+        return +1;
+    if (*da < *db)
+        return -1;
+    return 0;
 }
 
 static void DestroyDevice (void *data)



More information about the vlc-commits mailing list