2014-10-15 14:08:19

by Gowtham Anandha Babu

[permalink] [raw]
Subject: [PATCH 1/4] tools/csr_usb : Fix Resource leak: file

Handles resource leak.
---
tools/csr_usb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/csr_usb.c b/tools/csr_usb.c
index 5fb6bdc..a1d7324 100644
--- a/tools/csr_usb.c
+++ b/tools/csr_usb.c
@@ -80,9 +80,12 @@ static int read_value(const char *name, const char *attr, const char *format)
return -1;

n = fscanf(file, format, &value);
- if (n != 1)
+ if (n != 1) {
+ fclose(file);
return -1;
+ }

+ fclose(file);
return value;
}

--
1.9.1



2014-10-16 08:57:56

by Gowtham Anandha Babu

[permalink] [raw]
Subject: RE: [PATCH 1/4] tools/csr_usb : Fix Resource leak: file

Hi Luiz,

> -----Original Message-----
> From: Luiz Augusto von Dentz [mailto:[email protected]]
> Sent: Thursday, October 16, 2014 1:48 PM
> To: Gowtham Anandha Babu
> Cc: [email protected]; Dmitry Kasatkin; Bharat Panda;
> [email protected]
> Subject: Re: [PATCH 1/4] tools/csr_usb : Fix Resource leak: file
>
> Hi,
>
> On Wed, Oct 15, 2014 at 5:08 PM, Gowtham Anandha Babu
> <[email protected]> wrote:
> > Handles resource leak.
> > ---
> > tools/csr_usb.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/csr_usb.c b/tools/csr_usb.c index 5fb6bdc..a1d7324
> > 100644
> > --- a/tools/csr_usb.c
> > +++ b/tools/csr_usb.c
> > @@ -80,9 +80,12 @@ static int read_value(const char *name, const char
> *attr, const char *format)
> > return -1;
> >
> > n = fscanf(file, format, &value);
> > - if (n != 1)
> > + if (n != 1) {
> > + fclose(file);
> > return -1;
> > + }
> >
> > + fclose(file);
> > return value;
> > }
> >
> > --
> > 1.9.1
>
> Applied 1-3, but note that I did some changes in the commit message, please
> be consistent and don't include things like space before ':'
> etc, it is always a good practice got look how previous commit have been
> formatted and follow the HACKING document.
>
>
> --
> Luiz Augusto von Dentz

Sorry for the formatting errors and 50/72 format. I will follow the HACKING documents here after.
Thanks !

Regards,
Gowtham Anandha Babu


2014-10-16 08:17:41

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 1/4] tools/csr_usb : Fix Resource leak: file

Hi,

On Wed, Oct 15, 2014 at 5:08 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> Handles resource leak.
> ---
> tools/csr_usb.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/csr_usb.c b/tools/csr_usb.c
> index 5fb6bdc..a1d7324 100644
> --- a/tools/csr_usb.c
> +++ b/tools/csr_usb.c
> @@ -80,9 +80,12 @@ static int read_value(const char *name, const char *attr, const char *format)
> return -1;
>
> n = fscanf(file, format, &value);
> - if (n != 1)
> + if (n != 1) {
> + fclose(file);
> return -1;
> + }
>
> + fclose(file);
> return value;
> }
>
> --
> 1.9.1

Applied 1-3, but note that I did some changes in the commit message,
please be consistent and don't include things like space before ':'
etc, it is always a good practice got look how previous commit have
been formatted and follow the HACKING document.


--
Luiz Augusto von Dentz

2014-10-16 07:59:39

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 4/4] Fix enum coding-style

Hi,

On Wed, Oct 15, 2014 at 5:08 PM, Gowtham Anandha Babu
<[email protected]> wrote:
> Fix the enum coding-style as per the new coding style doc.

I guess the tabs confused you a little bit, the coding style is more
about having the values in case they come from a specification, the
alignment of the values don't need to be exactly as in the example in
the coding style.

