From: Michael Schmitz <schmitzmic@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Christoph Hellwig <hch@lst.de>,
linux-block@vger.kernel.org, axboe@kernel.dk,
linux-m68k@vger.kernel.org, martin@lichtvoll.de,
fthain@linux-m68k.org, stable@vger.kernel.org
Subject: Re: [PATCH v10 2/3] block: change annotation of rdb_CylBlocks in affs_hardblocks.h
Date: Fri, 16 Jun 2023 19:45:27 +1200 [thread overview]
Message-ID: <fec3fd71-47ae-9d15-a64a-a3a899bee503@gmail.com> (raw)
In-Reply-To: <CAMuHMdXpxK2HXJ0s_Fa--sMOAjR8Qt4EVQL2UC7UynMCA6q+1g@mail.gmail.com>
Hi Geert,
Am 16.06.2023 um 19:28 schrieb Geert Uytterhoeven:
> Hi Michael,
>
> On Fri, Jun 16, 2023 at 9:21 AM Michael Schmitz <schmitzmic@gmail.com> wrote:
>> Am 16.06.2023 um 17:48 schrieb Christoph Hellwig:
>>> On Fri, Jun 16, 2023 at 07:53:11AM +1200, Michael Schmitz wrote:
>>>> Thanks - now there's two __s32 fields in that header - one checksum each
>>>> for RDB and PB. No one has so far seen the need for a 'signed big endian 32
>>>> bit' type, and I'd rather avoid adding one to types.h. I'll leave those as
>>>> they are (with the tacit understanding that they are equally meant to be
>>>> big endian).
>>>
>>> We have those in a few other pleases and store them as __be32 as well. The
>>> (implicit) cast to s32 will make them signed again.
>>
>> Where's that cast to s32 hidden? I've only seen
>>
>> #define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
>>
>> which would make the checksums unsigned if __be32 was used.
>>
>> Whether the checksum code uses signed or unsigned math would require
>> inspection of the Amiga partitioning tool source which I don't have, so
>> I've kept __s32 to be safe.
>
> Unsurprisingly, block/partitions/amiga.c:checksum_block() calculates
> a checksum over __be32 words. The actual signedness of the checksum
> field doesn't matter much[*], as using two-complement numbers, you can
> just assign a signed value to an unsigned field.
> It should definitely be __be32.
>
> [*] I guess it was made signed because the procedure to update the
> check goes like this:
> 1. set checksum field to zero,
> 2. calculate sum,
> 3. store negated sum in checksum field.
Thanks, that explains why the result of checksum_block() is tested
against zero. Makes sense now.
Will fix in v12 ...
Cheers,
Michael
>
> Gr{oetje,eeting}s,
>
> Geert
>
next prev parent reply other threads:[~2023-06-16 7:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230615030837.8518-1-schmitzmic@gmail.com>
2023-06-15 3:08 ` [PATCH v10 1/3] block: fix signed int overflow in Amiga partition support Michael Schmitz
2023-06-15 3:08 ` [PATCH v10 2/3] block: change annotation of rdb_CylBlocks in affs_hardblocks.h Michael Schmitz
2023-06-15 4:17 ` Christoph Hellwig
2023-06-15 4:50 ` Michael Schmitz
2023-06-15 5:53 ` Christoph Hellwig
2023-06-15 7:09 ` Michael Schmitz
2023-06-15 7:21 ` Geert Uytterhoeven
2023-06-15 19:53 ` Michael Schmitz
2023-06-16 5:48 ` Christoph Hellwig
2023-06-16 7:20 ` Michael Schmitz
2023-06-16 7:25 ` Christoph Hellwig
2023-06-16 7:51 ` Michael Schmitz
2023-06-16 7:28 ` Geert Uytterhoeven
2023-06-16 7:45 ` Michael Schmitz [this message]
2023-06-15 3:08 ` [PATCH v10 3/3] block: add overflow checks for Amiga partition support Michael Schmitz
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=fec3fd71-47ae-9d15-a64a-a3a899bee503@gmail.com \
--to=schmitzmic@gmail.com \
--cc=axboe@kernel.dk \
--cc=fthain@linux-m68k.org \
--cc=geert@linux-m68k.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=martin@lichtvoll.de \
--cc=stable@vger.kernel.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