public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Alejandro Colomar <alx@kernel.org>
Cc: Mark Naughton <mnaughto@redhat.com>,
	 Mark Harris <mark.hsj@gmail.com>,
	linux-man@vger.kernel.org,  Joseph Myers <josmyers@redhat.com>
Subject: Re: strncmp(3) in the SYNOPSIS
Date: Thu, 05 Jun 2025 17:28:23 +0200	[thread overview]
Message-ID: <874iwuxl60.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <hkyvvyqkhbseev7cyqkdjvknur6tghu6xt7ekjfhjsfyicwsm2@awrjajnvugz5> (Alejandro Colomar's message of "Thu, 5 Jun 2025 17:10:33 +0200")

* Alejandro Colomar:

> Hi Florian,
>
> On Thu, Jun 05, 2025 at 04:53:02PM +0200, Florian Weimer wrote:
>> Somewhat related: This syntax is currently used for inputs that can be
>> either strings or arrays.  Two examples:
>> 
>>        size_t strnlen(size_t maxlen;
>>                       const char s[maxlen], size_t maxlen);
>> 
>>        int strncmp(size_t n;
>>                    const char s1[n], const char s2[n], size_t n);
>> 
>> Obviously, we want
>> 
>>      strncnmp(subject, "prefix", 6)
>> 
>> to be valid independently of the length of the subject string,
>
> I'm not sure I understand your statement.  It assumes that the subject
> is a string, which it need not be.
>
> 	[[gnu::nonstring]] char subject[7] = "asdfghi";
> 	strncmp(subject, "prefix", 6);

My point is that *if* it is a string, it can be arbitrary long.  It does
not have to contain at least five characters, it can be shorter.  These
two choices are valid:

  subject is a string
  subject is an array that is at least six bytes long

They overlap, but both options are needed.  For example, "?" is not an
array that is at least six bytes long.

Thanks,
Florian


  reply	other threads:[~2025-06-05 15:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-03 11:04 Forward Deceleration Changes Mark Naughton
2025-06-03 11:40 ` Alejandro Colomar
2025-06-03 12:21   ` Mark Naughton
2025-06-03 13:17     ` Alejandro Colomar
2025-06-03 14:48       ` Mark Harris
2025-06-03 14:52         ` Mark Naughton
2025-06-03 19:48           ` Alejandro Colomar
2025-06-04 12:00             ` Mark Naughton
2025-06-04 12:27               ` Alejandro Colomar
2025-06-05 14:53             ` Florian Weimer
2025-06-05 15:10               ` strncmp(3) in the SYNOPSIS Alejandro Colomar
2025-06-05 15:28                 ` Florian Weimer [this message]
2025-06-05 15:33                   ` Alejandro Colomar
2025-11-24 17:26                     ` Alejandro Colomar
2025-06-06 13:05           ` Forward Deceleration Changes Alejandro Colomar
2025-06-28 14:58             ` Alejandro Colomar
2025-06-28 23:38               ` Mark Harris
2025-06-29  0:10                 ` Alejandro Colomar

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=874iwuxl60.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=alx@kernel.org \
    --cc=josmyers@redhat.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mark.hsj@gmail.com \
    --cc=mnaughto@redhat.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