[vlc-commits] vdpau/instance: don't handle the NULL name case where it cannot happen

Steve Lhomme git at videolan.org
Wed Nov 27 12:47:00 CET 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Nov 27 11:19:03 2019 +0100| [7456c84b84645423fb951094d928c3e22cb3afd8] | committer: Steve Lhomme

vdpau/instance: don't handle the NULL name case where it cannot happen

The display_name passed to vdp_instance_create() is checked for NULL before and
we return an error if it is.

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

 modules/hw/vdpau/instance.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/modules/hw/vdpau/instance.c b/modules/hw/vdpau/instance.c
index 6194d88fbc..ddf1177276 100644
--- a/modules/hw/vdpau/instance.c
+++ b/modules/hw/vdpau/instance.c
@@ -48,7 +48,7 @@ typedef struct vdp_instance
 static VdpStatus vdp_instance_create(const char *name, int num,
                                      vdp_instance_t **pp)
 {
-    size_t namelen = (name != NULL) ? (strlen(name) + 1) : 0;
+    size_t namelen = strlen(name) + 1;
     vdp_instance_t *vi = malloc(sizeof (*vi) + namelen);
 
     if (unlikely(vi == NULL))
@@ -62,13 +62,8 @@ static VdpStatus vdp_instance_create(const char *name, int num,
     }
 
     vi->next = NULL;
-    if (name != NULL)
-    {
-        vi->name = (void *)(vi + 1);
-        memcpy(vi->name, name, namelen);
-    }
-    else
-        vi->name = NULL;
+    vi->name = (void *)(vi + 1);
+    memcpy(vi->name, name, namelen);
     if (num >= 0)
         vi->num = num;
     else
@@ -95,19 +90,9 @@ static void vdp_instance_destroy(vdp_instance_t *vi)
     free(vi);
 }
 
-/** Compares two string pointers that might be NULL */
-static int strnullcmp(const char *a, const char *b)
-{
-    if (b == NULL)
-        return a != NULL;
-    if (a == NULL)
-        return -1;
-    return strcmp(a, b);
-}
-
 static int vicmp(const char *name, int num, const vdp_instance_t *vi)
 {
-    int val = strnullcmp(name, vi->name);
+    int val = strcmp(name, vi->name);
     if (val)
         return val;
 



More information about the vlc-commits mailing list