[vlc-commits] keychain: minor code de-duplication

Felix Paul Kühne git at videolan.org
Thu Apr 12 22:54:56 CEST 2018


vlc/vlc-3.0 | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Apr  8 15:09:56 2018 +0200| [c9269964825902fe4371b83087baec7474712101] | committer: David Fuhrmann

keychain: minor code de-duplication

(cherry picked from commit bce09c18a25ca4a3e0fcd20df058985cef0da0d2)
Signed-off-by: David Fuhrmann <dfuhrmann at videolan.org>

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

 modules/keystore/Makefile.am |  2 +-
 modules/keystore/keychain.m  | 20 ++++----------------
 2 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/modules/keystore/Makefile.am b/modules/keystore/Makefile.am
index b455c20e35..a1b414949e 100644
--- a/modules/keystore/Makefile.am
+++ b/modules/keystore/Makefile.am
@@ -26,7 +26,7 @@ libkwallet_plugin_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 libkwallet_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(keystoredir)'
 libkwallet_plugin_la_LIBADD = $(DBUS_LIBS) $(LIBM)
 
-libkeychain_plugin_la_SOURCES = keystore/keychain.m
+libkeychain_plugin_la_SOURCES = keystore/keychain.m keystore/list_util.c keystore/list_util.h
 libkeychain_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc
 libkeychain_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(keystoredir)' -Wl,-framework,Foundation -Wl,-framework,Security -Wl,-framework,Cocoa
 
diff --git a/modules/keystore/keychain.m b/modules/keystore/keychain.m
index 9382bd8a8b..98a888d51b 100644
--- a/modules/keystore/keychain.m
+++ b/modules/keystore/keychain.m
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * keychain.m: Darwin Keychain keystore module
  *****************************************************************************
- * Copyright © 2016 VLC authors, VideoLAN and VideoLabs
+ * Copyright © 2016, 2018 VLC authors, VideoLAN and VideoLabs
  *
  * Author: Felix Paul Kühne <fkuehne # videolabs.io>
  *
@@ -28,6 +28,8 @@
 #include <vlc_plugin.h>
 #include <vlc_keystore.h>
 
+#include "list_util.h"
+
 #import <Foundation/Foundation.h>
 #import <Security/Security.h>
 #import <Cocoa/Cocoa.h>
@@ -272,20 +274,6 @@ static void SetAttributesForQuery(const char *const ppsz_values[KEY_MAX], NSMuta
     }
 }
 
-static int CopyEntryValues(const char * ppsz_dst[KEY_MAX], const char *const ppsz_src[KEY_MAX])
-{
-    for (unsigned int i = 0; i < KEY_MAX; ++i)
-    {
-        if (ppsz_src[i])
-        {
-            ppsz_dst[i] = strdup(ppsz_src[i]);
-            if (!ppsz_dst[i])
-                return VLC_EGENERIC;
-        }
-    }
-    return VLC_SUCCESS;
-}
-
 static int Store(vlc_keystore *p_keystore,
                  const char *const ppsz_values[KEY_MAX],
                  const uint8_t *p_secret,
@@ -373,7 +361,7 @@ static unsigned int Find(vlc_keystore *p_keystore,
 
     for (NSUInteger i = 0; i < count; i++) {
         vlc_keystore_entry *p_entry = &p_entries[i];
-        if (CopyEntryValues((const char **)p_entry->ppsz_values, (const char *const*)ppsz_values) != VLC_SUCCESS) {
+        if (ks_values_copy((const char **)p_entry->ppsz_values, ppsz_values) != VLC_SUCCESS) {
             vlc_keystore_release_entries(p_entries, 1);
             return 0;
         }



More information about the vlc-commits mailing list