diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2017-10-27 13:42:33 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2017-10-27 13:42:33 +0300 |
commit | 6c467e923b83b3683df7dc1eadb7c54c764c5475 (patch) | |
tree | 47851ab425f3df28f58c795989f037f23818629a /profiles | |
parent | 8a016ba9152c1bbf83bb5f10149b11af1b29ccdc (diff) | |
download | bluez-6c467e923b83b3683df7dc1eadb7c54c764c5475.tar.gz |
sixaxis: Fix compilation and various coding style issues
This fixes the following problems:
plugins/sixaxis.c:443:7: error: ‘version’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
if (!setup_device(fd, sysfs_path, name, source, vid, pid, version, type, adapter))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plugins/sixaxis.c:409:34: note: ‘version’ was declared here
uint16_t bus, vid, pid, source, version;
^~~~~~~
plugins/sixaxis.c:443:7: error: ‘source’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
if (!setup_device(fd, sysfs_path, name, source, vid, pid, version, type, adapter))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plugins/sixaxis.c:409:26: note: ‘source’ was declared here
uint16_t bus, vid, pid, source, version;
^~~~~~
cc1: all warnings being treated as errors
And many instances of code going over 80 columns.
Diffstat (limited to 'profiles')
-rw-r--r-- | profiles/input/server.c | 8 | ||||
-rw-r--r-- | profiles/input/sixaxis.h | 35 |
2 files changed, 18 insertions, 25 deletions
diff --git a/profiles/input/server.c b/profiles/input/server.c index ef428fefe..f2c8c0f70 100644 --- a/profiles/input/server.c +++ b/profiles/input/server.c @@ -124,7 +124,7 @@ static bool dev_is_sixaxis(const bdaddr_t *src, const bdaddr_t *dst) { struct btd_device *device; uint16_t vid, pid; - CablePairingType type; + const struct cable_pairing *cp; device = btd_adapter_find_device(adapter_find(src), dst, BDADDR_BREDR); if (!device) @@ -133,9 +133,9 @@ static bool dev_is_sixaxis(const bdaddr_t *src, const bdaddr_t *dst) vid = btd_device_get_vendor(device); pid = btd_device_get_product(device); - type = get_pairing_type(vid, pid, NULL, NULL, NULL); - if (type == CABLE_PAIRING_SIXAXIS || - type == CABLE_PAIRING_DS4) + cp = get_pairing(vid, pid); + if (cp && (cp->type == CABLE_PAIRING_SIXAXIS || + cp->type == CABLE_PAIRING_DS4)) return true; return false; diff --git a/profiles/input/sixaxis.h b/profiles/input/sixaxis.h index 17a7dc3f7..8e6f3cc18 100644 --- a/profiles/input/sixaxis.h +++ b/profiles/input/sixaxis.h @@ -32,20 +32,19 @@ typedef enum { CABLE_PAIRING_DS4, } CablePairingType; -static inline CablePairingType get_pairing_type(uint16_t vid, - uint16_t pid, - char **name, - uint16_t *source, - uint16_t *version) +struct cable_pairing { + const char *name; + uint16_t source; + uint16_t vid; + uint16_t pid; + uint16_t version; + CablePairingType type; +}; + +static inline const struct cable_pairing * +get_pairing(uint16_t vid, uint16_t pid) { - static const struct { - const char *name; - uint16_t source; - uint16_t vid; - uint16_t pid; - uint16_t version; - CablePairingType type; - } devices[] = { + static const struct cable_pairing devices[] = { { .name = "Sony PLAYSTATION(R)3 Controller", .source = 0x0002, @@ -87,16 +86,10 @@ static inline CablePairingType get_pairing_type(uint16_t vid, if (devices[i].pid != pid) continue; - if (name) - *name = g_strdup(devices[i].name); - if (source) - *source = devices[i].source; - if (version) - *version = devices[i].version; - return devices[i].type; + return &devices[i]; } - return CABLE_PAIRING_UNSUPPORTED; + return NULL; } #endif /* _SIXAXIS_H_ */ |