2015-07-28 09:59:29

by Atul Kumar Rai

[permalink] [raw]
Subject: [PATCH] tools/sdptool: Remove unnecessary typecasts

Fixed unnecessary typecasts of malloc return values.
---
tools/sdptool.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/sdptool.c b/tools/sdptool.c
index cd8bfb6..cbe8814 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -921,9 +921,9 @@ static int set_attribseq(sdp_session_t *session, uint32_t handle, uint16_t attri
}

/* Create arrays */
- dtdArray = (void **)malloc(argc * sizeof(void *));
- valueArray = (void **)malloc(argc * sizeof(void *));
- allocArray = (void **)malloc(argc * sizeof(void *));
+ dtdArray = malloc(argc * sizeof(void *));
+ valueArray = malloc(argc * sizeof(void *));
+ allocArray = malloc(argc * sizeof(void *));

if (!dtdArray || !valueArray || !allocArray) {
ret = -ENOMEM;
@@ -936,7 +936,7 @@ static int set_attribseq(sdp_session_t *session, uint32_t handle, uint16_t attri
if (!strncasecmp(argv[i], "u0x", 3)) {
/* UUID16 */
uint16_t value_int = strtoul((argv[i]) + 3, NULL, 16);
- uuid_t *value_uuid = (uuid_t *) malloc(sizeof(uuid_t));
+ uuid_t *value_uuid = malloc(sizeof(uuid_t));
if (!value_uuid) {
ret = -ENOMEM;
goto cleanup;
@@ -950,7 +950,7 @@ static int set_attribseq(sdp_session_t *session, uint32_t handle, uint16_t attri
valueArray[i] = &value_uuid->value.uuid16;
} else if (!strncasecmp(argv[i], "0x", 2)) {
/* Int */
- uint32_t *value_int = (uint32_t *) malloc(sizeof(int));
+ uint32_t *value_int = malloc(sizeof(int));
if (!value_int) {
ret = -ENOMEM;
goto cleanup;
--
2.1.4



2015-07-29 07:07:55

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] tools/sdptool: Remove unnecessary typecasts

Hi Atul,

On Tue, Jul 28, 2015, Atul Rai wrote:
> Fixed unnecessary typecasts of malloc return values.
> ---
> tools/sdptool.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)

Applied. Thanks.

Johan