C99 compatibility fixes

Stop building the pcardext Python extension because it unusable
().

Related to:

  <https://fedoraproject.org/wiki/Changes/PortingToModernC>
  <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>
This commit is contained in:
Florian Weimer 2022-11-24 17:24:31 +01:00
parent a960ac4214
commit bbb19dff5e
6 changed files with 157 additions and 1 deletions

View File

@ -0,0 +1,34 @@
The pcardext Python extension cannot be loaded because it has not been
ported to Python 3:
>>> import pcardext
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib64/python3.11/site-packages/pcardext.so: undefined symbol: PyString_AsStringAndSize
>>>
Stop building this extension because it breaks the build if the
compiler lacks support for implicit function declarations.
Bug: <https://bugzilla.redhat.com/show_bug.cgi?id=2148210>
Submitted upstream: <https://bugs.launchpad.net/hplip/+bug/1997875>
diff --git a/Makefile.am b/Makefile.am
index ddac16a9dd514008..15d953af9150c09e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -306,13 +306,6 @@ if !HPLIP_CLASS_DRIVER
pcarddir = $(hplipdir)/pcard
dist_pcard_DATA = pcard/__init__.py pcard/photocard.py
-# pcardext
-pcardextdir = $(pyexecdir)
-pcardext_LTLIBRARIES = pcardext.la
-pcardext_la_LDFLAGS = -module -avoid-version
-pcardext_la_SOURCES = pcard/pcardext/pcardext.c pcard/fat.c pcard/pcardext/pcardext.h
-pcardext_la_CFLAGS = -I$(PYTHONINCLUDEDIR)
-
# prnt
prntdir = $(hplipdir)/prnt
dist_prnt_DATA = prnt/cups.py prnt/__init__.py prnt/ldl.py prnt/pcl.py prnt/colorcal.py

17
hplip-pserror-c99.patch Normal file
View File

@ -0,0 +1,17 @@
prnt/pserror.c: Replace an implicit int with an explicit int
Submitted upstream: <https://bugs.launchpad.net/hplip/+bug/1997875>
diff --git a/prnt/hpps/pserror.c b/prnt/hpps/pserror.c
index 114d7e1b5fa364fb..493b49c27917a7e6 100644
--- a/prnt/hpps/pserror.c
+++ b/prnt/hpps/pserror.c
@@ -24,7 +24,7 @@ extern char *program ; /* Defined by main program, giving program name */
void message(int flags, char *format, ...)
{
va_list args ;
- static column = 0 ; /* current screen column for message wrap */
+ static int column = 0 ; /* current screen column for message wrap */
char msgbuf[MAX_MESSAGE] ; /* buffer in which to put the message */
char *bufptr = msgbuf ; /* message buffer pointer */

View File

@ -0,0 +1,19 @@
scam/sane/hpaio.c: Include orblite.h for more function prototypes
Otherwise the build fails with compilers which do not support
implicit function declarations.
Submitted upstream: <https://bugs.launchpad.net/hplip/+bug/1997875>
diff --git a/scan/sane/hpaio.c b/scan/sane/hpaio.c
index d342626822fc2190..57d1ddea32fb5816 100644
--- a/scan/sane/hpaio.c
+++ b/scan/sane/hpaio.c
@@ -50,6 +50,7 @@
#include "sclpml.h"
#include "escl.h"
#include "io.h"
+#include "orblite.h"
#include "orblitei.h"

View File

@ -0,0 +1,48 @@
scan/sane/orblite: Include <dflcn.h> for function prototypes
This is required for C99 compatibility. Also delete the unused
bb_unload function because it calls a call to the undefined
_DBG function/macro.
Submitted upstream: <https://bugs.launchpad.net/hplip/+bug/1997875>
diff --git a/scan/sane/orblite.c b/scan/sane/orblite.c
index ba86640c7528fc9c..ac59dda9c2dba593 100644
--- a/scan/sane/orblite.c
+++ b/scan/sane/orblite.c
@@ -20,6 +20,7 @@
#include "orblitei.h"
#include "orblite.h"//Added New
#include <math.h>
+#include <dlfcn.h>
#include "utils.h"
#include "io.h"
@@ -193,27 +194,6 @@ bugout:
}
-static int bb_unload(SANE_THandle ps)
-{
- _DBG("Calling orblite bb_unload: \n");
- if (ps->bb_handle)
- {
- dlclose(ps->bb_handle);
- ps->bb_handle = NULL;
- }
- if (ps->hpmud_handle)
- {
- dlclose(ps->hpmud_handle);
- ps->hpmud_handle = NULL;
- }
-// if (ps->math_handle)
-// {
-// dlclose(ps->math_handle);
-// ps->math_handle = NULL;
-// }
- return 0;
-}
-
SANE_Status
orblite_init (SANE_Int * version_code, SANE_Auth_Callback authorize)
{

View File

@ -0,0 +1,20 @@
Kludge to support building C99 mode. This should no longer be needed
once glibc declares strcasestr by default, and not just with
-D_GNU_SOURCE.
Submitted upstream: <https://bugs.launchpad.net/hplip/+bug/1997875>
diff --git a/scan/sane/sclpml.c b/scan/sane/sclpml.c
index dc8b32ce02ad1202..f2cacd53e86800ce 100644
--- a/scan/sane/sclpml.c
+++ b/scan/sane/sclpml.c
@@ -47,6 +47,9 @@
#define DEBUG_DECLARE_ONLY
#include "sanei_debug.h"
+/* This file is not built with _GNU_SOURCE. */
+char *strcasestr(const char *, const char *);
+
//# define SCLPML_DEBUG
# ifdef SCLPML_DEBUG
# define _DBG(args...) syslog(LOG_INFO, __FILE__ " " STRINGIZE(__LINE__) ": " args)

View File

@ -7,7 +7,7 @@
Summary: HP Linux Imaging and Printing Project
Name: hplip
Version: 3.22.10
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+ and MIT and BSD and IJG and GPLv2+ with exceptions and ISC
Url: https://developers.hp.com/hp-linux-imaging-and-printing
@ -203,6 +203,14 @@ Patch61: hplip-plugin-script.patch
Patch1000: hplip-fedora-gui.patch
%endif
# C99 compatibility fixes.
# Submitted uostream: <https://bugs.launchpad.net/hplip/+bug/1997875>
Patch1001: hplip-pserror-c99.patch
Patch1002: hplip-scan-hpaio-include.patch
Patch1003: hplip-scan-orblite-c99.patch
Patch1004: hplip-pcardext-disable.patch
Patch1005: hplip-sclpml-strcasestr.patch
# uses automatic creation of configure
BuildRequires: autoconf
# uses automatic creation of Makefile
@ -524,6 +532,12 @@ done
%patch1000 -p1 -b .fedora-gui
%endif
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
%patch1004 -p1
%patch1005 -p1
sed -i.duplex-constraints \
-e 's,\(UIConstraints.* \*Duplex\),//\1,' \
prnt/drv/hpcups.drv.in
@ -879,6 +893,10 @@ rm -f %{buildroot}%{_sysconfdir}/xdg/autostart/hplip-systray.desktop
%config(noreplace) %{_sysconfdir}/sane.d/dll.d/hpaio
%changelog
* Thu Nov 24 2022 Florian Weimer <fweimer@redhat.com> - 3.22.10-2
- C99 compatibility fixes
- Stop building the pcardext Python extension because it unusable (#2148210)
* Wed Nov 23 2022 Zdenek Dohnal <zdohnal@redhat.com> - 3.22.10-1
- 2139309 - hplip-3.22.10 is available