From patchwork Tue Jun 9 16:08:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Marshall X-Patchwork-Id: 1306059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=glasgow.ac.uk Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49hFRT4VxZz9sT2 for ; Wed, 10 Jun 2020 02:08:53 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCFF4388B027; Tue, 9 Jun 2020 16:08:50 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from plockton.cent.gla.ac.uk (plockton.cent.gla.ac.uk [130.209.16.75]) by sourceware.org (Postfix) with ESMTP id D4849388B026 for ; Tue, 9 Jun 2020 16:08:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D4849388B026 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=glasgow.ac.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=John.W.Marshall@glasgow.ac.uk Received: from tmpvpnr181-22.cent.gla.ac.uk ([172.20.181.22] helo=Johns-MacBook-Pro.local) by plockton.cent.gla.ac.uk with smtp (Exim 4.72) (envelope-from ) id 1jignu-0000Na-7q for libc-alpha@sourceware.org; Tue, 09 Jun 2020 17:08:46 +0100 Date: Tue, 9 Jun 2020 17:08:45 +0100 From: John Marshall To: libc-alpha@sourceware.org Subject: [PATCH] random: range is not portably RAND_MAX [BZ #7003] Message-ID: <20200609160620.GA29668@Johns-MacBook-Pro.local> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On other platforms, RAND_MAX (which is the range of rand(3)) may differ from 2^31-1 (which is the range of random(3)). Reviewed-by: Carlos O'Donell --- The fix applied for BZ #7003 made a similar change to manual/math.texi but this comment was neglected. I am not FSF copyright assigned, but I imagine this change is trivial enough not to need it. Cheers, John stdlib/stdlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index f971df4247..fb06bb9ac1 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -397,7 +397,7 @@ extern long int a64l (const char *__s) `initstate' and `setstate' functions are those from BSD Unices. The `rand' and `srand' functions are required by the ANSI standard. We provide both interfaces to the same random number generator. */ -/* Return a random long integer between 0 and RAND_MAX inclusive. */ +/* Return a random long integer in [0,2^31). */ extern long int random (void) __THROW; /* Seed the random number generator with the given number. */