All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acpica: utpredef: Remove some unused functions
@ 2015-01-04 15:22 Rickard Strandqvist
  2015-01-14  8:55   ` [Devel] " Zheng, Lv
  0 siblings, 1 reply; 8+ messages in thread
From: Rickard Strandqvist @ 2015-01-04 15:22 UTC (permalink / raw)
  To: Robert Moore, Lv Zheng
  Cc: Rickard Strandqvist, Rafael J. Wysocki, Len Brown, linux-acpi,
	devel, linux-kernel

Removes some functions that are not used anywhere:
acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()

This was partially found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/acpi/acpica/acutils.h  |    9 ---
 drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
 2 files changed, 143 deletions(-)

diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 486d342..9b3fab1 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
 
 const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
 
-const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
-
-void
-acpi_ut_display_predefined_method(char *buffer,
-				  const union acpi_predefined_info *this_name,
-				  u8 multi_line);
-
 void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
 
-u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
-
 /*
  * utstate - Generic state creation/cache routines
  */
diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
index db30caf..f1ff33c 100644
--- a/drivers/acpi/acpica/utpredef.c
+++ b/drivers/acpi/acpica/utpredef.c
@@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_ut_match_resource_name
- *
- * PARAMETERS:  name                - Name to find
- *
- * RETURN:      Pointer to entry in the resource table. NULL indicates not
- *              found.
- *
- * DESCRIPTION: Check an object name against the predefined resource
- *              descriptor object list.
- *
- ******************************************************************************/
-
-const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
-{
-	const union acpi_predefined_info *this_name;
-
-	/* Quick check for a predefined name, first character must be underscore */
-
-	if (name[0] != '_') {
-		return (NULL);
-	}
-
-	/* Search info table for a predefined method/object name */
-
-	this_name = acpi_gbl_resource_names;
-	while (this_name->info.name[0]) {
-		if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
-			return (this_name);
-		}
-
-		this_name++;
-	}
-
-	return (NULL);		/* Not found */
-}
-
-/*******************************************************************************
- *
- * FUNCTION:    acpi_ut_display_predefined_method
- *
- * PARAMETERS:  buffer              - Scratch buffer for this function
- *              this_name           - Entry in the predefined method/name table
- *              multi_line          - TRUE if output should be on >1 line
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display information about a predefined method. Number and
- *              type of the input arguments, and expected type(s) for the
- *              return value, if any.
- *
- ******************************************************************************/
-
-void
-acpi_ut_display_predefined_method(char *buffer,
-				  const union acpi_predefined_info *this_name,
-				  u8 multi_line)
-{
-	u32 arg_count;
-
-	/*
-	 * Get the argument count and the string buffer
-	 * containing all argument types
-	 */
-	arg_count = acpi_ut_get_argument_types(buffer,
-					       this_name->info.argument_list);
-
-	if (multi_line) {
-		printf("      ");
-	}
-
-	printf("%4.4s    Requires %s%u argument%s",
-	       this_name->info.name,
-	       (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
-	       "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
-
-	/* Display the types for any arguments */
-
-	if (arg_count > 0) {
-		printf(" (%s)", buffer);
-	}
-
-	if (multi_line) {
-		printf("\n    ");
-	}
-
-	/* Get the return value type(s) allowed */
-
-	if (this_name->info.expected_btypes) {
-		acpi_ut_get_expected_return_types(buffer,
-						  this_name->info.
-						  expected_btypes);
-		printf("  Return value types: %s\n", buffer);
-	} else {
-		printf("  No return value\n");
-	}
-}
-
-/*******************************************************************************
- *
  * FUNCTION:    acpi_ut_get_argument_types
  *
  * PARAMETERS:  buffer              - Where to return the formatted types
@@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
 	return (arg_count);
 }
 
-/*******************************************************************************
- *
- * FUNCTION:    acpi_ut_get_resource_bit_width
- *
- * PARAMETERS:  buffer              - Where the formatted string is returned
- *              types               - Bitfield of expected data types
- *
- * RETURN:      Count of return types. Formatted string in Buffer.
- *
- * DESCRIPTION: Format the resource bit widths into a printable string.
- *
- ******************************************************************************/
-
-u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
-{
-	u32 i;
-	u16 sub_index;
-	u32 found;
-
-	*buffer = 0;
-	sub_index = 1;
-	found = 0;
-
-	for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
-		if (types & 1) {
-			strcat(buffer, &(ut_resource_type_names[i][sub_index]));
-			sub_index = 0;
-			found++;
-		}
-
-		types >>= 1;
-	}
-
-	return (found);
-}
 #endif
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH] acpica: utpredef: Remove some unused functions
@ 2015-01-14  8:55   ` Zheng, Lv
  0 siblings, 0 replies; 8+ messages in thread
From: Zheng, Lv @ 2015-01-14  8:55 UTC (permalink / raw)
  To: Rickard Strandqvist, Moore, Robert
  Cc: Wysocki, Rafael J, Len Brown, linux-acpi, devel, linux-kernel

Hi, Rickard

The functions below seem already marked by "ACPI_ASL_COMPILER || ACPI_HELP_APP".
How did you detect them as used functions?

Thanks
-Lv


> -----Original Message-----
> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
> Sent: Sunday, January 04, 2015 11:23 PM
> To: Moore, Robert; Zheng, Lv
> Cc: Rickard Strandqvist; Wysocki, Rafael J; Len Brown; linux-acpi@vger.kernel.org; devel@acpica.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] acpica: utpredef: Remove some unused functions
> 
> Removes some functions that are not used anywhere:
> acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()
> 
> This was partially found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  drivers/acpi/acpica/acutils.h  |    9 ---
>  drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
>  2 files changed, 143 deletions(-)
> 
> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
> index 486d342..9b3fab1 100644
> --- a/drivers/acpi/acpica/acutils.h
> +++ b/drivers/acpi/acpica/acutils.h
> @@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
> 
>  const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
> 
> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
> -
> -void
> -acpi_ut_display_predefined_method(char *buffer,
> -				  const union acpi_predefined_info *this_name,
> -				  u8 multi_line);
> -
>  void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
> 
> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
> -
>  /*
>   * utstate - Generic state creation/cache routines
>   */
> diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
> index db30caf..f1ff33c 100644
> --- a/drivers/acpi/acpica/utpredef.c
> +++ b/drivers/acpi/acpica/utpredef.c
> @@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
> 
>  /*******************************************************************************
>   *
> - * FUNCTION:    acpi_ut_match_resource_name
> - *
> - * PARAMETERS:  name                - Name to find
> - *
> - * RETURN:      Pointer to entry in the resource table. NULL indicates not
> - *              found.
> - *
> - * DESCRIPTION: Check an object name against the predefined resource
> - *              descriptor object list.
> - *
> - ******************************************************************************/
> -
> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
> -{
> -	const union acpi_predefined_info *this_name;
> -
> -	/* Quick check for a predefined name, first character must be underscore */
> -
> -	if (name[0] != '_') {
> -		return (NULL);
> -	}
> -
> -	/* Search info table for a predefined method/object name */
> -
> -	this_name = acpi_gbl_resource_names;
> -	while (this_name->info.name[0]) {
> -		if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
> -			return (this_name);
> -		}
> -
> -		this_name++;
> -	}
> -
> -	return (NULL);		/* Not found */
> -}
> -
> -/*******************************************************************************
> - *
> - * FUNCTION:    acpi_ut_display_predefined_method
> - *
> - * PARAMETERS:  buffer              - Scratch buffer for this function
> - *              this_name           - Entry in the predefined method/name table
> - *              multi_line          - TRUE if output should be on >1 line
> - *
> - * RETURN:      None
> - *
> - * DESCRIPTION: Display information about a predefined method. Number and
> - *              type of the input arguments, and expected type(s) for the
> - *              return value, if any.
> - *
> - ******************************************************************************/
> -
> -void
> -acpi_ut_display_predefined_method(char *buffer,
> -				  const union acpi_predefined_info *this_name,
> -				  u8 multi_line)
> -{
> -	u32 arg_count;
> -
> -	/*
> -	 * Get the argument count and the string buffer
> -	 * containing all argument types
> -	 */
> -	arg_count = acpi_ut_get_argument_types(buffer,
> -					       this_name->info.argument_list);
> -
> -	if (multi_line) {
> -		printf("      ");
> -	}
> -
> -	printf("%4.4s    Requires %s%u argument%s",
> -	       this_name->info.name,
> -	       (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
> -	       "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
> -
> -	/* Display the types for any arguments */
> -
> -	if (arg_count > 0) {
> -		printf(" (%s)", buffer);
> -	}
> -
> -	if (multi_line) {
> -		printf("\n    ");
> -	}
> -
> -	/* Get the return value type(s) allowed */
> -
> -	if (this_name->info.expected_btypes) {
> -		acpi_ut_get_expected_return_types(buffer,
> -						  this_name->info.
> -						  expected_btypes);
> -		printf("  Return value types: %s\n", buffer);
> -	} else {
> -		printf("  No return value\n");
> -	}
> -}
> -
> -/*******************************************************************************
> - *
>   * FUNCTION:    acpi_ut_get_argument_types
>   *
>   * PARAMETERS:  buffer              - Where to return the formatted types
> @@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
>  	return (arg_count);
>  }
> 
> -/*******************************************************************************
> - *
> - * FUNCTION:    acpi_ut_get_resource_bit_width
> - *
> - * PARAMETERS:  buffer              - Where the formatted string is returned
> - *              types               - Bitfield of expected data types
> - *
> - * RETURN:      Count of return types. Formatted string in Buffer.
> - *
> - * DESCRIPTION: Format the resource bit widths into a printable string.
> - *
> - ******************************************************************************/
> -
> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
> -{
> -	u32 i;
> -	u16 sub_index;
> -	u32 found;
> -
> -	*buffer = 0;
> -	sub_index = 1;
> -	found = 0;
> -
> -	for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
> -		if (types & 1) {
> -			strcat(buffer, &(ut_resource_type_names[i][sub_index]));
> -			sub_index = 0;
> -			found++;
> -		}
> -
> -		types >>= 1;
> -	}
> -
> -	return (found);
> -}
>  #endif
> --
> 1.7.10.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Devel] [PATCH] acpica: utpredef: Remove some unused functions
@ 2015-01-14  8:55   ` Zheng, Lv
  0 siblings, 0 replies; 8+ messages in thread
From: Zheng, Lv @ 2015-01-14  8:55 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 6598 bytes --]

Hi, Rickard

The functions below seem already marked by "ACPI_ASL_COMPILER || ACPI_HELP_APP".
How did you detect them as used functions?

Thanks
-Lv


> -----Original Message-----
> From: Rickard Strandqvist [mailto:rickard_strandqvist(a)spectrumdigital.se]
> Sent: Sunday, January 04, 2015 11:23 PM
> To: Moore, Robert; Zheng, Lv
> Cc: Rickard Strandqvist; Wysocki, Rafael J; Len Brown; linux-acpi(a)vger.kernel.org; devel(a)acpica.org; linux-kernel(a)vger.kernel.org
> Subject: [PATCH] acpica: utpredef: Remove some unused functions
> 
> Removes some functions that are not used anywhere:
> acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()
> 
> This was partially found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist(a)spectrumdigital.se>
> ---
>  drivers/acpi/acpica/acutils.h  |    9 ---
>  drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
>  2 files changed, 143 deletions(-)
> 
> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
> index 486d342..9b3fab1 100644
> --- a/drivers/acpi/acpica/acutils.h
> +++ b/drivers/acpi/acpica/acutils.h
> @@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
> 
>  const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
> 
> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
> -
> -void
> -acpi_ut_display_predefined_method(char *buffer,
> -				  const union acpi_predefined_info *this_name,
> -				  u8 multi_line);
> -
>  void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
> 
> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
> -
>  /*
>   * utstate - Generic state creation/cache routines
>   */
> diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
> index db30caf..f1ff33c 100644
> --- a/drivers/acpi/acpica/utpredef.c
> +++ b/drivers/acpi/acpica/utpredef.c
> @@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
> 
>  /*******************************************************************************
>   *
> - * FUNCTION:    acpi_ut_match_resource_name
> - *
> - * PARAMETERS:  name                - Name to find
> - *
> - * RETURN:      Pointer to entry in the resource table. NULL indicates not
> - *              found.
> - *
> - * DESCRIPTION: Check an object name against the predefined resource
> - *              descriptor object list.
> - *
> - ******************************************************************************/
> -
> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
> -{
> -	const union acpi_predefined_info *this_name;
> -
> -	/* Quick check for a predefined name, first character must be underscore */
> -
> -	if (name[0] != '_') {
> -		return (NULL);
> -	}
> -
> -	/* Search info table for a predefined method/object name */
> -
> -	this_name = acpi_gbl_resource_names;
> -	while (this_name->info.name[0]) {
> -		if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
> -			return (this_name);
> -		}
> -
> -		this_name++;
> -	}
> -
> -	return (NULL);		/* Not found */
> -}
> -
> -/*******************************************************************************
> - *
> - * FUNCTION:    acpi_ut_display_predefined_method
> - *
> - * PARAMETERS:  buffer              - Scratch buffer for this function
> - *              this_name           - Entry in the predefined method/name table
> - *              multi_line          - TRUE if output should be on >1 line
> - *
> - * RETURN:      None
> - *
> - * DESCRIPTION: Display information about a predefined method. Number and
> - *              type of the input arguments, and expected type(s) for the
> - *              return value, if any.
> - *
> - ******************************************************************************/
> -
> -void
> -acpi_ut_display_predefined_method(char *buffer,
> -				  const union acpi_predefined_info *this_name,
> -				  u8 multi_line)
> -{
> -	u32 arg_count;
> -
> -	/*
> -	 * Get the argument count and the string buffer
> -	 * containing all argument types
> -	 */
> -	arg_count = acpi_ut_get_argument_types(buffer,
> -					       this_name->info.argument_list);
> -
> -	if (multi_line) {
> -		printf("      ");
> -	}
> -
> -	printf("%4.4s    Requires %s%u argument%s",
> -	       this_name->info.name,
> -	       (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
> -	       "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
> -
> -	/* Display the types for any arguments */
> -
> -	if (arg_count > 0) {
> -		printf(" (%s)", buffer);
> -	}
> -
> -	if (multi_line) {
> -		printf("\n    ");
> -	}
> -
> -	/* Get the return value type(s) allowed */
> -
> -	if (this_name->info.expected_btypes) {
> -		acpi_ut_get_expected_return_types(buffer,
> -						  this_name->info.
> -						  expected_btypes);
> -		printf("  Return value types: %s\n", buffer);
> -	} else {
> -		printf("  No return value\n");
> -	}
> -}
> -
> -/*******************************************************************************
> - *
>   * FUNCTION:    acpi_ut_get_argument_types
>   *
>   * PARAMETERS:  buffer              - Where to return the formatted types
> @@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
>  	return (arg_count);
>  }
> 
> -/*******************************************************************************
> - *
> - * FUNCTION:    acpi_ut_get_resource_bit_width
> - *
> - * PARAMETERS:  buffer              - Where the formatted string is returned
> - *              types               - Bitfield of expected data types
> - *
> - * RETURN:      Count of return types. Formatted string in Buffer.
> - *
> - * DESCRIPTION: Format the resource bit widths into a printable string.
> - *
> - ******************************************************************************/
> -
> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
> -{
> -	u32 i;
> -	u16 sub_index;
> -	u32 found;
> -
> -	*buffer = 0;
> -	sub_index = 1;
> -	found = 0;
> -
> -	for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
> -		if (types & 1) {
> -			strcat(buffer, &(ut_resource_type_names[i][sub_index]));
> -			sub_index = 0;
> -			found++;
> -		}
> -
> -		types >>= 1;
> -	}
> -
> -	return (found);
> -}
>  #endif
> --
> 1.7.10.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] acpica: utpredef: Remove some unused functions
  2015-01-14  8:55   ` [Devel] " Zheng, Lv
  (?)
@ 2015-01-14 22:50   ` Rickard Strandqvist
  2015-01-15  2:00       ` Zheng, Lv
  -1 siblings, 1 reply; 8+ messages in thread
From: Rickard Strandqvist @ 2015-01-14 22:50 UTC (permalink / raw)
  To: Zheng, Lv
  Cc: Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi, devel,
	linux-kernel

2015-01-14 9:55 GMT+01:00 Zheng, Lv <lv.zheng@intel.com>:
> Hi, Rickard
>
> The functions below seem already marked by "ACPI_ASL_COMPILER || ACPI_HELP_APP".
> How did you detect them as used functions?
>
> Thanks
> -Lv
>
>
>> -----Original Message-----
>> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
>> Sent: Sunday, January 04, 2015 11:23 PM
>> To: Moore, Robert; Zheng, Lv
>> Cc: Rickard Strandqvist; Wysocki, Rafael J; Len Brown; linux-acpi@vger.kernel.org; devel@acpica.org; linux-kernel@vger.kernel.org
>> Subject: [PATCH] acpica: utpredef: Remove some unused functions
>>
>> Removes some functions that are not used anywhere:
>> acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()
>>
>> This was partially found by using a static code analysis program called cppcheck.
>>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> ---
>>  drivers/acpi/acpica/acutils.h  |    9 ---
>>  drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
>>  2 files changed, 143 deletions(-)
>>
>> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
>> index 486d342..9b3fab1 100644
>> --- a/drivers/acpi/acpica/acutils.h
>> +++ b/drivers/acpi/acpica/acutils.h
>> @@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
>>
>>  const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
>>
>> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
>> -
>> -void
>> -acpi_ut_display_predefined_method(char *buffer,
>> -                               const union acpi_predefined_info *this_name,
>> -                               u8 multi_line);
>> -
>>  void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
>>
>> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
>> -
>>  /*
>>   * utstate - Generic state creation/cache routines
>>   */
>> diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
>> index db30caf..f1ff33c 100644
>> --- a/drivers/acpi/acpica/utpredef.c
>> +++ b/drivers/acpi/acpica/utpredef.c
>> @@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
>>
>>  /*******************************************************************************
>>   *
>> - * FUNCTION:    acpi_ut_match_resource_name
>> - *
>> - * PARAMETERS:  name                - Name to find
>> - *
>> - * RETURN:      Pointer to entry in the resource table. NULL indicates not
>> - *              found.
>> - *
>> - * DESCRIPTION: Check an object name against the predefined resource
>> - *              descriptor object list.
>> - *
>> - ******************************************************************************/
>> -
>> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
>> -{
>> -     const union acpi_predefined_info *this_name;
>> -
>> -     /* Quick check for a predefined name, first character must be underscore */
>> -
>> -     if (name[0] != '_') {
>> -             return (NULL);
>> -     }
>> -
>> -     /* Search info table for a predefined method/object name */
>> -
>> -     this_name = acpi_gbl_resource_names;
>> -     while (this_name->info.name[0]) {
>> -             if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
>> -                     return (this_name);
>> -             }
>> -
>> -             this_name++;
>> -     }
>> -
>> -     return (NULL);          /* Not found */
>> -}
>> -
>> -/*******************************************************************************
>> - *
>> - * FUNCTION:    acpi_ut_display_predefined_method
>> - *
>> - * PARAMETERS:  buffer              - Scratch buffer for this function
>> - *              this_name           - Entry in the predefined method/name table
>> - *              multi_line          - TRUE if output should be on >1 line
>> - *
>> - * RETURN:      None
>> - *
>> - * DESCRIPTION: Display information about a predefined method. Number and
>> - *              type of the input arguments, and expected type(s) for the
>> - *              return value, if any.
>> - *
>> - ******************************************************************************/
>> -
>> -void
>> -acpi_ut_display_predefined_method(char *buffer,
>> -                               const union acpi_predefined_info *this_name,
>> -                               u8 multi_line)
>> -{
>> -     u32 arg_count;
>> -
>> -     /*
>> -      * Get the argument count and the string buffer
>> -      * containing all argument types
>> -      */
>> -     arg_count = acpi_ut_get_argument_types(buffer,
>> -                                            this_name->info.argument_list);
>> -
>> -     if (multi_line) {
>> -             printf("      ");
>> -     }
>> -
>> -     printf("%4.4s    Requires %s%u argument%s",
>> -            this_name->info.name,
>> -            (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
>> -            "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
>> -
>> -     /* Display the types for any arguments */
>> -
>> -     if (arg_count > 0) {
>> -             printf(" (%s)", buffer);
>> -     }
>> -
>> -     if (multi_line) {
>> -             printf("\n    ");
>> -     }
>> -
>> -     /* Get the return value type(s) allowed */
>> -
>> -     if (this_name->info.expected_btypes) {
>> -             acpi_ut_get_expected_return_types(buffer,
>> -                                               this_name->info.
>> -                                               expected_btypes);
>> -             printf("  Return value types: %s\n", buffer);
>> -     } else {
>> -             printf("  No return value\n");
>> -     }
>> -}
>> -
>> -/*******************************************************************************
>> - *
>>   * FUNCTION:    acpi_ut_get_argument_types
>>   *
>>   * PARAMETERS:  buffer              - Where to return the formatted types
>> @@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
>>       return (arg_count);
>>  }
>>
>> -/*******************************************************************************
>> - *
>> - * FUNCTION:    acpi_ut_get_resource_bit_width
>> - *
>> - * PARAMETERS:  buffer              - Where the formatted string is returned
>> - *              types               - Bitfield of expected data types
>> - *
>> - * RETURN:      Count of return types. Formatted string in Buffer.
>> - *
>> - * DESCRIPTION: Format the resource bit widths into a printable string.
>> - *
>> - ******************************************************************************/
>> -
>> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
>> -{
>> -     u32 i;
>> -     u16 sub_index;
>> -     u32 found;
>> -
>> -     *buffer = 0;
>> -     sub_index = 1;
>> -     found = 0;
>> -
>> -     for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
>> -             if (types & 1) {
>> -                     strcat(buffer, &(ut_resource_type_names[i][sub_index]));
>> -                     sub_index = 0;
>> -                     found++;
>> -             }
>> -
>> -             types >>= 1;
>> -     }
>> -
>> -     return (found);
>> -}
>>  #endif
>> --
>> 1.7.10.4
>

Hi

Cppcheck running depending on the settings all define on and off, if
that's what you wonder.

Otherwise, I did a little deeper explanation how I made did this with
cppcheck, and same scripts.
https://lkml.org/lkml/2015/1/9/531


Kind regards
Rickard Strandqvist

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] acpica: utpredef: Remove some unused functions
  2015-01-14 22:50   ` Rickard Strandqvist
  2015-01-15  2:00       ` Zheng, Lv
@ 2015-01-15  2:00       ` Zheng, Lv
  0 siblings, 0 replies; 8+ messages in thread
From: Zheng, Lv @ 2015-01-15  2:00 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi, devel,
	linux-kernel

Hi,

> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
> Sent: Thursday, January 15, 2015 6:50 AM
> 
> 2015-01-14 9:55 GMT+01:00 Zheng, Lv <lv.zheng@intel.com>:
> > Hi, Rickard
> >
> > The functions below seem already marked by "ACPI_ASL_COMPILER || ACPI_HELP_APP".
> > How did you detect them as used functions?

Do you mean something like this?

<?xml version="1.0"?>
<def>
  <define name="ACPI_ASL_COMPILER" value="0"/>
  <define name="ACPI_HELP_APP" value="0"/>
</def>

Can Cppcheck automatically remove code blocks depending on the define settings during preprocessor stage?

Thanks and best regards
-Lv

> >
> > Thanks
> > -Lv
> >
> >
> >> -----Original Message-----
> >> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
> >> Sent: Sunday, January 04, 2015 11:23 PM
> >> To: Moore, Robert; Zheng, Lv
> >> Cc: Rickard Strandqvist; Wysocki, Rafael J; Len Brown; linux-acpi@vger.kernel.org; devel@acpica.org; linux-kernel@vger.kernel.org
> >> Subject: [PATCH] acpica: utpredef: Remove some unused functions
> >>
> >> Removes some functions that are not used anywhere:
> >> acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()
> >>
> >> This was partially found by using a static code analysis program called cppcheck.
> >>
> >> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> >> ---
> >>  drivers/acpi/acpica/acutils.h  |    9 ---
> >>  drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
> >>  2 files changed, 143 deletions(-)
> >>
> >> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
> >> index 486d342..9b3fab1 100644
> >> --- a/drivers/acpi/acpica/acutils.h
> >> +++ b/drivers/acpi/acpica/acutils.h
> >> @@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
> >>
> >>  const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
> >>
> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
> >> -
> >> -void
> >> -acpi_ut_display_predefined_method(char *buffer,
> >> -                               const union acpi_predefined_info *this_name,
> >> -                               u8 multi_line);
> >> -
> >>  void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
> >>
> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
> >> -
> >>  /*
> >>   * utstate - Generic state creation/cache routines
> >>   */
> >> diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
> >> index db30caf..f1ff33c 100644
> >> --- a/drivers/acpi/acpica/utpredef.c
> >> +++ b/drivers/acpi/acpica/utpredef.c
> >> @@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
> >>
> >>  /*******************************************************************************
> >>   *
> >> - * FUNCTION:    acpi_ut_match_resource_name
> >> - *
> >> - * PARAMETERS:  name                - Name to find
> >> - *
> >> - * RETURN:      Pointer to entry in the resource table. NULL indicates not
> >> - *              found.
> >> - *
> >> - * DESCRIPTION: Check an object name against the predefined resource
> >> - *              descriptor object list.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
> >> -{
> >> -     const union acpi_predefined_info *this_name;
> >> -
> >> -     /* Quick check for a predefined name, first character must be underscore */
> >> -
> >> -     if (name[0] != '_') {
> >> -             return (NULL);
> >> -     }
> >> -
> >> -     /* Search info table for a predefined method/object name */
> >> -
> >> -     this_name = acpi_gbl_resource_names;
> >> -     while (this_name->info.name[0]) {
> >> -             if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
> >> -                     return (this_name);
> >> -             }
> >> -
> >> -             this_name++;
> >> -     }
> >> -
> >> -     return (NULL);          /* Not found */
> >> -}
> >> -
> >> -/*******************************************************************************
> >> - *
> >> - * FUNCTION:    acpi_ut_display_predefined_method
> >> - *
> >> - * PARAMETERS:  buffer              - Scratch buffer for this function
> >> - *              this_name           - Entry in the predefined method/name table
> >> - *              multi_line          - TRUE if output should be on >1 line
> >> - *
> >> - * RETURN:      None
> >> - *
> >> - * DESCRIPTION: Display information about a predefined method. Number and
> >> - *              type of the input arguments, and expected type(s) for the
> >> - *              return value, if any.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -void
> >> -acpi_ut_display_predefined_method(char *buffer,
> >> -                               const union acpi_predefined_info *this_name,
> >> -                               u8 multi_line)
> >> -{
> >> -     u32 arg_count;
> >> -
> >> -     /*
> >> -      * Get the argument count and the string buffer
> >> -      * containing all argument types
> >> -      */
> >> -     arg_count = acpi_ut_get_argument_types(buffer,
> >> -                                            this_name->info.argument_list);
> >> -
> >> -     if (multi_line) {
> >> -             printf("      ");
> >> -     }
> >> -
> >> -     printf("%4.4s    Requires %s%u argument%s",
> >> -            this_name->info.name,
> >> -            (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
> >> -            "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
> >> -
> >> -     /* Display the types for any arguments */
> >> -
> >> -     if (arg_count > 0) {
> >> -             printf(" (%s)", buffer);
> >> -     }
> >> -
> >> -     if (multi_line) {
> >> -             printf("\n    ");
> >> -     }
> >> -
> >> -     /* Get the return value type(s) allowed */
> >> -
> >> -     if (this_name->info.expected_btypes) {
> >> -             acpi_ut_get_expected_return_types(buffer,
> >> -                                               this_name->info.
> >> -                                               expected_btypes);
> >> -             printf("  Return value types: %s\n", buffer);
> >> -     } else {
> >> -             printf("  No return value\n");
> >> -     }
> >> -}
> >> -
> >> -/*******************************************************************************
> >> - *
> >>   * FUNCTION:    acpi_ut_get_argument_types
> >>   *
> >>   * PARAMETERS:  buffer              - Where to return the formatted types
> >> @@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
> >>       return (arg_count);
> >>  }
> >>
> >> -/*******************************************************************************
> >> - *
> >> - * FUNCTION:    acpi_ut_get_resource_bit_width
> >> - *
> >> - * PARAMETERS:  buffer              - Where the formatted string is returned
> >> - *              types               - Bitfield of expected data types
> >> - *
> >> - * RETURN:      Count of return types. Formatted string in Buffer.
> >> - *
> >> - * DESCRIPTION: Format the resource bit widths into a printable string.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
> >> -{
> >> -     u32 i;
> >> -     u16 sub_index;
> >> -     u32 found;
> >> -
> >> -     *buffer = 0;
> >> -     sub_index = 1;
> >> -     found = 0;
> >> -
> >> -     for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
> >> -             if (types & 1) {
> >> -                     strcat(buffer, &(ut_resource_type_names[i][sub_index]));
> >> -                     sub_index = 0;
> >> -                     found++;
> >> -             }
> >> -
> >> -             types >>= 1;
> >> -     }
> >> -
> >> -     return (found);
> >> -}
> >>  #endif
> >> --
> >> 1.7.10.4
> >
> 
> Hi
> 
> Cppcheck running depending on the settings all define on and off, if
> that's what you wonder.
> 
> Otherwise, I did a little deeper explanation how I made did this with
> cppcheck, and same scripts.
> https://lkml.org/lkml/2015/1/9/531
> 
> 
> Kind regards
> Rickard Strandqvist

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] acpica: utpredef: Remove some unused functions
@ 2015-01-15  2:00       ` Zheng, Lv
  0 siblings, 0 replies; 8+ messages in thread
From: Zheng, Lv @ 2015-01-15  2:00 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi, devel,
	linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 8518 bytes --]

Hi,

> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
> Sent: Thursday, January 15, 2015 6:50 AM
> 
> 2015-01-14 9:55 GMT+01:00 Zheng, Lv <lv.zheng@intel.com>:
> > Hi, Rickard
> >
> > The functions below seem already marked by "ACPI_ASL_COMPILER || ACPI_HELP_APP".
> > How did you detect them as used functions?

Do you mean something like this?

<?xml version="1.0"?>
<def>
  <define name="ACPI_ASL_COMPILER" value="0"/>
  <define name="ACPI_HELP_APP" value="0"/>
</def>

Can Cppcheck automatically remove code blocks depending on the define settings during preprocessor stage?

Thanks and best regards
-Lv

> >
> > Thanks
> > -Lv
> >
> >
> >> -----Original Message-----
> >> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
> >> Sent: Sunday, January 04, 2015 11:23 PM
> >> To: Moore, Robert; Zheng, Lv
> >> Cc: Rickard Strandqvist; Wysocki, Rafael J; Len Brown; linux-acpi@vger.kernel.org; devel@acpica.org; linux-kernel@vger.kernel.org
> >> Subject: [PATCH] acpica: utpredef: Remove some unused functions
> >>
> >> Removes some functions that are not used anywhere:
> >> acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()
> >>
> >> This was partially found by using a static code analysis program called cppcheck.
> >>
> >> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> >> ---
> >>  drivers/acpi/acpica/acutils.h  |    9 ---
> >>  drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
> >>  2 files changed, 143 deletions(-)
> >>
> >> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
> >> index 486d342..9b3fab1 100644
> >> --- a/drivers/acpi/acpica/acutils.h
> >> +++ b/drivers/acpi/acpica/acutils.h
> >> @@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
> >>
> >>  const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
> >>
> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
> >> -
> >> -void
> >> -acpi_ut_display_predefined_method(char *buffer,
> >> -                               const union acpi_predefined_info *this_name,
> >> -                               u8 multi_line);
> >> -
> >>  void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
> >>
> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
> >> -
> >>  /*
> >>   * utstate - Generic state creation/cache routines
> >>   */
> >> diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
> >> index db30caf..f1ff33c 100644
> >> --- a/drivers/acpi/acpica/utpredef.c
> >> +++ b/drivers/acpi/acpica/utpredef.c
> >> @@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
> >>
> >>  /*******************************************************************************
> >>   *
> >> - * FUNCTION:    acpi_ut_match_resource_name
> >> - *
> >> - * PARAMETERS:  name                - Name to find
> >> - *
> >> - * RETURN:      Pointer to entry in the resource table. NULL indicates not
> >> - *              found.
> >> - *
> >> - * DESCRIPTION: Check an object name against the predefined resource
> >> - *              descriptor object list.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
> >> -{
> >> -     const union acpi_predefined_info *this_name;
> >> -
> >> -     /* Quick check for a predefined name, first character must be underscore */
> >> -
> >> -     if (name[0] != '_') {
> >> -             return (NULL);
> >> -     }
> >> -
> >> -     /* Search info table for a predefined method/object name */
> >> -
> >> -     this_name = acpi_gbl_resource_names;
> >> -     while (this_name->info.name[0]) {
> >> -             if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
> >> -                     return (this_name);
> >> -             }
> >> -
> >> -             this_name++;
> >> -     }
> >> -
> >> -     return (NULL);          /* Not found */
> >> -}
> >> -
> >> -/*******************************************************************************
> >> - *
> >> - * FUNCTION:    acpi_ut_display_predefined_method
> >> - *
> >> - * PARAMETERS:  buffer              - Scratch buffer for this function
> >> - *              this_name           - Entry in the predefined method/name table
> >> - *              multi_line          - TRUE if output should be on >1 line
> >> - *
> >> - * RETURN:      None
> >> - *
> >> - * DESCRIPTION: Display information about a predefined method. Number and
> >> - *              type of the input arguments, and expected type(s) for the
> >> - *              return value, if any.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -void
> >> -acpi_ut_display_predefined_method(char *buffer,
> >> -                               const union acpi_predefined_info *this_name,
> >> -                               u8 multi_line)
> >> -{
> >> -     u32 arg_count;
> >> -
> >> -     /*
> >> -      * Get the argument count and the string buffer
> >> -      * containing all argument types
> >> -      */
> >> -     arg_count = acpi_ut_get_argument_types(buffer,
> >> -                                            this_name->info.argument_list);
> >> -
> >> -     if (multi_line) {
> >> -             printf("      ");
> >> -     }
> >> -
> >> -     printf("%4.4s    Requires %s%u argument%s",
> >> -            this_name->info.name,
> >> -            (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
> >> -            "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
> >> -
> >> -     /* Display the types for any arguments */
> >> -
> >> -     if (arg_count > 0) {
> >> -             printf(" (%s)", buffer);
> >> -     }
> >> -
> >> -     if (multi_line) {
> >> -             printf("\n    ");
> >> -     }
> >> -
> >> -     /* Get the return value type(s) allowed */
> >> -
> >> -     if (this_name->info.expected_btypes) {
> >> -             acpi_ut_get_expected_return_types(buffer,
> >> -                                               this_name->info.
> >> -                                               expected_btypes);
> >> -             printf("  Return value types: %s\n", buffer);
> >> -     } else {
> >> -             printf("  No return value\n");
> >> -     }
> >> -}
> >> -
> >> -/*******************************************************************************
> >> - *
> >>   * FUNCTION:    acpi_ut_get_argument_types
> >>   *
> >>   * PARAMETERS:  buffer              - Where to return the formatted types
> >> @@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
> >>       return (arg_count);
> >>  }
> >>
> >> -/*******************************************************************************
> >> - *
> >> - * FUNCTION:    acpi_ut_get_resource_bit_width
> >> - *
> >> - * PARAMETERS:  buffer              - Where the formatted string is returned
> >> - *              types               - Bitfield of expected data types
> >> - *
> >> - * RETURN:      Count of return types. Formatted string in Buffer.
> >> - *
> >> - * DESCRIPTION: Format the resource bit widths into a printable string.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
> >> -{
> >> -     u32 i;
> >> -     u16 sub_index;
> >> -     u32 found;
> >> -
> >> -     *buffer = 0;
> >> -     sub_index = 1;
> >> -     found = 0;
> >> -
> >> -     for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
> >> -             if (types & 1) {
> >> -                     strcat(buffer, &(ut_resource_type_names[i][sub_index]));
> >> -                     sub_index = 0;
> >> -                     found++;
> >> -             }
> >> -
> >> -             types >>= 1;
> >> -     }
> >> -
> >> -     return (found);
> >> -}
> >>  #endif
> >> --
> >> 1.7.10.4
> >
> 
> Hi
> 
> Cppcheck running depending on the settings all define on and off, if
> that's what you wonder.
> 
> Otherwise, I did a little deeper explanation how I made did this with
> cppcheck, and same scripts.
> https://lkml.org/lkml/2015/1/9/531
> 
> 
> Kind regards
> Rickard Strandqvist
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Devel] [PATCH] acpica: utpredef: Remove some unused functions
@ 2015-01-15  2:00       ` Zheng, Lv
  0 siblings, 0 replies; 8+ messages in thread
From: Zheng, Lv @ 2015-01-15  2:00 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 8607 bytes --]

Hi,

> From: Rickard Strandqvist [mailto:rickard_strandqvist(a)spectrumdigital.se]
> Sent: Thursday, January 15, 2015 6:50 AM
> 
> 2015-01-14 9:55 GMT+01:00 Zheng, Lv <lv.zheng(a)intel.com>:
> > Hi, Rickard
> >
> > The functions below seem already marked by "ACPI_ASL_COMPILER || ACPI_HELP_APP".
> > How did you detect them as used functions?

Do you mean something like this?

<?xml version="1.0"?>
<def>
  <define name="ACPI_ASL_COMPILER" value="0"/>
  <define name="ACPI_HELP_APP" value="0"/>
</def>

Can Cppcheck automatically remove code blocks depending on the define settings during preprocessor stage?

Thanks and best regards
-Lv

> >
> > Thanks
> > -Lv
> >
> >
> >> -----Original Message-----
> >> From: Rickard Strandqvist [mailto:rickard_strandqvist(a)spectrumdigital.se]
> >> Sent: Sunday, January 04, 2015 11:23 PM
> >> To: Moore, Robert; Zheng, Lv
> >> Cc: Rickard Strandqvist; Wysocki, Rafael J; Len Brown; linux-acpi(a)vger.kernel.org; devel(a)acpica.org; linux-kernel(a)vger.kernel.org
> >> Subject: [PATCH] acpica: utpredef: Remove some unused functions
> >>
> >> Removes some functions that are not used anywhere:
> >> acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()
> >>
> >> This was partially found by using a static code analysis program called cppcheck.
> >>
> >> Signed-off-by: Rickard Strandqvist <rickard_strandqvist(a)spectrumdigital.se>
> >> ---
> >>  drivers/acpi/acpica/acutils.h  |    9 ---
> >>  drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
> >>  2 files changed, 143 deletions(-)
> >>
> >> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
> >> index 486d342..9b3fab1 100644
> >> --- a/drivers/acpi/acpica/acutils.h
> >> +++ b/drivers/acpi/acpica/acutils.h
> >> @@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
> >>
> >>  const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
> >>
> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
> >> -
> >> -void
> >> -acpi_ut_display_predefined_method(char *buffer,
> >> -                               const union acpi_predefined_info *this_name,
> >> -                               u8 multi_line);
> >> -
> >>  void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
> >>
> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
> >> -
> >>  /*
> >>   * utstate - Generic state creation/cache routines
> >>   */
> >> diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
> >> index db30caf..f1ff33c 100644
> >> --- a/drivers/acpi/acpica/utpredef.c
> >> +++ b/drivers/acpi/acpica/utpredef.c
> >> @@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
> >>
> >>  /*******************************************************************************
> >>   *
> >> - * FUNCTION:    acpi_ut_match_resource_name
> >> - *
> >> - * PARAMETERS:  name                - Name to find
> >> - *
> >> - * RETURN:      Pointer to entry in the resource table. NULL indicates not
> >> - *              found.
> >> - *
> >> - * DESCRIPTION: Check an object name against the predefined resource
> >> - *              descriptor object list.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
> >> -{
> >> -     const union acpi_predefined_info *this_name;
> >> -
> >> -     /* Quick check for a predefined name, first character must be underscore */
> >> -
> >> -     if (name[0] != '_') {
> >> -             return (NULL);
> >> -     }
> >> -
> >> -     /* Search info table for a predefined method/object name */
> >> -
> >> -     this_name = acpi_gbl_resource_names;
> >> -     while (this_name->info.name[0]) {
> >> -             if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
> >> -                     return (this_name);
> >> -             }
> >> -
> >> -             this_name++;
> >> -     }
> >> -
> >> -     return (NULL);          /* Not found */
> >> -}
> >> -
> >> -/*******************************************************************************
> >> - *
> >> - * FUNCTION:    acpi_ut_display_predefined_method
> >> - *
> >> - * PARAMETERS:  buffer              - Scratch buffer for this function
> >> - *              this_name           - Entry in the predefined method/name table
> >> - *              multi_line          - TRUE if output should be on >1 line
> >> - *
> >> - * RETURN:      None
> >> - *
> >> - * DESCRIPTION: Display information about a predefined method. Number and
> >> - *              type of the input arguments, and expected type(s) for the
> >> - *              return value, if any.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -void
> >> -acpi_ut_display_predefined_method(char *buffer,
> >> -                               const union acpi_predefined_info *this_name,
> >> -                               u8 multi_line)
> >> -{
> >> -     u32 arg_count;
> >> -
> >> -     /*
> >> -      * Get the argument count and the string buffer
> >> -      * containing all argument types
> >> -      */
> >> -     arg_count = acpi_ut_get_argument_types(buffer,
> >> -                                            this_name->info.argument_list);
> >> -
> >> -     if (multi_line) {
> >> -             printf("      ");
> >> -     }
> >> -
> >> -     printf("%4.4s    Requires %s%u argument%s",
> >> -            this_name->info.name,
> >> -            (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
> >> -            "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
> >> -
> >> -     /* Display the types for any arguments */
> >> -
> >> -     if (arg_count > 0) {
> >> -             printf(" (%s)", buffer);
> >> -     }
> >> -
> >> -     if (multi_line) {
> >> -             printf("\n    ");
> >> -     }
> >> -
> >> -     /* Get the return value type(s) allowed */
> >> -
> >> -     if (this_name->info.expected_btypes) {
> >> -             acpi_ut_get_expected_return_types(buffer,
> >> -                                               this_name->info.
> >> -                                               expected_btypes);
> >> -             printf("  Return value types: %s\n", buffer);
> >> -     } else {
> >> -             printf("  No return value\n");
> >> -     }
> >> -}
> >> -
> >> -/*******************************************************************************
> >> - *
> >>   * FUNCTION:    acpi_ut_get_argument_types
> >>   *
> >>   * PARAMETERS:  buffer              - Where to return the formatted types
> >> @@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
> >>       return (arg_count);
> >>  }
> >>
> >> -/*******************************************************************************
> >> - *
> >> - * FUNCTION:    acpi_ut_get_resource_bit_width
> >> - *
> >> - * PARAMETERS:  buffer              - Where the formatted string is returned
> >> - *              types               - Bitfield of expected data types
> >> - *
> >> - * RETURN:      Count of return types. Formatted string in Buffer.
> >> - *
> >> - * DESCRIPTION: Format the resource bit widths into a printable string.
> >> - *
> >> - ******************************************************************************/
> >> -
> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
> >> -{
> >> -     u32 i;
> >> -     u16 sub_index;
> >> -     u32 found;
> >> -
> >> -     *buffer = 0;
> >> -     sub_index = 1;
> >> -     found = 0;
> >> -
> >> -     for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
> >> -             if (types & 1) {
> >> -                     strcat(buffer, &(ut_resource_type_names[i][sub_index]));
> >> -                     sub_index = 0;
> >> -                     found++;
> >> -             }
> >> -
> >> -             types >>= 1;
> >> -     }
> >> -
> >> -     return (found);
> >> -}
> >>  #endif
> >> --
> >> 1.7.10.4
> >
> 
> Hi
> 
> Cppcheck running depending on the settings all define on and off, if
> that's what you wonder.
> 
> Otherwise, I did a little deeper explanation how I made did this with
> cppcheck, and same scripts.
> https://lkml.org/lkml/2015/1/9/531
> 
> 
> Kind regards
> Rickard Strandqvist

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] acpica: utpredef: Remove some unused functions
  2015-01-15  2:00       ` Zheng, Lv
  (?)
  (?)
@ 2015-01-18 17:54       ` Rickard Strandqvist
  -1 siblings, 0 replies; 8+ messages in thread
From: Rickard Strandqvist @ 2015-01-18 17:54 UTC (permalink / raw)
  To: Zheng, Lv
  Cc: Moore, Robert, Wysocki, Rafael J, Len Brown, linux-acpi, devel,
	linux-kernel

2015-01-15 3:00 GMT+01:00 Zheng, Lv <lv.zheng@intel.com>:
> Hi,
>
>> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
>> Sent: Thursday, January 15, 2015 6:50 AM
>>
>> 2015-01-14 9:55 GMT+01:00 Zheng, Lv <lv.zheng@intel.com>:
>> > Hi, Rickard
>> >
>> > The functions below seem already marked by "ACPI_ASL_COMPILER || ACPI_HELP_APP".
>> > How did you detect them as used functions?
>
> Do you mean something like this?
>
> <?xml version="1.0"?>
> <def>
>   <define name="ACPI_ASL_COMPILER" value="0"/>
>   <define name="ACPI_HELP_APP" value="0"/>
> </def>
>
> Can Cppcheck automatically remove code blocks depending on the define settings during preprocessor stage?
>
> Thanks and best regards
> -Lv
>
>> >
>> > Thanks
>> > -Lv
>> >
>> >
>> >> -----Original Message-----
>> >> From: Rickard Strandqvist [mailto:rickard_strandqvist@spectrumdigital.se]
>> >> Sent: Sunday, January 04, 2015 11:23 PM
>> >> To: Moore, Robert; Zheng, Lv
>> >> Cc: Rickard Strandqvist; Wysocki, Rafael J; Len Brown; linux-acpi@vger.kernel.org; devel@acpica.org; linux-kernel@vger.kernel.org
>> >> Subject: [PATCH] acpica: utpredef: Remove some unused functions
>> >>
>> >> Removes some functions that are not used anywhere:
>> >> acpi_ut_get_resource_bit_width() acpi_ut_display_predefined_method() acpi_ut_match_resource_name()
>> >>
>> >> This was partially found by using a static code analysis program called cppcheck.
>> >>
>> >> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> >> ---
>> >>  drivers/acpi/acpica/acutils.h  |    9 ---
>> >>  drivers/acpi/acpica/utpredef.c |  134 ----------------------------------------
>> >>  2 files changed, 143 deletions(-)
>> >>
>> >> diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
>> >> index 486d342..9b3fab1 100644
>> >> --- a/drivers/acpi/acpica/acutils.h
>> >> +++ b/drivers/acpi/acpica/acutils.h
>> >> @@ -502,17 +502,8 @@ const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
>> >>
>> >>  const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name);
>> >>
>> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name);
>> >> -
>> >> -void
>> >> -acpi_ut_display_predefined_method(char *buffer,
>> >> -                               const union acpi_predefined_info *this_name,
>> >> -                               u8 multi_line);
>> >> -
>> >>  void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes);
>> >>
>> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types);
>> >> -
>> >>  /*
>> >>   * utstate - Generic state creation/cache routines
>> >>   */
>> >> diff --git a/drivers/acpi/acpica/utpredef.c b/drivers/acpi/acpica/utpredef.c
>> >> index db30caf..f1ff33c 100644
>> >> --- a/drivers/acpi/acpica/utpredef.c
>> >> +++ b/drivers/acpi/acpica/utpredef.c
>> >> @@ -209,105 +209,6 @@ static const char *ut_resource_type_names[] = {
>> >>
>> >>  /*******************************************************************************
>> >>   *
>> >> - * FUNCTION:    acpi_ut_match_resource_name
>> >> - *
>> >> - * PARAMETERS:  name                - Name to find
>> >> - *
>> >> - * RETURN:      Pointer to entry in the resource table. NULL indicates not
>> >> - *              found.
>> >> - *
>> >> - * DESCRIPTION: Check an object name against the predefined resource
>> >> - *              descriptor object list.
>> >> - *
>> >> - ******************************************************************************/
>> >> -
>> >> -const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
>> >> -{
>> >> -     const union acpi_predefined_info *this_name;
>> >> -
>> >> -     /* Quick check for a predefined name, first character must be underscore */
>> >> -
>> >> -     if (name[0] != '_') {
>> >> -             return (NULL);
>> >> -     }
>> >> -
>> >> -     /* Search info table for a predefined method/object name */
>> >> -
>> >> -     this_name = acpi_gbl_resource_names;
>> >> -     while (this_name->info.name[0]) {
>> >> -             if (ACPI_COMPARE_NAME(name, this_name->info.name)) {
>> >> -                     return (this_name);
>> >> -             }
>> >> -
>> >> -             this_name++;
>> >> -     }
>> >> -
>> >> -     return (NULL);          /* Not found */
>> >> -}
>> >> -
>> >> -/*******************************************************************************
>> >> - *
>> >> - * FUNCTION:    acpi_ut_display_predefined_method
>> >> - *
>> >> - * PARAMETERS:  buffer              - Scratch buffer for this function
>> >> - *              this_name           - Entry in the predefined method/name table
>> >> - *              multi_line          - TRUE if output should be on >1 line
>> >> - *
>> >> - * RETURN:      None
>> >> - *
>> >> - * DESCRIPTION: Display information about a predefined method. Number and
>> >> - *              type of the input arguments, and expected type(s) for the
>> >> - *              return value, if any.
>> >> - *
>> >> - ******************************************************************************/
>> >> -
>> >> -void
>> >> -acpi_ut_display_predefined_method(char *buffer,
>> >> -                               const union acpi_predefined_info *this_name,
>> >> -                               u8 multi_line)
>> >> -{
>> >> -     u32 arg_count;
>> >> -
>> >> -     /*
>> >> -      * Get the argument count and the string buffer
>> >> -      * containing all argument types
>> >> -      */
>> >> -     arg_count = acpi_ut_get_argument_types(buffer,
>> >> -                                            this_name->info.argument_list);
>> >> -
>> >> -     if (multi_line) {
>> >> -             printf("      ");
>> >> -     }
>> >> -
>> >> -     printf("%4.4s    Requires %s%u argument%s",
>> >> -            this_name->info.name,
>> >> -            (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
>> >> -            "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
>> >> -
>> >> -     /* Display the types for any arguments */
>> >> -
>> >> -     if (arg_count > 0) {
>> >> -             printf(" (%s)", buffer);
>> >> -     }
>> >> -
>> >> -     if (multi_line) {
>> >> -             printf("\n    ");
>> >> -     }
>> >> -
>> >> -     /* Get the return value type(s) allowed */
>> >> -
>> >> -     if (this_name->info.expected_btypes) {
>> >> -             acpi_ut_get_expected_return_types(buffer,
>> >> -                                               this_name->info.
>> >> -                                               expected_btypes);
>> >> -             printf("  Return value types: %s\n", buffer);
>> >> -     } else {
>> >> -             printf("  No return value\n");
>> >> -     }
>> >> -}
>> >> -
>> >> -/*******************************************************************************
>> >> - *
>> >>   * FUNCTION:    acpi_ut_get_argument_types
>> >>   *
>> >>   * PARAMETERS:  buffer              - Where to return the formatted types
>> >> @@ -361,39 +262,4 @@ static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
>> >>       return (arg_count);
>> >>  }
>> >>
>> >> -/*******************************************************************************
>> >> - *
>> >> - * FUNCTION:    acpi_ut_get_resource_bit_width
>> >> - *
>> >> - * PARAMETERS:  buffer              - Where the formatted string is returned
>> >> - *              types               - Bitfield of expected data types
>> >> - *
>> >> - * RETURN:      Count of return types. Formatted string in Buffer.
>> >> - *
>> >> - * DESCRIPTION: Format the resource bit widths into a printable string.
>> >> - *
>> >> - ******************************************************************************/
>> >> -
>> >> -u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
>> >> -{
>> >> -     u32 i;
>> >> -     u16 sub_index;
>> >> -     u32 found;
>> >> -
>> >> -     *buffer = 0;
>> >> -     sub_index = 1;
>> >> -     found = 0;
>> >> -
>> >> -     for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
>> >> -             if (types & 1) {
>> >> -                     strcat(buffer, &(ut_resource_type_names[i][sub_index]));
>> >> -                     sub_index = 0;
>> >> -                     found++;
>> >> -             }
>> >> -
>> >> -             types >>= 1;
>> >> -     }
>> >> -
>> >> -     return (found);
>> >> -}
>> >>  #endif
>> >> --
>> >> 1.7.10.4
>> >
>>
>> Hi
>>
>> Cppcheck running depending on the settings all define on and off, if
>> that's what you wonder.
>>
>> Otherwise, I did a little deeper explanation how I made did this with
>> cppcheck, and same scripts.
>> https://lkml.org/lkml/2015/1/9/531
>>
>>
>> Kind regards
>> Rickard Strandqvist


Hi Lv

Interesting question, myself have not had reason to investigate it.

By default cppcheck will check all preprocessor configurations.
I'm not sure if you can do so via an xml file, but you can give
arguments to cppcheck define and unset with the -D and -U
Ex:
check all configurations when macro A is defined
cppcheck -DA --force file.c

Se the manual for cppcheck here see: "Chapter 3. Preprocessor configurations"

http://cppcheck.sourceforge.net/manual.pdf


Kind regards
Rickard Strandqvist

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-01-18 17:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-04 15:22 [PATCH] acpica: utpredef: Remove some unused functions Rickard Strandqvist
2015-01-14  8:55 ` Zheng, Lv
2015-01-14  8:55   ` [Devel] " Zheng, Lv
2015-01-14 22:50   ` Rickard Strandqvist
2015-01-15  2:00     ` Zheng, Lv
2015-01-15  2:00       ` [Devel] " Zheng, Lv
2015-01-15  2:00       ` Zheng, Lv
2015-01-18 17:54       ` Rickard Strandqvist

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.