OSDN Git Service

core: Fix sscanf() format specification
authorAnderson Lizardo <anderson.lizardo@openbossa.org>
Sat, 4 Jan 2014 01:55:21 +0000 (21:55 -0400)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 6 Jan 2014 19:20:58 +0000 (21:20 +0200)
Also change the type of the "handle" variable so it is compatible with
the "%hu" specification used for sprintf() on the same function.

Fixes clang error:

src/adapter.c:3550:24: error: format specifies type 'unsigned short' but
the argument has type 'int' [-Werror,-Wformat]

src/adapter.c

index 9480103..230f3ce 100644 (file)
@@ -3515,16 +3515,16 @@ static void convert_ccc_entry(char *key, char *value, void *user_data)
        char *src_addr = user_data;
        char dst_addr[18];
        char type = BDADDR_BREDR;
-       int handle, ret;
+       uint16_t handle;
+       int ret, err;
        char filename[PATH_MAX + 1];
        GKeyFile *key_file;
        struct stat st;
-       int err;
        char group[6];
        char *data;
        gsize length = 0;
 
-       ret = sscanf(key, "%17s#%hhu#%04X", dst_addr, &type, &handle);
+       ret = sscanf(key, "%17s#%hhu#%04hX", dst_addr, &type, &handle);
        if (ret < 3)
                return;
 
@@ -3565,16 +3565,16 @@ static void convert_gatt_entry(char *key, char *value, void *user_data)
        char *src_addr = user_data;
        char dst_addr[18];
        char type = BDADDR_BREDR;
-       int handle, ret;
+       uint16_t handle;
+       int ret, err;
        char filename[PATH_MAX + 1];
        GKeyFile *key_file;
        struct stat st;
-       int err;
        char group[6];
        char *data;
        gsize length = 0;
 
-       ret = sscanf(key, "%17s#%hhu#%04X", dst_addr, &type, &handle);
+       ret = sscanf(key, "%17s#%hhu#%04hX", dst_addr, &type, &handle);
        if (ret < 3)
                return;