> ---
> lib/uuid.h | 8 ++++----
> profiles/cups/cups.h | 16 ++++++++--------
> profiles/health/hdp_types.h | 4 ++--
> profiles/proximity/reporter.h | 6 +++---
> profiles/time/server.c | 20 ++++++++++----------
> 5 files changed, 27 insertions(+), 27 deletions(-)
>
> diff --git a/lib/uuid.h b/lib/uuid.h
> index 8303772..f05888a 100644
> --- a/lib/uuid.h
> +++ b/lib/uuid.h
> @@ -142,10 +142,10 @@ extern "C" {
>
> typedef struct {
> enum {
> - BT_UUID_UNSPEC = 0,
> - BT_UUID16 = 16,
> - BT_UUID32 = 32,
> - BT_UUID128 = 128,
> + BT_UUID_UNSPEC = 0,
> + BT_UUID16 = 16,
> + BT_UUID32 = 32,
> + BT_UUID128 = 128,
> } type;
> union {
> uint16_t u16;
> diff --git a/profiles/cups/cups.h b/profiles/cups/cups.h
> index f4e0c01..dbea1bf 100644
> --- a/profiles/cups/cups.h
> +++ b/profiles/cups/cups.h
> @@ -21,14 +21,14 @@
> *
> */
>
> -enum { /**** Backend exit codes ****/
> - CUPS_BACKEND_OK = 0, /* Job completed successfully */
> - CUPS_BACKEND_FAILED = 1, /* Job failed, use error-policy */
> - CUPS_BACKEND_AUTH_REQUIRED = 2, /* Job failed, authentication required */
> - CUPS_BACKEND_HOLD = 3, /* Job failed, hold job */
> - CUPS_BACKEND_STOP = 4, /* Job failed, stop queue */
> - CUPS_BACKEND_CANCEL = 5, /* Job failed, cancel job */
> - CUPS_BACKEND_RETRY = 6, /* Failure requires us to retry (BlueZ specific) */
> +enum { /**** Backend exit codes ****/
> + CUPS_BACKEND_OK = 0, /* Job completed successfully */
> + CUPS_BACKEND_FAILED = 1, /* Job failed, use error-policy */
> + CUPS_BACKEND_AUTH_REQUIRED = 2, /* Job failed, authentication required */
> + CUPS_BACKEND_HOLD = 3, /* Job failed, hold job */
> + CUPS_BACKEND_STOP = 4, /* Job failed, stop queue */
> + CUPS_BACKEND_CANCEL = 5, /* Job failed, cancel job */
> + CUPS_BACKEND_RETRY = 6, /* Failure requires us to retry (BlueZ specific) */
> };
>
> int sdp_search_spp(sdp_session_t *sdp, uint8_t *channel);
> diff --git a/profiles/health/hdp_types.h b/profiles/health/hdp_types.h
> index b34b5e0..92f461a 100644
> --- a/profiles/health/hdp_types.h
> +++ b/profiles/health/hdp_types.h
> @@ -49,8 +49,8 @@
> #define HDP_SOURCE_ROLE_AS_STRING "source"
>
> typedef enum {
> - HDP_SOURCE = 0x00,
> - HDP_SINK = 0x01
> + HDP_SOURCE = 0x00,
> + HDP_SINK = 0x01
> } HdpRole;
>
> typedef enum {
> diff --git a/profiles/proximity/reporter.h b/profiles/proximity/reporter.h
> index a8e1aac..243db26 100644
> --- a/profiles/proximity/reporter.h
> +++ b/profiles/proximity/reporter.h
> @@ -31,9 +31,9 @@
> #define POWER_LEVEL_CHR_UUID 0x2A07
>
> enum {
> - NO_ALERT = 0x00,
> - MILD_ALERT = 0x01,
> - HIGH_ALERT = 0x02,
> + NO_ALERT = 0x00,
> + MILD_ALERT = 0x01,
> + HIGH_ALERT = 0x02,
> };
>
> void reporter_device_remove(struct btd_service *service);
> diff --git a/profiles/time/server.c b/profiles/time/server.c
> index 1716a5e..0b6f70b 100644
> --- a/profiles/time/server.c
> +++ b/profiles/time/server.c
> @@ -55,22 +55,22 @@
> #define CT_TIME_CHR_UUID 0x2A2B
>
> enum {
> - UPDATE_RESULT_SUCCESSFUL = 0,
> - UPDATE_RESULT_CANCELED = 1,
> - UPDATE_RESULT_NO_CONN = 2,
> - UPDATE_RESULT_ERROR = 3,
> - UPDATE_RESULT_TIMEOUT = 4,
> - UPDATE_RESULT_NOT_ATTEMPTED = 5,
> + UPDATE_RESULT_SUCCESSFUL = 0,
> + UPDATE_RESULT_CANCELED = 1,
> + UPDATE_RESULT_NO_CONN = 2,
> + UPDATE_RESULT_ERROR = 3,
> + UPDATE_RESULT_TIMEOUT = 4,
> + UPDATE_RESULT_NOT_ATTEMPTED = 5,
> };
>
> enum {
> - UPDATE_STATE_IDLE = 0,
> - UPDATE_STATE_PENDING = 1,
> + UPDATE_STATE_IDLE = 0,
> + UPDATE_STATE_PENDING = 1,
> };
>
> enum {
> - GET_REFERENCE_UPDATE = 1,
> - CANCEL_REFERENCE_UPDATE = 2,
> + GET_REFERENCE_UPDATE = 1,
> + CANCEL_REFERENCE_UPDATE = 2,
> };
>
> static int encode_current_time(uint8_t value[10])
> --
> 1.9.1
>



--
Luiz Augusto von Dentz

2014-10-15 14:08:22

by Gowtham Anandha Babu

[permalink] [raw]
Subject: [PATCH 4/4] Fix enum coding-style

Fix the enum coding-style as per the new coding style doc.
---
lib/uuid.h | 8 ++++----
profiles/cups/cups.h | 16 ++++++++--------
profiles/health/hdp_types.h | 4 ++--
profiles/proximity/reporter.h | 6 +++---
profiles/time/server.c | 20 ++++++++++----------
5 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/lib/uuid.h b/lib/uuid.h
index 8303772..f05888a 100644
--- a/lib/uuid.h
+++ b/lib/uuid.h
@@ -142,10 +142,10 @@ extern "C" {

typedef struct {
enum {
- BT_UUID_UNSPEC = 0,
- BT_UUID16 = 16,
- BT_UUID32 = 32,
- BT_UUID128 = 128,
+ BT_UUID_UNSPEC = 0,
+ BT_UUID16 = 16,
+ BT_UUID32 = 32,
+ BT_UUID128 = 128,
} type;
union {
uint16_t u16;
diff --git a/profiles/cups/cups.h b/profiles/cups/cups.h
index f4e0c01..dbea1bf 100644
--- a/profiles/cups/cups.h
+++ b/profiles/cups/cups.h
@@ -21,14 +21,14 @@
*
*/

-enum { /**** Backend exit codes ****/
- CUPS_BACKEND_OK = 0, /* Job completed successfully */
- CUPS_BACKEND_FAILED = 1, /* Job failed, use error-policy */
- CUPS_BACKEND_AUTH_REQUIRED = 2, /* Job failed, authentication required */
- CUPS_BACKEND_HOLD = 3, /* Job failed, hold job */
- CUPS_BACKEND_STOP = 4, /* Job failed, stop queue */
- CUPS_BACKEND_CANCEL = 5, /* Job failed, cancel job */
- CUPS_BACKEND_RETRY = 6, /* Failure requires us to retry (BlueZ specific) */
+enum { /**** Backend exit codes ****/
+ CUPS_BACKEND_OK = 0, /* Job completed successfully */
+ CUPS_BACKEND_FAILED = 1, /* Job failed, use error-policy */
+ CUPS_BACKEND_AUTH_REQUIRED = 2, /* Job failed, authentication required */
+ CUPS_BACKEND_HOLD = 3, /* Job failed, hold job */
+ CUPS_BACKEND_STOP = 4, /* Job failed, stop queue */
+ CUPS_BACKEND_CANCEL = 5, /* Job failed, cancel job */
+ CUPS_BACKEND_RETRY = 6, /* Failure requires us to retry (BlueZ specific) */
};

int sdp_search_spp(sdp_session_t *sdp, uint8_t *channel);
diff --git a/profiles/health/hdp_types.h b/profiles/health/hdp_types.h
index b34b5e0..92f461a 100644
--- a/profiles/health/hdp_types.h
+++ b/profiles/health/hdp_types.h
@@ -49,8 +49,8 @@
#define HDP_SOURCE_ROLE_AS_STRING "source"

typedef enum {
- HDP_SOURCE = 0x00,
- HDP_SINK = 0x01
+ HDP_SOURCE = 0x00,
+ HDP_SINK = 0x01
} HdpRole;

typedef enum {
diff --git a/profiles/proximity/reporter.h b/profiles/proximity/reporter.h
index a8e1aac..243db26 100644
--- a/profiles/proximity/reporter.h
+++ b/profiles/proximity/reporter.h
@@ -31,9 +31,9 @@
#define POWER_LEVEL_CHR_UUID 0x2A07

enum {
- NO_ALERT = 0x00,
- MILD_ALERT = 0x01,
- HIGH_ALERT = 0x02,
+ NO_ALERT = 0x00,
+ MILD_ALERT = 0x01,
+ HIGH_ALERT = 0x02,
};

void reporter_device_remove(struct btd_service *service);
diff --git a/profiles/time/server.c b/profiles/time/server.c
index 1716a5e..0b6f70b 100644
--- a/profiles/time/server.c
+++ b/profiles/time/server.c
@@ -55,22 +55,22 @@
#define CT_TIME_CHR_UUID 0x2A2B

enum {
- UPDATE_RESULT_SUCCESSFUL = 0,
- UPDATE_RESULT_CANCELED = 1,
- UPDATE_RESULT_NO_CONN = 2,
- UPDATE_RESULT_ERROR = 3,
- UPDATE_RESULT_TIMEOUT = 4,
- UPDATE_RESULT_NOT_ATTEMPTED = 5,
+ UPDATE_RESULT_SUCCESSFUL = 0,
+ UPDATE_RESULT_CANCELED = 1,
+ UPDATE_RESULT_NO_CONN = 2,
+ UPDATE_RESULT_ERROR = 3,
+ UPDATE_RESULT_TIMEOUT = 4,
+ UPDATE_RESULT_NOT_ATTEMPTED = 5,
};

enum {
- UPDATE_STATE_IDLE = 0,
- UPDATE_STATE_PENDING = 1,
+ UPDATE_STATE_IDLE = 0,
+ UPDATE_STATE_PENDING = 1,
};

enum {
- GET_REFERENCE_UPDATE = 1,
- CANCEL_REFERENCE_UPDATE = 2,
+ GET_REFERENCE_UPDATE = 1,
+ CANCEL_REFERENCE_UPDATE = 2,
};

static int encode_current_time(uint8_t value[10])
--
1.9.1


2014-10-15 14:08:21

by Gowtham Anandha Babu

[permalink] [raw]
Subject: [PATCH 3/4] obexd/src/main: Fix coding style and improves readability

---
obexd/src/main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/obexd/src/main.c b/obexd/src/main.c
index 80645f8..0040c1e 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -199,7 +199,8 @@ const char *obex_option_capability(void)
return option_capability;
}

-static gboolean is_dir(const char *dir) {
+static gboolean is_dir(const char *dir)
+{
struct stat st;

if (stat(dir, &st) < 0) {
@@ -290,8 +291,9 @@ int main(int argc, char *argv[])
}

if (option_root[0] != '/') {
- char *old_root = option_root, *home = getenv("HOME");
+ const char *home = getenv("HOME");
if (home) {
+ char *old_root = option_root;
option_root = g_strdup_printf("%s/%s", home, old_root);
g_free(old_root);
}
--
1.9.1


2014-10-15 14:08:20

by Gowtham Anandha Babu

[permalink] [raw]
Subject: [PATCH 2/4] tools/hciattach : Fix syntax error

This error may not be shown during normal compilation,
because of ifdef.
---
tools/hciattach.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/hciattach.c b/tools/hciattach.c
index d8ef7e7..2ace6f5 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -128,7 +128,7 @@ int uart_speed(int s)
return B3500000;
#endif
#ifdef B3710000
- case 3710000
+ case 3710000:
return B3710000;
#endif
#ifdef B4000000
--
1.9.1