From 3103f20653e3d71ed1e25dbfa60cd7148c92af63 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 24 Feb 2025 14:41:00 +0100 Subject: [PATCH 1/2] dracut: add static linkage to internal functions Added the `static` keyword to functions that are not used outside their respective source files to limit their linkage and prevent potential symbol conflicts. --- dracut/dd/dd_extract.c | 2 +- dracut/dd/dd_list.c | 6 +++--- dracut/dd/rpmutils.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dracut/dd/dd_extract.c b/dracut/dd/dd_extract.c index 6542df1b137..e833107c065 100644 --- a/dracut/dd/dd_extract.c +++ b/dracut/dd/dd_extract.c @@ -80,7 +80,7 @@ void show_help() { * during cpio extraction, only extract files we need * eg. module .ko files and firmware directory */ -int dlabelFilter(const char* name, const struct stat *fstat, int packageflags, void *userptr) +static int dlabelFilter(const char* name, const struct stat *fstat, int packageflags, void *userptr) { int l = strlen(name); diff --git a/dracut/dd/dd_list.c b/dracut/dd/dd_list.c index dd33b10c5ca..0d39babd0e7 100644 --- a/dracut/dd/dd_list.c +++ b/dracut/dd/dd_list.c @@ -58,7 +58,7 @@ struct _version_struct { char* anaconda; }; -int globErrFunc(const char *epath, int eerrno) +static int globErrFunc(const char *epath, int eerrno) { /* TODO check fatal errors */ @@ -86,7 +86,7 @@ void show_help() { * we use it to check if kernel-modules = * and installer-enhancement = */ -int dlabelProvides(const char* dep, const char* version, uint32_t sense, void *userptr) +static int dlabelProvides(const char* dep, const char* version, uint32_t sense, void *userptr) { char *kernelver = ((struct _version_struct*)userptr)->kernel; char *anacondaver = ((struct _version_struct*)userptr)->anaconda; @@ -132,7 +132,7 @@ int dlabelProvides(const char* dep, const char* version, uint32_t sense, void *u /** * Print information about the rpm to stdout */ -int dlabelOK(const char* source, Header *h, int packageflags) +static int dlabelOK(const char* source, Header *h, int packageflags) { struct rpmtd_s tdname; struct rpmtd_s tddesc; diff --git a/dracut/dd/rpmutils.c b/dracut/dd/rpmutils.c index 72a5cb2fd4e..cc60c4e4224 100644 --- a/dracut/dd/rpmutils.c +++ b/dracut/dd/rpmutils.c @@ -54,14 +54,14 @@ struct cpio_mydata { * libarchive callbacks */ -ssize_t rpm_myread(struct archive *a, void *client_data, const void **buff) +static ssize_t rpm_myread(struct archive *a, void *client_data, const void **buff) { struct cpio_mydata *mydata = client_data; *buff = mydata->buffer; return Fread(mydata->buffer, 1, BUFFERSIZE, mydata->gzdi); } -int rpm_myclose(struct archive *a, void *client_data) +static int rpm_myclose(struct archive *a, void *client_data) { struct cpio_mydata *mydata = client_data; if (mydata->gzdi > 0) @@ -81,7 +81,7 @@ int init_rpm() { /* read data from RPM header */ -const char * headerGetString(Header h, rpmTagVal tag) +static const char * headerGetString(Header h, rpmTagVal tag) { const char *res = NULL; struct rpmtd_s td; From 3f4e041aea97e23c9ef4e95d21f513645a8d38e5 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Mon, 24 Feb 2025 15:19:27 +0100 Subject: [PATCH 2/2] dracut: use RPM library-provided headerGetString function Removed the local definition of `headerGetString` in rpmutils.c to avoid conflicts with the existing declaration in the RPM library headers. The code now uses the library-provided function from . --- dracut/dd/rpmutils.c | 17 ----------------- dracut/dd/rpmutils.h | 1 - 2 files changed, 18 deletions(-) diff --git a/dracut/dd/rpmutils.c b/dracut/dd/rpmutils.c index cc60c4e4224..c08db031bda 100644 --- a/dracut/dd/rpmutils.c +++ b/dracut/dd/rpmutils.c @@ -78,23 +78,6 @@ int init_rpm() { return rpmReadConfigFiles(NULL, NULL); } - -/* read data from RPM header */ - -static const char * headerGetString(Header h, rpmTagVal tag) -{ - const char *res = NULL; - struct rpmtd_s td; - - if (headerGet(h, tag, &td, HEADERGET_MINMEM)) { - if (rpmtdCount(&td) == 1) { - res = rpmtdGetString(&td); - } - rpmtdFreeData(&td); - } - return res; -} - /* * */ diff --git a/dracut/dd/rpmutils.h b/dracut/dd/rpmutils.h index b0b2f944836..ce3cc60a8c2 100644 --- a/dracut/dd/rpmutils.h +++ b/dracut/dd/rpmutils.h @@ -64,7 +64,6 @@ typedef int (*dependencyfunc)(const char* depname, const char* depversion, const */ typedef int (*okfunc)(const char* filename, Header *rpmheader, int packageflags); -const char * headerGetString(Header h, rpmTagVal tag); int init_rpm(); int checkDDRPM(const char *source, dependencyfunc provides,