From 89f4e22e9e277171a8c1339b7171a75a06e5225e88917c46fa007cf3ac43c505 Mon Sep 17 00:00:00 2001
From: Pedro Monreal Gonzalez <pmonrealgonzalez@suse.com>
Date: Thu, 7 Mar 2024 07:47:11 +0000
Subject: [PATCH] Accepting request 1155577 from
 home:pmonrealgonzalez:branches:devel:languages:perl

- Fix build with gcc14: [bsc#1221011]
  * Upstream PR: https://github.com/perl5-dbi/DBD-mysql/pull/295
  * Add perl-DBD-mysql-gcc14.patch

OBS-URL: https://build.opensuse.org/request/show/1155577
OBS-URL: https://build.opensuse.org/package/show/devel:languages:perl/perl-DBD-mysql?expand=0&rev=77
---
 cpanspec.yml               |  5 ++---
 perl-DBD-mysql-gcc14.patch | 40 ++++++++++++++++++++++++++++++++++++++
 perl-DBD-mysql.changes     |  7 +++++++
 perl-DBD-mysql.spec        |  7 ++++---
 4 files changed, 53 insertions(+), 6 deletions(-)
 create mode 100644 perl-DBD-mysql-gcc14.patch

diff --git a/cpanspec.yml b/cpanspec.yml
index de0e608..3d169d6 100644
--- a/cpanspec.yml
+++ b/cpanspec.yml
@@ -4,9 +4,8 @@ description_paragraphs: 1
 #sources:
 #  - source1
 #  - source2
-#patches:
-#  foo.patch: -p1
-#  bar.patch:
+patches:
+  perl-DBD-mysql-gcc14.patch: -p1
 preamble: |-
  BuildRequires:  libmariadb-devel
  BuildRequires:  zlib-devel
diff --git a/perl-DBD-mysql-gcc14.patch b/perl-DBD-mysql-gcc14.patch
new file mode 100644
index 0000000..c80f56e
--- /dev/null
+++ b/perl-DBD-mysql-gcc14.patch
@@ -0,0 +1,40 @@
+From 93bc876808af048091bf76d6908a9748d0476ab9 Mon Sep 17 00:00:00 2001
+From: Eric Herman <eric@freesa.org>
+Date: Thu, 10 Jan 2019 10:22:38 +0100
+Subject: [PATCH] Fix "assignment from incompatible pointer type"
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+I encountered this warning from gcc 7.3.0 building on Ubuntu:
+
+dbdimp.c: In function ‘mysql_st_prepare’:
+dbdimp.c:3207:24: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
+           bind->is_null=      (_Bool*) &(fbind->is_null);
+
+The "MYSQL_BIND" field "is_null" is of type "my_bool", not "_Bool".
+
+The type "my_bool" is (usually) type-defined to be of a "char" type.
+
+Regardless, the "imp_sth_phb_t" field "is_null" is of type "char".
+
+This commit removes the cast, which means that if we later discover
+that "my_bool" is defined to be of a type incompatible with the
+"imp_sth_phb_t" field "is_null", it will break at compile-time.
+---
+ dbdimp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/dbdimp.c b/dbdimp.c
+index b0399d94..e7e6c007 100644
+--- a/dbdimp.c
++++ b/dbdimp.c
+@@ -3204,7 +3204,7 @@ dbd_st_prepare(
+           bind->buffer_type=  MYSQL_TYPE_STRING;
+           bind->buffer=       NULL;
+           bind->length=       &(fbind->length);
+-          bind->is_null=      (_Bool*) &(fbind->is_null);
++          bind->is_null=      &(fbind->is_null);
+           fbind->is_null=     1;
+           fbind->length=      0;
+         }
diff --git a/perl-DBD-mysql.changes b/perl-DBD-mysql.changes
index 0b3dfc3..cb498ee 100644
--- a/perl-DBD-mysql.changes
+++ b/perl-DBD-mysql.changes
@@ -1,3 +1,10 @@
+-------------------------------------------------------------------
+Wed Mar  6 13:55:14 UTC 2024 - Pedro Monreal <pmonreal@suse.com>
+
+- Fix build with gcc14: [bsc#1221011]
+  * Upstream PR: https://github.com/perl5-dbi/DBD-mysql/pull/295
+  * Add perl-DBD-mysql-gcc14.patch
+
 -------------------------------------------------------------------
 Wed Feb 13 15:05:24 UTC 2019 - Vítězslav Čížek <vcizek@suse.com>
 
diff --git a/perl-DBD-mysql.spec b/perl-DBD-mysql.spec
index f273263..161e452 100644
--- a/perl-DBD-mysql.spec
+++ b/perl-DBD-mysql.spec
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-DBD-mysql
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2024 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -23,9 +23,10 @@ Release:        0
 Summary:        MySQL driver for the Perl5 Database Interface (DBI)
 License:        Artistic-1.0 OR GPL-1.0-or-later
 Group:          Development/Libraries/Perl
-Url:            https://metacpan.org/release/%{cpan_name}
+URL:            https://metacpan.org/release/%{cpan_name}
 Source0:        https://cpan.metacpan.org/authors/id/D/DV/DVEEDEN/%{cpan_name}-%{version}.tar.gz
 Source1:        cpanspec.yml
+Patch0:         perl-DBD-mysql-gcc14.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 BuildRequires:  perl
 BuildRequires:  perl-macros
@@ -49,7 +50,7 @@ are supported. Some rarely used functions are missing, mainly because
 no-one ever requested them. :-)
 
 %prep
-%setup -q -n %{cpan_name}-%{version}
+%autosetup -p1 -n %{cpan_name}-%{version}
 find . -type f ! -name \*.pl -print0 | xargs -0 chmod 644
 
 %build