# Handle RDB version differences

**URL:** <https://forum.codecrafters.io/t/handle-rdb-version-differences/1615>\
**Category:** Challenges\
**Tags:** challenge:redis\
**Created:** [September 3, 2024, 1:20am UTC](https://forum.codecrafters.io/t/handle-rdb-version-differences/1615 "2024-09-03T01:20:08Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [September 5, 2024, 7:50am UTC](https://forum.codecrafters.io/t/handle-rdb-version-differences/1615/12 "2024-09-05T07:50:51Z")

</div>

Our tests for Redis in cpp run on `Debian GNU/Linux 12 (bookworm)` [[Dockerfile](https://github.com/codecrafters-io/build-your-own-redis/blob/main/dockerfiles/cpp-23.Dockerfile)].

I did a bunch of logs, and could confirm that:

1. The file was not corrupted.
2. The parsing went well, until after the magic string and the RDB version.
3. Everything from this point was ignored till the end of the file.

So a crucial question is:

> Can the code read the next byte `0xFA` correctly, and match `opcode == 0xFA`?

The result is no and no.

The reason is that char is **signed** by default on most platforms, meaning `char opcode` interprets 0xFA as `-6`, thus ignoring `opcode (-6) == 0xFA (250)`

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/0/0117303956417cf672fbd1fbada4dfb27965d4c3.jpeg)

* * *

Do you by any chance use an ARM-based machine, where char could be `unsigned` by default? @AlRodriguezGar14

You can do this to find out:

```cpp
char opcode = 0xFA;

std::cout << "opcode as int: " << int(opcode) << std::endl;

if (std::is_signed<decltype(opcode)>::value)
{
  std::cout << "opcode is signed." << std::endl;
}
else
{
  std::cout << "opcode is unsigned." << std::endl;
}

```

---

_[View the full topic](https://forum.codecrafters.io/t/handle-rdb-version-differences/1615)._
