public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] Fix undefined behaviour inconsistent for strtok
Date: Tue, 25 Oct 2016 12:57:00 -0000	[thread overview]
Message-ID: <mvmoa28k2mn.fsf@hawking.suse.de> (raw)
In-Reply-To: <385e684a-8101-fd26-d2ff-464515a2e88c@linaro.org> (Adhemerval Zanella's message of "Tue, 25 Oct 2016 10:33:15 -0200")

On Okt 25 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> On 25/10/2016 09:31, Andreas Schwab wrote:
>> On Okt 25 2016, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>> 
>>> 	* string/strtok.c (strtok): Return null is previous input is also
>> 
>> s/is/if/
>> 
>>> diff --git a/string/strtok.c b/string/strtok.c
>>> index 7a4574d..5c4b309 100644
>>> --- a/string/strtok.c
>>> +++ b/string/strtok.c
>>> @@ -40,8 +40,8 @@ STRTOK (char *s, const char *delim)
>>>  {
>>>    char *token;
>>>  
>>> -  if (s == NULL)
>>> -    s = olds;
>>> +  if ((s == NULL) && ((s = olds) == NULL))
>> 
>> Please avoid assignment in an expression.  And the parens are redundant.
>> 
>> Andreas.
>> 
>
> Right, with these fixes would it be acceptable?

I don't see much point in supporting invalid use of strtok.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

  reply	other threads:[~2016-10-25 12:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25 10:58 Adhemerval Zanella
2016-10-25 11:31 ` Andreas Schwab
2016-10-25 12:33   ` Adhemerval Zanella
2016-10-25 12:57     ` Andreas Schwab [this message]
2016-10-25 13:13       ` Adhemerval Zanella
2016-10-25 13:20         ` Andreas Schwab
2016-10-25 13:23           ` Adhemerval Zanella
2016-10-25 13:45             ` Andreas Schwab
2016-10-25 13:49               ` Adhemerval Zanella
2016-10-25 13:51             ` Joseph Myers
2016-10-25 14:08               ` Adhemerval Zanella
2016-10-25 13:32 ` Florian Weimer
2016-10-25 14:04 Wilco Dijkstra
2016-10-25 16:46 ` Wilco Dijkstra

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=mvmoa28k2mn.fsf@hawking.suse.de \
    --to=schwab@suse.de \
    --cc=adhemerval.zanella@linaro.org \
    --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).