All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paul Louvel" <paul.louvel@bootlin.com>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v5 2/5] watchdog: w83627hf_wdt: Convert to platform driver model
Date: Tue, 20 Oct 2026 08:59:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-178668@kernel.org> (raw)
In-Reply-To: <20261020-w83627hf_wdt-improvements-v5-2-90b226684fc7@bootlin.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] watchdog: w83627hf_wdt: format truncation warning in wdt_probe()
--

commit a96b55145c68318e10b7deaae2c19abda6f0df61
Author: Paul Louvel <paul.louvel@bootlin.com>

watchdog: w83627hf_wdt: Convert to platform driver model

This commit converts the w83627hf_wdt driver to use the platform driver
model with device-managed resources and adds error logging during probe.

> diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
> index fa1808a4c6c88..96ea278e45c4e 100644
> --- a/drivers/watchdog/w83627hf_wdt.c
> +++ b/drivers/watchdog/w83627hf_wdt.c
[ ... ]
> @@ -462,6 +456,58 @@ static int wdt_find(int addr)
>  	return ret;
>  }
>  
> +static int wdt_probe(struct platform_device *pdev)
> +{
> +	const struct platform_device_id *id = platform_get_device_id(pdev);
> +	struct device *dev = &pdev->dev;
> +	struct watchdog_device *wdd;
> +	struct w83627hf_data *data;
> +	enum chips chip;
> +	int ret;
> +
> +	dev_info(dev, "WDT driver initialising\n");
> +
> +	if (!id)
> +		return dev_err_probe(dev, -EINVAL, "failed to get chip id\n");
> +
> +	chip = id->driver_data;
> +
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	data->info.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE;
> +	snprintf(data->info.identity, sizeof(data->info.identity), "%s Watchdog",
> +		 id->name);

[Severity: Low]
Does this unchecked snprintf() call in wdt_probe() trigger a
-Wformat-truncation warning when building with GCC under W=1?

In include/linux/mod_devicetable.h, id->name is a 24-byte array:

    #define PLATFORM_NAME_SIZE	24
    ...
    struct platform_device_id {
    	char name[PLATFORM_NAME_SIZE];
    	kernel_ulong_t driver_data;
    };

And in include/uapi/linux/watchdog.h, data->info.identity is 32 bytes:

    struct watchdog_info {
    	__u32 options;		/* Options the card/driver supports */
    	__u32 firmware_version;	/* Firmware version of the card */
    	__u8  identity[32];	/* Identity of the board */
    };

Because id is retrieved via platform_get_device_id(pdev), GCC cannot narrow
id->name to the string literals in wdt_ids[] and sees up to 23 characters
plus " Watchdog" (33 bytes including NUL) being formatted into the 32-byte
data->info.identity buffer.

Would it be better to use scnprintf() here instead of snprintf() to avoid
the truncation warning?

[ ... ]

$>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261020-w83627hf_wdt-improvements-v5-0-90b226684fc7@bootlin.com?part=2

  reply	other threads:[~2026-10-20  8:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  8:11 [PATCH v5 0/5] watchdog: w83627hf_wdt: Convert driver to the driver model and add minute support Paul Louvel
2026-10-20  8:11 ` [PATCH v5 1/5] watchdog: w83627hf_wdt: Replace magic numbers with descriptive macros Paul Louvel
2026-10-20  8:11 ` [PATCH v5 2/5] watchdog: w83627hf_wdt: Convert to platform driver model Paul Louvel
2026-10-20  8:59   ` sashiko-bot [this message]
2026-10-20 13:29   ` Tzung-Bi Shih
2026-10-20  8:11 ` [PATCH v5 3/5] watchdog: w83627hf_wdt: Move register offsets into driver data Paul Louvel
2026-10-20 13:44   ` Tzung-Bi Shih
2026-10-20  8:11 ` [PATCH v5 4/5] watchdog: w83627hf_wdt: Store Super I/O configurations in platform data Paul Louvel
2026-10-20  8:11 ` [PATCH v5 5/5] watchdog: w83627hf_wdt: Add minute mode counting Paul Louvel
2026-10-20 14:08   ` Tzung-Bi Shih
2026-10-20 15:42     ` Guenter Roeck
2026-10-20 16:28     ` Paul Louvel

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=sashiko-outbox-178668@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=paul.louvel@bootlin.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.