All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] accel/habanalabs: Add missing const
@ 2026-11-25 17:39 Alejandro Colomar
  2026-11-25 17:47 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Alejandro Colomar @ 2026-11-25 17:39 UTC (permalink / raw)
  To: Koby Elbaz, Konstantin Sinyuk, dri-devel; +Cc: Alejandro Colomar

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

These pointers are derived from other const pointers.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
---

Hi,

These were found while changing some <linux/string.h> APIs to preserve
the const qualifier in the return type.


Have a lovely night!
Alex

 drivers/accel/habanalabs/common/firmware_if.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/accel/habanalabs/common/firmware_if.c b/drivers/accel/habanalabs/common/firmware_if.c
index c8f1e252241d..8ae1e0e4dae1 100644
--- a/drivers/accel/habanalabs/common/firmware_if.c
+++ b/drivers/accel/habanalabs/common/firmware_if.c
@@ -68,7 +68,8 @@ int hl_fw_version_cmp(struct hl_device *hdev, u32 major, u32 minor, u32 subminor
 
 static char *extract_fw_ver_from_str(const char *fw_str)
 {
-	char *str, *fw_ver, *whitespace;
+	char *fw_ver;
+	const char *str, *whitespace;
 	u32 ver_offset;
 
 	fw_ver = kmalloc(VERSION_MAX_LEN, GFP_KERNEL);
@@ -105,7 +106,7 @@ static char *extract_fw_ver_from_str(const char *fw_str)
  *
  * Return: Upon success, return a pointer to the given_char in the string. Upon failure, return NULL
  */
-static char *extract_u32_until_given_char(char *str, u32 *ver_num, char given_char)
+static const char *extract_u32_until_given_char(const char *str, u32 *ver_num, char given_char)
 {
 	char num_str[8] = {}, *ch;
 
@@ -136,7 +137,7 @@ static char *extract_u32_until_given_char(char *str, u32 *ver_num, char given_ch
  */
 static int hl_get_sw_major_minor_subminor(struct hl_device *hdev, const char *fw_str)
 {
-	char *end, *start;
+	const char *end, *start;
 
 	end = strnstr(fw_str, "-rc-", VERSION_MAX_LEN);
 	if (end == fw_str)
@@ -194,7 +195,7 @@ static int hl_get_sw_major_minor_subminor(struct hl_device *hdev, const char *fw
  *
  * Return: 0 on success, negative error code for failure.
  */
-static int hl_get_preboot_major_minor(struct hl_device *hdev, char *preboot_ver)
+static int hl_get_preboot_major_minor(struct hl_device *hdev, const char *preboot_ver)
 {
 	preboot_ver = extract_u32_until_given_char(preboot_ver, &hdev->fw_inner_major_ver, '.');
 	if (!preboot_ver) {
-- 
2.55.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] accel/habanalabs: Add missing const
  2026-11-25 17:39 [PATCH] accel/habanalabs: Add missing const Alejandro Colomar
@ 2026-11-25 17:47 ` sashiko-bot
  2026-11-25 18:13   ` Alejandro Colomar
  0 siblings, 1 reply; 3+ messages in thread
From: sashiko-bot @ 2026-11-25 17:47 UTC (permalink / raw)
  To: Alejandro Colomar, dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] accel/habanalabs: missing const on ch in
  extract_u32_until_given_char()
--

commit fd205b9061bdb9d6cd798164f715276c74b998b2
Author: Alejandro Colomar <alx@kernel.org>

accel/habanalabs: Add missing const

This commit adds const qualifiers to firmware version string pointers
derived from const char * inputs in firmware_if.c.

> diff --git a/drivers/accel/habanalabs/common/firmware_if.c b/drivers/accel/habanalabs/common/firmware_if.c
> index 29f5652d60433..69d39a8789d4c 100644
> --- a/drivers/accel/habanalabs/common/firmware_if.c
> +++ b/drivers/accel/habanalabs/common/firmware_if.c
[ ... ]
> @@ -112,7 +113,7 @@ static char *extract_fw_ver_from_str(const char *fw_str)
>   *
>   * Return: Upon success, return a pointer to the given_char in the string. Upon failure, return NULL
>   */
> -static char *extract_u32_until_given_char(char *str, u32 *ver_num, char given_char)
> +static const char *extract_u32_until_given_char(const char *str, u32 *ver_num, char given_char)
>  {
>  	char num_str[8] = {}, *ch;

[Severity: Low]
Should ch also be declared as const char *?  It receives the result of
strchrnul(str, given_char) on the now-const str and is returned directly,
so leaving it non-const will trigger a -Wdiscarded-qualifiers warning once
strchrnul() preserves const.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/a284672589d00aa039a8c53ccf43bd1a5fd8e8f9.1795628340.git.alx@kernel.org?part=1

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

* Re: [PATCH] accel/habanalabs: Add missing const
  2026-11-25 17:47 ` sashiko-bot
@ 2026-11-25 18:13   ` Alejandro Colomar
  0 siblings, 0 replies; 3+ messages in thread
From: Alejandro Colomar @ 2026-11-25 18:13 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: dri-devel

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

> Date: 2026-11-25 17:47:57+0000
> From: sashiko-bot@kernel.org
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] accel/habanalabs: missing const on ch in
>   extract_u32_until_given_char()
> --
> 
> commit fd205b9061bdb9d6cd798164f715276c74b998b2
> Author: Alejandro Colomar <alx@kernel.org>
> 
> accel/habanalabs: Add missing const
> 
> This commit adds const qualifiers to firmware version string pointers
> derived from const char * inputs in firmware_if.c.
> 
> > diff --git a/drivers/accel/habanalabs/common/firmware_if.c b/drivers/accel/habanalabs/common/firmware_if.c
> > index 29f5652d60433..69d39a8789d4c 100644
> > --- a/drivers/accel/habanalabs/common/firmware_if.c
> > +++ b/drivers/accel/habanalabs/common/firmware_if.c
> [ ... ]
> > @@ -112,7 +113,7 @@ static char *extract_fw_ver_from_str(const char *fw_str)
> >   *
> >   * Return: Upon success, return a pointer to the given_char in the string. Upon failure, return NULL
> >   */
> > -static char *extract_u32_until_given_char(char *str, u32 *ver_num, char given_char)
> > +static const char *extract_u32_until_given_char(const char *str, u32 *ver_num, char given_char)
> >  {
> >  	char num_str[8] = {}, *ch;
> 
> [Severity: Low]
> Should ch also be declared as const char *?  It receives the result of
> strchrnul(str, given_char) on the now-const str and is returned directly,
> so leaving it non-const will trigger a -Wdiscarded-qualifiers warning once
> strchrnul() preserves const.

I haven't yet changed strchrnul(3) to preserve const, because I need to
discuss some stuff with GCC maintainers (it has some issues with the
existing builtins in GCC), so I'll do that in a future patch.

For now, let's ignore that.

> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/a284672589d00aa039a8c53ccf43bd1a5fd8e8f9.1795628340.git.alx@kernel.org?part=1

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2026-11-25 18:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 17:39 [PATCH] accel/habanalabs: Add missing const Alejandro Colomar
2026-11-25 17:47 ` sashiko-bot
2026-11-25 18:13   ` Alejandro Colomar

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.