public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Carlos O'Donell (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: [review] manual: Clarify strnlen, wcsnlen, strndup null termination behavior
Date: Wed, 27 Nov 2019 19:08:00 -0000	[thread overview]
Message-ID: <20191127190806.A9DF420AF6@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1572431114000.Ia3e68bc2d4d7e967df141702fb2f600cbd4a6432@gnutoolchain-gerrit.osci.io>

Carlos O'Donell has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/444
......................................................................


Patch Set 1: Code-Review+2

(2 comments)

Looks good to me.

Reivewed-by: Carlos O'Donell <carlos@redhat.com>

| --- /dev/null
| +++ /COMMIT_MSG
| @@ -1,0 +1,12 @@ 
| +Parent:     177a3d48 (y2038: linux: Provide __clock_getres64 implementation)
| +Author:     Florian Weimer <fweimer@redhat.com>
| +AuthorDate: 2019-10-30 11:21:18 +0100
| +Commit:     Florian Weimer <fweimer@redhat.com>
| +CommitDate: 2019-10-30 11:21:18 +0100
| +
| +manual: Clarify strnlen, wcsnlen, strndup null termination behavior
| +
| +It is required that the inputs are arrays, as reading is not
| +guaranteed to stop on the first null byte.

PS1, Line 10:

OK. Agreed.

| +
| +Change-Id: Ia3e68bc2d4d7e967df141702fb2f600cbd4a6432
| --- manual/string.texi
| +++ manual/string.texi
| @@ -321,18 +321,22 @@ is more efficient and works even if @var{s} is not null-terminated so
|  long as @var{maxlen} does not exceed the size of @var{s}'s array.
|  
|  @smallexample
|  char string[32] = "hello, world";
|  strnlen (string, 32)
|      @result{} 12
|  strnlen (string, 5)
|      @result{} 5
|  @end smallexample
|  
| +Note that @var{s} must be an array of at least @var{maxlen} bytes.  It
| +is undefined to call @code{strnlen} on a shorter array, even if it is
| +known that the shorter array contains a null terminator.

PS1, Line 333:

OK. Agreed, you must have at least maxlen bytes, othewise it's
undefined. We might even create something that scans backwards for
NULL bytes knowing we have maxlen bytes.

| +
|  This function is a GNU extension and is declared in @file{string.h}.
|  @end deftypefun
|  
|  @deftypefun size_t wcsnlen (const wchar_t *@var{ws}, size_t @var{maxlen})
|  @standards{GNU, wchar.h}
|  @safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
|  @code{wcsnlen} is the wide character equivalent to @code{strnlen}.  The
|  @var{maxlen} parameter specifies the maximum number of wide characters.

-- 
Gerrit-Project: glibc
Gerrit-Branch: master
Gerrit-Change-Id: Ia3e68bc2d4d7e967df141702fb2f600cbd4a6432
Gerrit-Change-Number: 444
Gerrit-PatchSet: 1
Gerrit-Owner: Florian Weimer <fweimer@redhat.com>
Gerrit-Reviewer: Carlos O'Donell <carlos@redhat.com>
Gerrit-Comment-Date: Wed, 27 Nov 2019 19:08:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

  parent reply	other threads:[~2019-11-27 19:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 10:25 Florian Weimer (Code Review)
2019-10-30 10:44 ` Andreas Schwab
2019-10-30 10:55   ` Florian Weimer
2019-10-30 11:00     ` Andreas Schwab
2019-10-30 11:03       ` Florian Weimer
2019-10-30 11:10         ` Andreas Schwab
2019-10-30 12:01           ` Zack Weinberg
2019-10-30 16:20             ` Andreas Schwab
2019-10-30 16:31               ` Zack Weinberg
2019-10-30 16:47                 ` Andreas Schwab
2019-10-30 16:58                   ` Zack Weinberg
2019-10-30 17:26                     ` Andreas Schwab
2019-10-30 18:12                       ` Zack Weinberg
2019-10-30 18:36                         ` Florian Weimer
2019-10-30 17:24             ` Joseph Myers
2019-11-28  9:43         ` Florian Weimer
2019-11-28 15:56           ` Carlos O'Donell
2019-11-28 15:58             ` Carlos O'Donell
2019-11-28 18:23               ` Rich Felker
2019-11-28 18:38                 ` Szabolcs Nagy
2019-11-29 18:20                   ` Martin Sebor
2019-11-27 19:08 ` Carlos O'Donell (Code Review) [this message]
2019-11-27 19:14 ` Florian Weimer (Code Review)
2019-11-27 22:11 ` Carlos O'Donell (Code Review)

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=20191127190806.A9DF420AF6@gnutoolchain-gerrit.osci.io \
    --to=gerrit@gnutoolchain-gerrit.osci.io \
    --cc=fweimer@redhat.com \
    --cc=gnutoolchain-gerrit@osci.io \
    --cc=libc-alpha@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).