From 12367acb33263b811f173ce330e21c6f26e07900 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 29 Oct 2022 18:17:57 +0300 Subject: [PATCH] Fix byte swapping warnings --- src/db.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/db.cc b/src/db.cc index 3cf178b..f724772 100644 --- a/src/db.cc +++ b/src/db.cc @@ -338,7 +338,7 @@ int fileReadInt32(File* stream, int* valuePtr) return -1; } - *valuePtr = ((value >> 24) & 0xFF) | ((value >> 8) & 0xFF00) | ((value << 8) & 0xFF0000) | ((value << 24) & 0xFF000000); + *valuePtr = ((value & 0xFF000000) >> 24) | ((value & 0xFF0000) >> 8) | ((value & 0xFF00) << 8) | ((value & 0xFF) << 24); return 0; } @@ -511,7 +511,7 @@ int fileReadInt32List(File* stream, int* arr, int count) for (int index = 0; index < count; index++) { int value = arr[index]; - arr[index] = ((value >> 24) & 0xFF) | ((value >> 8) & 0xFF00) | ((value << 8) & 0xFF0000) | ((value << 24) & 0xFF000000); + arr[index] = ((value & 0xFF000000) >> 24) | ((value & 0xFF0000) >> 8) | ((value & 0xFF00) << 8) | ((value & 0xFF) << 24); } return 0;