public inbox for chrome-platform@lists.linux.dev
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: trunix-creator <trunixcodes@zohomail.com>
Cc: bleung@chromium.org, groeck@chromium.org,
	chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/chrome: cros_ec_lightbar: replace sscanf with kstrtouint
Date: Mon, 23 Feb 2026 16:17:25 +0800	[thread overview]
Message-ID: <aZwNFdO8NMY4wLy9@tzungbi-laptop> (raw)
In-Reply-To: <20260208221335.16030-1-trunixcodes@zohomail.com>

On Sun, Feb 08, 2026 at 02:13:35PM -0800, trunix-creator wrote:
> Replace the use of sscanf() with kstrtouint(), which is the favored kernel
> API for parsing integers from strings. This avoids format string parsing
> overhead and improves robustness.
> 
> Signed-off-by: trunix-creator <trunixcodes@zohomail.com>

Thanks for the patch.

Before this can be considered for merging, you'll need to update the
Signed-off-by line.  The kernel community requires the use of your real
name (legal name) rather than a handle (see also "Developer's Certificate
of Origin" in Documentation/process/submitting-patches.rst).

> @@ -243,10 +243,10 @@ static ssize_t led_rgb_store(struct device *dev, struct device_attribute *attr,
>  		if (!*buf)
>  			break;
>  
> -		ret = sscanf(buf, "%i", &val[i++]);
> +		ret = kstrtouint(buf, 0, &val[i]);
>  		if (ret == 0)
>  			goto exit;

This is incorrect.  `sscanf` returns the number of items matched (e.g., 1 on
success in the case).  `kstrtouint` returns 0 on success.

> -
> +		i++;

Why it moves the increment to here?  It seems unrelated to the patch.

      reply	other threads:[~2026-02-23  8:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-08 22:13 [PATCH] platform/chrome: cros_ec_lightbar: replace sscanf with kstrtouint trunix-creator
2026-02-23  8:17 ` Tzung-Bi Shih [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aZwNFdO8NMY4wLy9@tzungbi-laptop \
    --to=tzungbi@kernel.org \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trunixcodes@zohomail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox