From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97869 invoked by alias); 25 Oct 2016 11:31:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 97855 invoked by uid 89); 25 Oct 2016 11:31:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:746 X-HELO: mx2.suse.de From: Andreas Schwab To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] Fix undefined behaviour inconsistent for strtok References: <1477393113-3845-1-git-send-email-adhemerval.zanella@linaro.org> X-Yow: You were s'posed to laugh! Date: Tue, 25 Oct 2016 11:31:00 -0000 In-Reply-To: <1477393113-3845-1-git-send-email-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Tue, 25 Oct 2016 08:58:33 -0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2016-10/txt/msg00412.txt.bz2 On Okt 25 2016, Adhemerval Zanella 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. -- 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."