diff mbox

[libdrm] modetest: Fix to check return value of asprintf()

Message ID 1515550601-1453-1-git-send-email-sw0312.kim@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Seung-Woo Kim Jan. 10, 2018, 2:16 a.m. UTC
There is warning about ignoring return value of 'asprintf'. Fix to
check return value of asprintf().

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
---
 tests/modetest/modetest.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Comments

Eric Engestrom Jan. 22, 2018, 12:09 p.m. UTC | #1
On Wednesday, 2018-01-10 11:16:41 +0900, Seung-Woo Kim wrote:
> There is warning about ignoring return value of 'asprintf'. Fix to
> check return value of asprintf().
> 
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>

Do you have commit access or would you like me to push it for you?

> ---
>  tests/modetest/modetest.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> index 62d9332..0773bd0 100644
> --- a/tests/modetest/modetest.c
> +++ b/tests/modetest/modetest.c
> @@ -656,10 +656,13 @@ static struct resources *get_resources(struct device *dev)
>  	for (i = 0; i < res->res->count_connectors; i++) {
>  		struct connector *connector = &res->connectors[i];
>  		drmModeConnector *conn = connector->connector;
> +		int num;
>  
> -		asprintf(&connector->name, "%s-%u",
> +		num = asprintf(&connector->name, "%s-%u",
>  			 util_lookup_connector_type_name(conn->connector_type),
>  			 conn->connector_type_id);
> +		if (num < 0)
> +			goto error;
>  	}
>  
>  #define get_properties(_res, __res, type, Type)					\
> -- 
> 1.7.4.1
>
Seung-Woo Kim Jan. 23, 2018, 12:29 a.m. UTC | #2
Hello,

On 2018년 01월 22일 21:09, Eric Engestrom wrote:
> On Wednesday, 2018-01-10 11:16:41 +0900, Seung-Woo Kim wrote:
>> There is warning about ignoring return value of 'asprintf'. Fix to
>> check return value of asprintf().
>>
>> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> 
> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
> 
> Do you have commit access or would you like me to push it for you?

Thanks for reviewing. I don't have access permission, so please push it.

Best Regards,
- Seung-Woo Kim

> 
>> ---
>>  tests/modetest/modetest.c |    5 ++++-
>>  1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
>> index 62d9332..0773bd0 100644
>> --- a/tests/modetest/modetest.c
>> +++ b/tests/modetest/modetest.c
>> @@ -656,10 +656,13 @@ static struct resources *get_resources(struct device *dev)
>>  	for (i = 0; i < res->res->count_connectors; i++) {
>>  		struct connector *connector = &res->connectors[i];
>>  		drmModeConnector *conn = connector->connector;
>> +		int num;
>>  
>> -		asprintf(&connector->name, "%s-%u",
>> +		num = asprintf(&connector->name, "%s-%u",
>>  			 util_lookup_connector_type_name(conn->connector_type),
>>  			 conn->connector_type_id);
>> +		if (num < 0)
>> +			goto error;
>>  	}
>>  
>>  #define get_properties(_res, __res, type, Type)					\
>> -- 
>> 1.7.4.1
>>
> 
> 
>
diff mbox

Patch

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 62d9332..0773bd0 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -656,10 +656,13 @@  static struct resources *get_resources(struct device *dev)
 	for (i = 0; i < res->res->count_connectors; i++) {
 		struct connector *connector = &res->connectors[i];
 		drmModeConnector *conn = connector->connector;
+		int num;
 
-		asprintf(&connector->name, "%s-%u",
+		num = asprintf(&connector->name, "%s-%u",
 			 util_lookup_connector_type_name(conn->connector_type),
 			 conn->connector_type_id);
+		if (num < 0)
+			goto error;
 	}
 
 #define get_properties(_res, __res, type, Type)					\