Skip to content

Commit

Permalink
changelogs: Fix count variable type
Browse files Browse the repository at this point in the history
The variable `count` in `print_changelogs` used to be `int32_t`, but was
changed to `int64_t`. Because of that, the build on i686 arch fails with:

```
error: conversion from 'int64_t' {aka 'long long int'} to
'__gnu_cxx::__normal_iterator<libdnf5::rpm::Changelog*,
std::vector<libdnf5::rpm::Changelog> >::difference_type' {aka 'int'} may
change value [-Werror=conversion]
```
  • Loading branch information
pkratoch authored and kontura committed Jun 29, 2023
1 parent 50a8ecb commit 49cd99c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions dnf5-plugins/changelog_plugin/changelog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ void ChangelogCommand::configure() {
void ChangelogCommand::run() {
auto & ctx = get_context();

std::pair<libdnf5::cli::output::ChangelogFilterType, std::variant<libdnf5::rpm::PackageQuery, int64_t>> filter = {
libdnf5::cli::output::ChangelogFilterType::NONE, 0};
std::pair<libdnf5::cli::output::ChangelogFilterType, std::variant<libdnf5::rpm::PackageQuery, int64_t, int32_t>>
filter = {libdnf5::cli::output::ChangelogFilterType::NONE, 0};
libdnf5::rpm::PackageQuery full_package_query(ctx.base, libdnf5::sack::ExcludeFlags::APPLY_EXCLUDES, false);

auto since = since_option->get_value();
Expand Down
2 changes: 1 addition & 1 deletion include/libdnf5-cli/output/changelogs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum class ChangelogFilterType { NONE, UPGRADES, COUNT, SINCE };

void print_changelogs(
libdnf5::rpm::PackageQuery & query,
std::pair<ChangelogFilterType, std::variant<libdnf5::rpm::PackageQuery, int64_t>> filter);
std::pair<ChangelogFilterType, std::variant<libdnf5::rpm::PackageQuery, int64_t, int32_t>> filter);

} // namespace libdnf5::cli::output

Expand Down
4 changes: 2 additions & 2 deletions libdnf5-cli/output/changelogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace libdnf5::cli::output {

void print_changelogs(
libdnf5::rpm::PackageQuery & query,
std::pair<ChangelogFilterType, std::variant<libdnf5::rpm::PackageQuery, int64_t>> filter) {
std::pair<ChangelogFilterType, std::variant<libdnf5::rpm::PackageQuery, int64_t, int32_t>> filter) {
// by_srpm
std::map<std::string, std::vector<libdnf5::rpm::Package>> by_srpm;
for (auto pkg : query) {
Expand Down Expand Up @@ -88,7 +88,7 @@ void print_changelogs(
}
changelogs.erase(changelogs.begin() + static_cast<int>(idx), changelogs.end());
} else if (filter.first == ChangelogFilterType::COUNT) {
int64_t count = std::get<int64_t>(filter.second);
int32_t count = std::get<int32_t>(filter.second);
if (count > 0) {
if (static_cast<size_t>(count) < changelogs.size()) {
changelogs.erase(changelogs.begin() + count, changelogs.end());
Expand Down

0 comments on commit 49cd99c

Please sign in to comment.