public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Baris Can Goral <goralbaris@gmail.com>
To: mjguzik@gmail.com
Cc: acpica-devel@lists.linux.dev, goralbaris@gmail.com,
	kees@kernel.org, lenb@kernel.org, linux-acpi@vger.kernel.org,
	lkp@intel.com, oe-lkp@lists.linux.dev, oliver.sang@intel.com,
	rafael.j.wysocki@intel.com, robert.moore@intel.com,
	skhan@linuxfoundation.org
Subject: [PATCH acpi] Replace strncpy with strscpy
Date: Wed, 21 May 2025 18:58:49 +0300	[thread overview]
Message-ID: <20250521155849.13783-1-goralbaris@gmail.com> (raw)
In-Reply-To: <rkc452hxtxcaym55croa5uvtjjsulbl25bhdk2mw2ce5fwqx4p@guhdxk6eogqj>

Hi Mateusz,

Tyring to understand your point. Why the customer want a string or
an ID without nul termination?
In your case, you put forward an idea that "the thing is NOT related as a
string, instead it is handled with memcmp".

My idea is:

For examle, the variable "signature" is __nonstring so, it does not necessarily 
contain a terminating NUL.
[snip]
      ACPI_COPY_NAMESEG(header.signature, signature);
      strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
      strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);

[/snip]

But the others, oem_id,oem_table_id are not.
So they are strings and deserve to end with nul.
[snip]
struct acpi_table_header {
    char signature[ACPI_NAMESEG_SIZE] __nonstring;  /* ASCII table signature */
    u32 length;     /* Length of table in bytes, including this header */
    u8 revision;        /* ACPI Specification minor version number */
    u8 checksum;        /* To make sum of entire table == 0 */
    char oem_id[ACPI_OEM_ID_SIZE];  /* ASCII OEM identification */
    char oem_table_id[ACPI_OEM_TABLE_ID_SIZE];  /* ASCII OEM table identification */
    u32 oem_revision;   /* OEM revision number */
    char asl_compiler_id[ACPI_NAMESEG_SIZE];    /* ASCII ASL compiler vendor ID */
    u32 asl_compiler_revision;  /* ASL compiler version */
  };
[/snip]
Otherwise, the writer would have added "__nonstring" keyword.

Best Regards,
Baris

      reply	other threads:[~2025-05-21 15:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 15:20 [PATCH] acpi: convert strncpy into strscpy goralbaris
2025-05-07 15:25 ` Rafael J. Wysocki
2025-05-19  5:18 ` kernel test robot
2025-05-20 16:35   ` [PATCH acpi] Replace strncpy with strscpy Baris Can Goral
2025-05-20 16:48     ` [PATCH v2] acpi: convert strncpy into strscpy Baris Can Goral
2025-05-21  7:43     ` [PATCH acpi] Replace strncpy with strscpy Mateusz Guzik
2025-05-21 15:58       ` Baris Can Goral [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=20250521155849.13783-1-goralbaris@gmail.com \
    --to=goralbaris@gmail.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=kees@kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mjguzik@gmail.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=oliver.sang@intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.com \
    --cc=skhan@linuxfoundation.org \
    /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