Fix C compatibility issues in tests

Related to:

  <https://fedoraproject.org/wiki/Changes/PortingToModernC>
  <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>
This commit is contained in:
Florian Weimer 2024-01-21 18:57:57 +01:00
parent e756ae568d
commit 3265c40aad
3 changed files with 80 additions and 1 deletions

46
libreport-c89-2.patch Normal file
View File

@ -0,0 +1,46 @@
problem_item_get_size expects unsigned long * argument in problem_data.at test
Otherwise, the test fails to build on i686 with GCC 14.
Submitted upstream: <https://github.com/abrt/libreport/pull/802>
diff --git a/tests/problem_data.at b/tests/problem_data.at
index 4d8bf0075c0a8b91..db67a76732d48663 100644
--- a/tests/problem_data.at
+++ b/tests/problem_data.at
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
struct problem_item *itm = problem_data_add_ext(data, "1", "foo", CD_FLAG_TXT | CD_FLAG_ISNOTEDITABLE, PROBLEM_ITEM_UNINITIALIZED_SIZE);
const size_t old_size = strlen(itm->content);
{
- size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
+ unsigned long current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
assert(problem_item_get_size(itm, &current_size) == 0);
assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
assert(current_size == old_size);
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
{
g_free(itm->content);
itm->content = NULL;
- size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
+ unsigned long current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
assert(problem_item_get_size(itm, &current_size) == 0);
assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
assert(current_size == old_size);
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
struct problem_item *itm = problem_data_add_ext(data, "2", flnm, CD_FLAG_BIN, PROBLEM_ITEM_UNINITIALIZED_SIZE);
{
- size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
+ unsigned long current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
assert(problem_item_get_size(itm, &current_size) == 0);
assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
assert(current_size == old_size);
@@ -129,7 +129,7 @@ int main(int argc, char **argv)
close(flds);
unlink(flnm);
assert(stat(flnm, &buf) != 0);
- size_t current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
+ unsigned long current_size = PROBLEM_ITEM_UNINITIALIZED_SIZE;
assert(problem_item_get_size(itm, &current_size) == 0);
assert(current_size != PROBLEM_ITEM_UNINITIALIZED_SIZE);
assert(current_size == old_size);

28
libreport-c89.patch Normal file
View File

@ -0,0 +1,28 @@
Remove incorrect casts from tests/string_list.at
The list_order argument already has the correct pointer type const
char * const * (after array-to-pointer decay).
Submitted upstream: <https://github.com/abrt/libreport/pull/802>
diff --git a/tests/string_list.at b/tests/string_list.at
index 6af162a2f8da3919..2118298da4de0ec3 100644
--- a/tests/string_list.at
+++ b/tests/string_list.at
@@ -22,13 +22,13 @@ int main(void)
NULL
};
- int index = libreport_index_of_string_in_list(FILENAME_REASON, (char**) list_order);
+ int index = libreport_index_of_string_in_list(FILENAME_REASON, list_order);
assert(index == 0);
- index = libreport_index_of_string_in_list(FILENAME_COUNT, (char**) list_order);
+ index = libreport_index_of_string_in_list(FILENAME_COUNT, list_order);
assert(index == 5);
- index = libreport_index_of_string_in_list("other", (char**) list_order);
+ index = libreport_index_of_string_in_list("other", list_order);
assert(index < 0);
return 0;

View File

@ -15,10 +15,12 @@
Summary: Generic library for reporting various problems
Name: libreport
Version: 2.17.11
Release: 4%{?dist}
Release: 5%{?dist}
License: GPL-2.0-or-later
URL: https://abrt.readthedocs.org/
Source: https://github.com/abrt/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0: libreport-c89.patch
Patch1: libreport-c89-2.patch
# Fix compatibility with libxml2 2.12
Patch: https://github.com/abrt/%{name}/pull/801.patch
@ -672,6 +674,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%endif
%changelog
* Sun Jan 21 2024 Florian Weimer <fweimer@redhat.com> - 2.17.11-5
- Fix C compatibility issues in tests
* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.17.11-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild