OSDN Git Service

android/pan: Generate file path in compile time
authorSzymon Janc <szymon.janc@tieto.com>
Fri, 10 Jan 2014 15:09:06 +0000 (16:09 +0100)
committerSzymon Janc <szymon.janc@tieto.com>
Mon, 13 Jan 2014 09:21:18 +0000 (10:21 +0100)
This reduce need of using snprintf function and removes need of manual
buffer size calculation.

android/pan.c

index 205da71..dfd7762 100644 (file)
@@ -50,9 +50,9 @@
 #include "bluetooth.h"
 
 #define SVC_HINT_NETWORKING 0x02
-#define BNEP_BRIDGE    "bnep"
-#define FORWARD_DELAY_PATH     "/sys/class/net/%s/bridge/forward_delay"
-#define DELAY_PATH_MAX 41
+
+#define BNEP_BRIDGE "bnep"
+#define FORWARD_DELAY_PATH "/sys/class/net/"BNEP_BRIDGE"/bridge/forward_delay"
 
 static bdaddr_t adapter_addr;
 GSList *devices = NULL;
@@ -470,11 +470,8 @@ failed:
 static int set_forward_delay(void)
 {
        int fd, ret;
-       char path[DELAY_PATH_MAX];
-
-       snprintf(path, sizeof(path), FORWARD_DELAY_PATH, BNEP_BRIDGE);
 
-       fd = open(path, O_RDWR);
+       fd = open(FORWARD_DELAY_PATH, O_RDWR);
        if (fd < 0)
                return -errno;