Skip to content

Fix 32bit compilation#2175

Merged
BareosBot merged 3 commits intobareos:masterfrom
AlexanderS:fix-32bit
Feb 27, 2025
Merged

Fix 32bit compilation#2175
BareosBot merged 3 commits intobareos:masterfrom
AlexanderS:fix-32bit

Conversation

@AlexanderS
Copy link
Contributor

@AlexanderS AlexanderS commented Feb 13, 2025

Thank you for contributing to the Bareos Project!

While compiling a debian package for armhf (32bit) I encountered two errors.

The first errors in src/stored/backends/chunked_device.cc :

core/src/stored/backends/chunked_device.cc: In member function ‘ssize_t storagedaemon::ChunkedDevice::ReadChunked(int, void*, size_t)’:
core/src/include/bc_types.h:113:26: error: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘int’} and ‘uint32_t’ {aka ‘unsigned int’} [-Werror=sign-compare]
  113 | #  define MIN(a, b) ((a) < (b) ? (a) : (b))
      |                      ~~~~^~~~~
core/src/stored/backends/chunked_device.cc:685:13: note: in expansion of macro ‘MIN’
  685 |           = MIN((ssize_t)count, (current_chunk_->buflen - wanted_offset));
      |             ^~~
core/src/stored/backends/chunked_device.cc: In member function ‘ssize_t storagedaemon::ChunkedDevice::WriteChunked(int, const void*, size_t)’:
core/src/stored/backends/chunked_device.cc:846:46: error: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘int’} and ‘uint32_t’ {aka ‘unsigned int’} [-Werror=sign-compare]
  846 |             if ((wanted_offset + bytes_left) > current_chunk_->buflen) {

These errors are likely caused because the casts were just forgotten. There are multiple similar code lines around the locations with the appropriate casts.

The second error in core/src/stored/backends/dedupable/volume.cc:

core/src/stored/backends/dedupable/volume.cc: In constructor ‘dedup::data::data(dedup::{anonymous}::open_context, const dedup::config&)’:
core/src/stored/backends/dedupable/volume.cc:231:61: error: narrowing conversion of ‘(uint64_t)bf.dedup::config::block_file::End’ from ‘uint64_t’ {aka ‘long long unsigned int’} to ‘dedup::fvec<dedup::block>::size_type’ {aka ‘unsigned int’} [-Werror=narrowing]
  231 |   blocks = decltype(blocks){ctx.read_only, bfd.fileno(), bf.End};
      |                                                          ~~~^~~
core/src/stored/backends/dedupable/volume.cc:232:59: error: narrowing conversion of ‘(uint64_t)pf.dedup::config::part_file::End’ from ‘uint64_t’ {aka ‘long long unsigned int’} to ‘dedup::fvec<dedup::part>::size_type’ {aka ‘unsigned int’} [-Werror=narrowing]
  232 |   parts = decltype(parts){ctx.read_only, pfd.fileno(), pf.End};
      |                                                        ~~~^~~

These are errors in the new Dedupable Storage Backend. The pull request does not alter any data types of any field because I believe that the dedup::config structures are directly serialized into the files on the storage. So the implementation simply throws. if the config contains values that are too large.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
    Required backport PRs have been created
  • Correct milestone is set
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

@sebsura sebsura added bug This addresses a bug enhancement and removed bug This addresses a bug labels Feb 21, 2025
@AlexanderS AlexanderS force-pushed the fix-32bit branch 2 times, most recently from a54158c to 0cac495 Compare February 24, 2025 16:24
Copy link
Contributor

@sebsura sebsura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work!

This will fix sign comparision warnings when compiling 32bit
binaries. There are already a lot of similar casts, so I suspect these
ones were just forgotten.
This fixes some conversion warnings when compiling bareos for 32bit.
The types of config::block_file::End and config::part_file::End are
not the same as fvec<block>::size_type or fvec<part>::size_type for
32bit, beacuse size_t is not uint64_t.

This change does not change the types of the structures, because these
values are serialized on the volume.
@BareosBot BareosBot merged commit b8adb71 into bareos:master Feb 27, 2025
1 check was pending
@AlexanderS AlexanderS deleted the fix-32bit branch February 27, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments