* [PATCH] ALSA: hda: intel-sdw-acpi: Use u8 type for link index
@ 2023-09-12 16:26 Peter Ujfalusi
2023-09-12 17:33 ` Pierre-Louis Bossart
2023-09-13 7:43 ` Takashi Iwai
0 siblings, 2 replies; 3+ messages in thread
From: Peter Ujfalusi @ 2023-09-12 16:26 UTC (permalink / raw)
To: tiwai, perex, arnd
Cc: masahiroy, linux-kernel, alsa-devel, pierre-louis.bossart
Use consistently u8 for sdw link index. The id is limited to 4, u8 is
adequate in size to store it.
This change will also fixes the following compiler warning/error (W=1):
sound/hda/intel-sdw-acpi.c: In function ‘sdw_intel_acpi_scan’:
sound/hda/intel-sdw-acpi.c:34:35: error: ‘-subproperties’ directive output may be truncated writing 14 bytes into a region of size between 7 and 17 [-Werror=format-truncation=]
34 | "mipi-sdw-link-%d-subproperties", i);
| ^~~~~~~~~~~~~~
In function ‘is_link_enabled’,
inlined from ‘sdw_intel_scan_controller’ at sound/hda/intel-sdw-acpi.c:106:8,
inlined from ‘sdw_intel_acpi_scan’ at sound/hda/intel-sdw-acpi.c:180:9:
sound/hda/intel-sdw-acpi.c:33:9: note: ‘snprintf’ output between 30 and 40 bytes into a destination of size 32
33 | snprintf(name, sizeof(name),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
34 | "mipi-sdw-link-%d-subproperties", i);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
The warnings got brought to light by a recent patch upstream:
commit 6d4ab2e97dcf ("extrawarn: enable format and stringop overflow warnings in W=1")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
sound/hda/intel-sdw-acpi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/hda/intel-sdw-acpi.c b/sound/hda/intel-sdw-acpi.c
index 5cb92f7ccbca..b57d72ea4503 100644
--- a/sound/hda/intel-sdw-acpi.c
+++ b/sound/hda/intel-sdw-acpi.c
@@ -23,7 +23,7 @@ static int ctrl_link_mask;
module_param_named(sdw_link_mask, ctrl_link_mask, int, 0444);
MODULE_PARM_DESC(sdw_link_mask, "Intel link mask (one bit per link)");
-static bool is_link_enabled(struct fwnode_handle *fw_node, int i)
+static bool is_link_enabled(struct fwnode_handle *fw_node, u8 idx)
{
struct fwnode_handle *link;
char name[32];
@@ -31,7 +31,7 @@ static bool is_link_enabled(struct fwnode_handle *fw_node, int i)
/* Find master handle */
snprintf(name, sizeof(name),
- "mipi-sdw-link-%d-subproperties", i);
+ "mipi-sdw-link-%hhu-subproperties", idx);
link = fwnode_get_named_child_node(fw_node, name);
if (!link)
@@ -51,8 +51,8 @@ static int
sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
{
struct acpi_device *adev = acpi_fetch_acpi_dev(info->handle);
- int ret, i;
- u8 count;
+ u8 count, i;
+ int ret;
if (!adev)
return -EINVAL;
--
2.42.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: hda: intel-sdw-acpi: Use u8 type for link index
2023-09-12 16:26 [PATCH] ALSA: hda: intel-sdw-acpi: Use u8 type for link index Peter Ujfalusi
@ 2023-09-12 17:33 ` Pierre-Louis Bossart
2023-09-13 7:43 ` Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2023-09-12 17:33 UTC (permalink / raw)
To: Peter Ujfalusi, tiwai, perex, arnd; +Cc: masahiroy, linux-kernel, alsa-devel
On 9/12/23 12:26, Peter Ujfalusi wrote:
> Use consistently u8 for sdw link index. The id is limited to 4, u8 is
> adequate in size to store it.
>
> This change will also fixes the following compiler warning/error (W=1):
>
> sound/hda/intel-sdw-acpi.c: In function ‘sdw_intel_acpi_scan’:
> sound/hda/intel-sdw-acpi.c:34:35: error: ‘-subproperties’ directive output may be truncated writing 14 bytes into a region of size between 7 and 17 [-Werror=format-truncation=]
> 34 | "mipi-sdw-link-%d-subproperties", i);
> | ^~~~~~~~~~~~~~
> In function ‘is_link_enabled’,
> inlined from ‘sdw_intel_scan_controller’ at sound/hda/intel-sdw-acpi.c:106:8,
> inlined from ‘sdw_intel_acpi_scan’ at sound/hda/intel-sdw-acpi.c:180:9:
> sound/hda/intel-sdw-acpi.c:33:9: note: ‘snprintf’ output between 30 and 40 bytes into a destination of size 32
> 33 | snprintf(name, sizeof(name),
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 34 | "mipi-sdw-link-%d-subproperties", i);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> The warnings got brought to light by a recent patch upstream:
> commit 6d4ab2e97dcf ("extrawarn: enable format and stringop overflow warnings in W=1")
>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
> sound/hda/intel-sdw-acpi.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/sound/hda/intel-sdw-acpi.c b/sound/hda/intel-sdw-acpi.c
> index 5cb92f7ccbca..b57d72ea4503 100644
> --- a/sound/hda/intel-sdw-acpi.c
> +++ b/sound/hda/intel-sdw-acpi.c
> @@ -23,7 +23,7 @@ static int ctrl_link_mask;
> module_param_named(sdw_link_mask, ctrl_link_mask, int, 0444);
> MODULE_PARM_DESC(sdw_link_mask, "Intel link mask (one bit per link)");
>
> -static bool is_link_enabled(struct fwnode_handle *fw_node, int i)
> +static bool is_link_enabled(struct fwnode_handle *fw_node, u8 idx)
> {
> struct fwnode_handle *link;
> char name[32];
> @@ -31,7 +31,7 @@ static bool is_link_enabled(struct fwnode_handle *fw_node, int i)
>
> /* Find master handle */
> snprintf(name, sizeof(name),
> - "mipi-sdw-link-%d-subproperties", i);
> + "mipi-sdw-link-%hhu-subproperties", idx);
>
> link = fwnode_get_named_child_node(fw_node, name);
> if (!link)
> @@ -51,8 +51,8 @@ static int
> sdw_intel_scan_controller(struct sdw_intel_acpi_info *info)
> {
> struct acpi_device *adev = acpi_fetch_acpi_dev(info->handle);
> - int ret, i;
> - u8 count;
> + u8 count, i;
> + int ret;
>
> if (!adev)
> return -EINVAL;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: hda: intel-sdw-acpi: Use u8 type for link index
2023-09-12 16:26 [PATCH] ALSA: hda: intel-sdw-acpi: Use u8 type for link index Peter Ujfalusi
2023-09-12 17:33 ` Pierre-Louis Bossart
@ 2023-09-13 7:43 ` Takashi Iwai
1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2023-09-13 7:43 UTC (permalink / raw)
To: Peter Ujfalusi
Cc: tiwai, perex, arnd, masahiroy, linux-kernel, alsa-devel,
pierre-louis.bossart
On Tue, 12 Sep 2023 18:26:17 +0200,
Peter Ujfalusi wrote:
>
> Use consistently u8 for sdw link index. The id is limited to 4, u8 is
> adequate in size to store it.
>
> This change will also fixes the following compiler warning/error (W=1):
>
> sound/hda/intel-sdw-acpi.c: In function ‘sdw_intel_acpi_scan’:
> sound/hda/intel-sdw-acpi.c:34:35: error: ‘-subproperties’ directive output may be truncated writing 14 bytes into a region of size between 7 and 17 [-Werror=format-truncation=]
> 34 | "mipi-sdw-link-%d-subproperties", i);
> | ^~~~~~~~~~~~~~
> In function ‘is_link_enabled’,
> inlined from ‘sdw_intel_scan_controller’ at sound/hda/intel-sdw-acpi.c:106:8,
> inlined from ‘sdw_intel_acpi_scan’ at sound/hda/intel-sdw-acpi.c:180:9:
> sound/hda/intel-sdw-acpi.c:33:9: note: ‘snprintf’ output between 30 and 40 bytes into a destination of size 32
> 33 | snprintf(name, sizeof(name),
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 34 | "mipi-sdw-link-%d-subproperties", i);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> The warnings got brought to light by a recent patch upstream:
> commit 6d4ab2e97dcf ("extrawarn: enable format and stringop overflow warnings in W=1")
>
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-13 7:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-12 16:26 [PATCH] ALSA: hda: intel-sdw-acpi: Use u8 type for link index Peter Ujfalusi
2023-09-12 17:33 ` Pierre-Louis Bossart
2023-09-13 7:43 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox