From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 9B40A3856DF5 for ; Wed, 4 May 2022 15:13:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B40A3856DF5 Received: by mail-ot1-x32b.google.com with SMTP id s12-20020a0568301e0c00b00605f30530c2so1079763otr.9 for ; Wed, 04 May 2022 08:13:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=lOZnq+AvHQwpq2G/APgcRAqcSJDz5/vt1r7+Lm3xn8k=; b=nhnGcTYje7nnf9mUiPBOu5tWQls6mjW5xCkmwUmh+GPovw8C3LaqnFyfhLQXwQsbDf ONCGDTocultGELP1Mx2shx7vFjMjTyz5kiQNGOWvq9xqE1iTBaaieg741IkfpADraICS BhFr/iIwOsGSLXYYw5TTl9YwbpBMyt38MKmcnhtv+ktxp2lRszuxAZTUvk9cDrUH1ojb MWRSl+rStptxvofYDi19RHmoZPogTgLnUU+lJF1ka8HE/6WT6eqlu6ki4CNcm/Ajdp4C 0bofY3r8YxyNr3sUM62CQUptVbQNWdTsF24/qH0jLFNcyDiUZm9LEniLSCzg4X46YiDO mD8Q== X-Gm-Message-State: AOAM533sVSOZjoSIPeHmqAibuYun0aO0GFRnGY3EwMcoR+0uHCgC/riw gUjhNDJEHL1tM4ROmg/8DJ4QaA== X-Google-Smtp-Source: ABdhPJwUmSx8pRrGTBPNesdfxBb0rrLbKqrmARsFzwA2fwOp2t0uB6F9SwzPF4nYA8C5hCyIgPoh8w== X-Received: by 2002:a05:6830:20c5:b0:606:1826:406f with SMTP id z5-20020a05683020c500b006061826406fmr5095593otq.34.1651677193853; Wed, 04 May 2022 08:13:13 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:726:3ae8:3076:1dad:37? ([2804:431:c7cb:726:3ae8:3076:1dad:37]) by smtp.gmail.com with ESMTPSA id s4-20020a0568080b0400b00325cda1ffbasm4375445oij.57.2022.05.04.08.13.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 May 2022 08:13:12 -0700 (PDT) Message-ID: <0b53b954-be1e-c75c-1853-8699f8dbecff@linaro.org> Date: Wed, 4 May 2022 12:13:10 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v5 01/10] stdlib: Add arc4random, arc4random_buf, and arc4random_uniform (BZ #4417) Content-Language: en-US To: Florian Weimer Cc: Andreas Schwab , Adhemerval Zanella via Libc-alpha References: <20220504135921.3679585-1-adhemerval.zanella@linaro.org> <20220504135921.3679585-2-adhemerval.zanella@linaro.org> <87tua5penk.fsf@igel.home> <6a7fe3ef-a930-8c42-bf4e-1cbbbf55d3a9@linaro.org> <87o80dqrdf.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella In-Reply-To: <87o80dqrdf.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-List-Received-Date: Wed, 04 May 2022 15:13:16 -0000 On 04/05/2022 11:55, Florian Weimer wrote: > * Adhemerval Zanella: > >> On 04/05/2022 11:15, Andreas Schwab wrote: >>> On Mai 04 2022, Adhemerval Zanella via Libc-alpha wrote: >>> >>>> +/* Return the number of bytes which cover values up to the limit. */ >>>> +__attribute__ ((const)) >>>> +static uint32_t >>>> +byte_count (uint32_t n) >>>> +{ >>>> + if (n <= (1U << 8)) >>>> + return 1; >>>> + else if (n <= (1U << 16)) >>>> + return 2; >>>> + else if (n <= (1U << 24)) >>>> + return 3; >>>> + else >>>> + return 4; >>> >>> Shouldn't that compare with < instead of <=? >>> >> >> It should, I have fixed it. > > Are you sure? An argument of 256 means result values between in 0 and > 255 (inclusive), so a byte count of 1 for 256 is correct. Right, arc4random_uniform returns a number less than the upper bound.