[vlc-commits] dialog: fix vlc_array_remove sign (cid #1401379)

Thomas Guillem git at videolan.org
Thu Feb 23 14:46:12 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 23 14:29:25 2017 +0100| [25030bc7de9bede50bc227426788ab7b17ee4320] | committer: Thomas Guillem

dialog: fix vlc_array_remove sign (cid #1401379)

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

 src/interface/dialog.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/interface/dialog.c b/src/interface/dialog.c
index d174de1..24e1e00 100644
--- a/src/interface/dialog.c
+++ b/src/interface/dialog.c
@@ -166,17 +166,6 @@ libvlc_InternalDialogInit(libvlc_int_t *p_libvlc)
     return VLC_SUCCESS;
 }
 
-static int
-dialog_get_idx_locked(vlc_dialog_provider *p_provider, vlc_dialog_id *p_id)
-{
-    for (size_t i = 0; i < vlc_array_count(&p_provider->dialog_array); ++i)
-    {
-        if (p_id == vlc_array_item_at_index(&p_provider->dialog_array, i))
-            return i;
-    }
-    return -1;
-}
-
 static void
 dialog_cancel_locked(vlc_dialog_provider *p_provider, vlc_dialog_id *p_id)
 {
@@ -212,10 +201,9 @@ dialog_add_locked(vlc_dialog_provider *p_provider, enum dialog_type i_type)
 static void
 dialog_remove_locked(vlc_dialog_provider *p_provider, vlc_dialog_id *p_id)
 {
-    int i_array_idx = dialog_get_idx_locked(p_provider, p_id);
-    assert(i_array_idx >= 0);
-
-    vlc_array_remove(&p_provider->dialog_array, i_array_idx);
+    ssize_t i_idx = vlc_array_index_of_item(&p_provider->dialog_array, p_id);
+    if (i_idx >= 0)
+        vlc_array_remove(&p_provider->dialog_array, (size_t) i_idx);
 
     vlc_mutex_lock(&p_id->lock);
     p_id->i_refcount--;



More information about the vlc-commits mailing list