rpm-software-management / dnf5

Next-generation RPM package management system
Other
256 stars 86 forks source link

chore: static_cast to fix sign conversion warning #1715

Closed evan-goode closed 2 months ago

evan-goode commented 2 months ago

Without this patch, the i686 build fails due to -Werror and a sign conversion warning, introduced in https://github.com/rpm-software-management/dnf5/pull/1703.

I only noticed the error after making an upstream release and trying to build DNF 5.2.6.1 in Koji. It might be good to have builds for non-x86_64 architectures tested in our upstream CI so we can catch these issues sooner.

jrohel commented 2 months ago

Without this patch, the i686 build fails due to -Werror and a sign conversion warning

On x86_64, std::vector<some_type>::difference_type is a 64 bit signed type. Thus it can hold a larger number than unsigned int, a 32 bit unsigned type. But, on i686, std::vector<some_type>::difference_type is a 32 bit signed type. So the compiler correctly warned when adding unsigned int - a 32 bit unsigned type.

It might be good to have builds for non-x86_64 architectures tested in our upstream CI.

Yes, good idea. Especially testing a 32 bit build.

We could also test builds for big-endian architecture. To catch endian related bugs. Fedora supports s390x - big-endian architecture.

jrohel commented 2 months ago

Thanks for the fix.