From nobody Sat Dec 3 16:06:41 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NPZSZ3Q57z4jkC5 for ; Sat, 3 Dec 2022 16:06:54 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NPZSZ1MCCz3vYK for ; Sat, 3 Dec 2022 16:06:54 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ed1-x52e.google.com with SMTP id d14so5250922edj.11 for ; Sat, 03 Dec 2022 08:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=THIMBWYzBgO9XmJ6xxj5LrrO04eNgxdM9gPceCHBkUc=; b=2PXt6XFcD7Zia4N72bl0KRxB2M1hZjDO6lhTaHejDnJIhdVAUkROLHglAJB/ChYLUl fAOt11sD3I7OSp+oB+4eeZkBQfTxM5HmB2mfFdeY0Y2doHcxzFMzCvrlTwHFh5wu1Sms CSOJfYNT8WtXDrj4NkaWNNTjffcZwP2tAV1Rke45k6JpNwko9KyLEBtXHxJCK9lq5xPU YBiPvgloOUz62TBqMEFPwf9yGayPu7Bz7NOjB1dPG68xuBLMQSrWPJpy7G/ALtgqcwBZ Cjxmmdwz6jDo5RNJPVhAWPACOgV+kD/ogpPlBpLb3txFI1shujVl28A2/yfym3Kzl3aX An/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=THIMBWYzBgO9XmJ6xxj5LrrO04eNgxdM9gPceCHBkUc=; b=UJvr/fgcIWv50ZQ5LRaHf0jBT0FHLQcDCwEjuGPO6dxNca1hx1ZZnCUbdFWe7U31wk ypu4zYarwPRu9h035MGV05d8HnLHf70T7/qm2cxORfmG3ALM5VhFv0SqK36PF1KJCPuT wKWWna1oqGh/Xza4BIKyS8bleZhrZNPEEydU0yAZ9+zhmHqvNxKRTe7h6d/rC4km+JTI 9IGUJrxOmfogcEyrOA6u1LUGSQaSYKlkEunYNhjSAS4dv1E8PSIIP21owRo4+qD5N/ru x7w/5evTXX8oJKeUyFUt6+FYSSNUrMNVRoYY9w/Bwec3jD3fc5kj4gYyBTcajb+5Smi7 Sp4Q== X-Gm-Message-State: ANoB5pmyBcjcyDqo4t6pOLcNsfnrCvm8ArMyjw2w/JJbeyClu40CtlXS 1oj7Iw9twEixYquidJCzknC/zAYfMZGy/KMsjJduFw== X-Google-Smtp-Source: AA0mqf6uRu/z4Nc8AnHeS0lvlENxT9QkvzpTjA1I5i/WpnSS/U6p9SUtyL1BYte3cCppFxxiKtpiQCJXeGpK5EeSn2A= X-Received: by 2002:aa7:d659:0:b0:46b:1687:2e5d with SMTP id v25-20020aa7d659000000b0046b16872e5dmr26898908edr.136.1670083612633; Sat, 03 Dec 2022 08:06:52 -0800 (PST) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 References: <202212021949.2B2JnpxT077008@gitrepo.freebsd.org> <39c15d70-4895-3b3b-cbbd-d0d7eaec0fdb@selasky.org> In-Reply-To: <39c15d70-4895-3b3b-cbbd-d0d7eaec0fdb@selasky.org> From: Warner Losh Date: Sat, 3 Dec 2022 09:06:41 -0700 Message-ID: Subject: Re: git: da5d0a1dbc28 - main - kboot: Use unsigned long long. To: Hans Petter Selasky Cc: Warner Losh , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="0000000000007a0bb705eeeea4dc" X-Rspamd-Queue-Id: 4NPZSZ1MCCz3vYK X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --0000000000007a0bb705eeeea4dc Content-Type: text/plain; charset="UTF-8" On Sat, Dec 3, 2022 at 5:31 AM Hans Petter Selasky wrote: > On 12/2/22 20:49, Warner Losh wrote: > > The branch main has been updated by imp: > > > > URL: > https://cgit.FreeBSD.org/src/commit/?id=da5d0a1dbc2838eae7033254705c684d7a013fce > > > > commit da5d0a1dbc2838eae7033254705c684d7a013fce > > Author: Warner Losh > > AuthorDate: 2022-12-02 19:41:01 +0000 > > Commit: Warner Losh > > CommitDate: 2022-12-02 19:41:01 +0000 > > > > kboot: Use unsigned long long. > > > > For the 64-bit platforms, this is a nop. Currently kboot only > supports > > 64-bit platforms, though. If we support 32-bit in the future, this > will > > become important. > > > > Noticed by: rpokala > > Sponsored by: Netflix > > --- > > stand/kboot/util.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/stand/kboot/util.c b/stand/kboot/util.c > > index 938aad599e19..7d467a29b059 100644 > > --- a/stand/kboot/util.c > > +++ b/stand/kboot/util.c > > @@ -35,7 +35,7 @@ file2str(const char *fn, char *buffer, size_t buflen) > > bool > > file2u64(const char *fn, uint64_t *val) > > { > > - unsigned long v; > > + unsigned long long v; > > char buffer[80]; > > > > if (!file2str(fn, buffer, sizeof(buffer))) > > Why not include stdint.h and use uint64_t ? > > Instead of building on the good old assumptions, int is 32-bit and long > long is 64-bit? It is interesting to observe the sizes of these types in > 8-bit compilers :-) Not that it makes a big difference for us. Maybe > _Static_assert(sizeof(long long) == 8, "Please fix this code"); > The code was wrong because I called strtoull and assigned it to an unsigned long, not an unsigned long long. On 64-bit platforms, long and long long are the same. Long long being > 8 bytes is fine for this interface: it only returns 64 bits. And we assume this all over the place. Warner --0000000000007a0bb705eeeea4dc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Dec 3, 2022 at 5:31 AM Hans P= etter Selasky <hps@selasky.org>= ; wrote:
On 12/2= /22 20:49, Warner Losh wrote:
> The branch main has been updated by imp:
>
> URL: https://= cgit.FreeBSD.org/src/commit/?id=3Dda5d0a1dbc2838eae7033254705c684d7a013fce<= /a>
>
> commit da5d0a1dbc2838eae7033254705c684d7a013fce
> Author:=C2=A0 =C2=A0 =C2=A0Warner Losh <imp@FreeBSD.org>
> AuthorDate: 2022-12-02 19:41:01 +0000
> Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh <imp@FreeBSD.org>
> CommitDate: 2022-12-02 19:41:01 +0000
>
>=C2=A0 =C2=A0 =C2=A0 kboot: Use unsigned long long.
>=C2=A0 =C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 For the 64-bit platforms, this is a nop. Currently= kboot only supports
>=C2=A0 =C2=A0 =C2=A0 64-bit platforms, though. If we support 32-bit in = the future, this will
>=C2=A0 =C2=A0 =C2=A0 become important.
>=C2=A0 =C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 Noticed by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0rpokala
>=C2=A0 =C2=A0 =C2=A0 Sponsored by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Netflix
> ---
>=C2=A0 =C2=A0stand/kboot/util.c | 2 +-
>=C2=A0 =C2=A01 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/stand/kboot/util.c b/stand/kboot/util.c
> index 938aad599e19..7d467a29b059 100644
> --- a/stand/kboot/util.c
> +++ b/stand/kboot/util.c
> @@ -35,7 +35,7 @@ file2str(const char *fn, char *buffer, size_t buflen= )
>=C2=A0 =C2=A0bool
>=C2=A0 =C2=A0file2u64(const char *fn, uint64_t *val)
>=C2=A0 =C2=A0{
> -=C2=A0 =C2=A0 =C2=A0unsigned long v;
> +=C2=A0 =C2=A0 =C2=A0unsigned long long v;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0char buffer[80];
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (!file2str(fn, buffer, sizeof(buffer)))
Why not include stdint.h and use uint64_t ?

Instead of building on the good old assumptions, int is 32-bit and long long is 64-bit? It is interesting to observe the sizes of these types in 8-bit compilers :-) Not that it makes a big difference for us. Maybe
_Static_assert(sizeof(long long) =3D=3D 8, "Please fix this code"= );


Warner
--0000000000007a0bb705eeeea4dc--