[pulseaudio-commits] r1975 - in /trunk/src: modules/oss-util.c pulse/util.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Oct 29 08:32:23 PDT 2007


Author: lennart
Date: Mon Oct 29 16:32:22 2007
New Revision: 1975

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1975&root=pulseaudio&view=rev
Log:
make use of new pa_readlink() where applicable

Modified:
    trunk/src/modules/oss-util.c
    trunk/src/pulse/util.c

Modified: trunk/src/modules/oss-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/oss-util.c?rev=1975&root=pulseaudio&r1=1974&r2=1975&view=diff
==============================================================================
--- trunk/src/modules/oss-util.c (original)
+++ trunk/src/modules/oss-util.c Mon Oct 29 16:32:22 2007
@@ -293,29 +293,39 @@
 }
 
 static int get_device_number(const char *dev) {
-    char buf[PATH_MAX];
     const char *p, *e;
-
-    if (readlink(dev, buf, sizeof(buf)) < 0) {
-        if (errno != EINVAL && errno != ENOLINK)
-            return -1;
+    char *rp = NULL;
+    int r;
+
+    if (!(p = rp = pa_readlink(dev))) {
+        if (errno != EINVAL && errno != ENOLINK) {
+            r = -1;
+            goto finish;
+        }
 
         p = dev;
-    } else
-        p = buf;
+    }
 
     if ((e = strrchr(p, '/')))
         p = e+1;
 
-    if (p == 0)
-        return 0;
+    if (p == 0) {
+        r = 0;
+        goto finish;
+    }
 
     p = strchr(p, 0) -1;
 
-    if (*p >= '0' && *p <= '9')
-        return *p - '0';
-
-    return -1;
+    if (*p >= '0' && *p <= '9') {
+        r = *p - '0';
+        goto finish;
+    }
+
+    r = -1;
+
+finish:
+    pa_xfree(rp);
+    return r;
 }
 
 int pa_oss_get_hw_description(const char *dev, char *name, size_t l) {

Modified: trunk/src/pulse/util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulse/util.c?rev=1975&root=pulseaudio&r1=1974&r2=1975&view=diff
==============================================================================
--- trunk/src/pulse/util.c (original)
+++ trunk/src/pulse/util.c Mon Oct 29 16:32:22 2007
@@ -55,6 +55,7 @@
 #include <sys/prctl.h>
 #endif
 
+#include <pulse/xmalloc.h>
 #include <pulsecore/winsock.h>
 #include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
@@ -172,13 +173,13 @@
 
 #ifdef __linux__
     {
-        int i;
-        char path[PATH_MAX];
+        char *rp;
         /* This works on Linux only */
 
-        if ((i = readlink("/proc/self/exe", path, sizeof(path)-1)) >= 0) {
-            path[i] = 0;
-            return pa_strlcpy(s, pa_path_get_filename(path), l);
+        if ((rp = pa_readlink("/proc/self/exe"))) {
+            pa_strlcpy(s, pa_path_get_filename(rp), l);
+            pa_xfree(rp);
+            return s;
         }
     }
 




More information about the pulseaudio-commits mailing list