android/hal-health: Fix do not modify fd flags in non connected state
PATCH 1/1 android/hal-health: Fix do not modify fd flags in non connected state
Only on BTHL_CONN_STATE_CONNECTED state valid fd will be passed. Other states fd value is -1. Just call channel status call back.
--- android/hal-health.c | 4 ++++ 1 file changed, 4 insertions(+)
android/hal-health.c +4 -0
@@ -49,6 +49,9 @@ static void handle_channel_state(void *buf, uint16_t len, int fd)struct hal_ev_health_channel_state *ev = buf;int flags; +if (ev->channel_state !=BTHL_CONN_STATE_CONNECTED ) + goto end; + flags =fcntl (fd,F_GETFL ,0 );if (flags <0 ) {error ("health: fcntl GETFL error: %s" ,strerror (errno));
@@ -61,6 +64,7 @@ static void handle_channel_state(void *buf, uint16_t len, int fd)return ; } +end:if (cbacks->channel_state_cb) cbacks->channel_state_cb(ev->app_id, (bt_bdaddr_t *) ev->bdaddr, ev->mdep_index, ev->channel_id,
Signature · 1 line
1.9.1
Hi Ravi,
Quoted 11 lines · On Thursday 03 of July 2014 15:54:14 Ravi kumar Veeramally wrote:
Only on
BTHL_CONN_STATE_CONNECTEDstate valid fd will be passed. Other states fd value is -1. Just call channel status call back.--- android/hal-health.c | 4 ++++ 1 file changed, 4 insertions(+)android/hal-health.c +0
-0
android/hal-health.c static void handle_channel_state(void *buf, uint16_t len, int fd) · line 54
Quoted 6 lines
android/hal-health.c +3
-0@@ -49,6 +49,9 @@ static void handle_channel_state(void *buf, uint16_t len, int fd)struct hal_ev_health_channel_state *ev = buf;int flags; +if (ev->channel_state !=BTHL_CONN_STATE_CONNECTED ) + goto end; +
I'd check for fd < 0 here instead.
Quoted 12 lines
android/hal-health.c +1
-0flags =fcntl (fd,F_GETFL ,0 );if (flags <0 ) {error ("health: fcntl GETFL error: %s" ,strerror (errno));@@ -61,6 +64,7 @@ static void handle_channel_state(void *buf, uint16_t len, int fd)return ; } +end:if (cbacks->channel_state_cb) cbacks->channel_state_cb(ev->app_id, (bt_bdaddr_t *) ev->bdaddr, ev->mdep_index, ev->channel_id,
Signature · 2 lines
Best regards, Szymon Janc