Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another batch of c++ preparation trivia #3027

Merged
merged 10 commits into from
Apr 9, 2024
2 changes: 2 additions & 0 deletions build/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,7 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
goto exit;

#ifdef HAVE_LIBDW
{
/* Check build-ids and add build-ids links for files to package list. */
const char *arch = headerGetString(pkg->header, RPMTAG_ARCH);
if (!rstreq(arch, "noarch")) {
Expand All @@ -2668,6 +2669,7 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
if (fl.processingFailed)
goto exit;
}
}
#endif

/* Verify that file attributes scope over hardlinks correctly. */
Expand Down
2 changes: 0 additions & 2 deletions build/speclua.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

#include "system.h"

#include <lua.h>

#include "rpmlua.h"
#include "rpmbuild_internal.h"

Expand Down
5 changes: 3 additions & 2 deletions include/rpm/rpmtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ typedef enum rpmSigTag_e {
/** \ingroup header
* The basic types of data in tags from headers.
*/
typedef enum rpmTagType_e {
enum rpmTagType_e {
#define RPM_MIN_TYPE 1
RPM_NULL_TYPE = 0,
RPM_CHAR_TYPE = 1,
Expand All @@ -474,7 +474,8 @@ typedef enum rpmTagType_e {
#define RPM_MAX_TYPE 9
#define RPM_FORCEFREE_TYPE 0xff
#define RPM_MASK_TYPE 0x0000ffff
} rpmTagType;
};
typedef rpmFlags rpmTagType;

/** \ingroup rpmtag
* The classes of data in tags from headers.
Expand Down
14 changes: 7 additions & 7 deletions lib/backend/ndb/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static rpmRC ndb_pkgdbPut(dbiIndex dbi, dbiCursor dbc, unsigned int *hdrNum, un
{
struct ndbEnv_s *ndbenv = dbc->dbi->dbi_rpmdb->db_dbenv;
unsigned int hnum = *hdrNum;
int rc = RPMRC_OK;
rpmRC rc = RPMRC_OK;

if (hnum == 0) {
rc = rpmpkgNextPkgIdx(dbc->dbi->dbi_db, &hnum);
Expand Down Expand Up @@ -345,7 +345,7 @@ static rpmRC ndb_pkgdbDel(dbiIndex dbi, dbiCursor dbc, unsigned int hdrNum)
/* iterate over all packages */
static rpmRC ndb_pkgdbIter(dbiIndex dbi, dbiCursor dbc, unsigned char **hdrBlob, unsigned int *hdrLen)
{
int rc;
rpmRC rc;
unsigned int hdrNum;

if (!dbc->list) {
Expand Down Expand Up @@ -376,7 +376,7 @@ static rpmRC ndb_pkgdbIter(dbiIndex dbi, dbiCursor dbc, unsigned char **hdrBlob,

static rpmRC ndb_pkgdbGet(dbiIndex dbi, dbiCursor dbc, unsigned int hdrNum, unsigned char **hdrBlob, unsigned int *hdrLen)
{
int rc;
rpmRC rc;
struct ndbEnv_s *ndbenv = dbc->dbi->dbi_rpmdb->db_dbenv;

if (!hdrNum)
Expand Down Expand Up @@ -422,7 +422,7 @@ static void addtoset(dbiIndexSet *set, unsigned int *pkglist, unsigned int pkgli
/* Iterate over all index entries */
static rpmRC ndb_idxdbIter(dbiIndex dbi, dbiCursor dbc, dbiIndexSet *set)
{
int rc;
rpmRC rc;
if (!dbc->list) {
/* setup iteration list on first call */
rc = rpmidxList(dbc->dbi->dbi_db, &dbc->list, &dbc->nlist, &dbc->listdata);
Expand Down Expand Up @@ -469,7 +469,7 @@ static rpmRC ndb_idxdbIter(dbiIndex dbi, dbiCursor dbc, dbiIndexSet *set)

static rpmRC ndb_idxdbGet(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexSet *set, int searchType)
{
int rc;
rpmRC rc;
unsigned int *pkglist = 0, pkglistn = 0;

if (!keyp)
Expand All @@ -478,7 +478,7 @@ static rpmRC ndb_idxdbGet(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t
if (searchType == DBC_PREFIX_SEARCH) {
unsigned int *list = 0, nlist = 0, i = 0;
unsigned char *listdata = 0;
int rrc = RPMRC_NOTFOUND;
rpmRC rrc = RPMRC_NOTFOUND;
rc = rpmidxList(dbc->dbi->dbi_db, &list, &nlist, &listdata);
if (rc)
return rc;
Expand All @@ -489,7 +489,7 @@ static rpmRC ndb_idxdbGet(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t
continue;
rc = ndb_idxdbGet(dbi, dbc, (char *)k, kl, set, DBC_NORMAL_SEARCH);
if (rc == RPMRC_NOTFOUND)
rc = 0;
rc = RPMRC_OK;
else
rrc = rc;
}
Expand Down
12 changes: 4 additions & 8 deletions lib/backend/ndb/rpmidx.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#include "rpmidx.h"
#include "rpmxdb.h"

#define RPMRC_OK 0
#define RPMRC_NOTFOUND 1
#define RPMRC_FAIL 2

/* Index database
*
*
Expand Down Expand Up @@ -956,7 +952,7 @@ void rpmidxClose(rpmidxdb idxdb)
free(idxdb);
}

int rpmidxPut(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx)
rpmRC rpmidxPut(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx)
{
int rc;
if (!pkgidx || datidx >= 0x80000000) {
Expand All @@ -969,7 +965,7 @@ int rpmidxPut(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsig
return rc;
}

int rpmidxDel(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx)
rpmRC rpmidxDel(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx)
{
int rc;
if (!pkgidx || datidx >= 0x80000000) {
Expand All @@ -982,7 +978,7 @@ int rpmidxDel(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsig
return rc;
}

int rpmidxGet(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int **pkgidxlistp, unsigned int *pkgidxnump)
rpmRC rpmidxGet(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int **pkgidxlistp, unsigned int *pkgidxnump)
{
int rc;
*pkgidxlistp = 0;
Expand All @@ -994,7 +990,7 @@ int rpmidxGet(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsig
return rc;
}

int rpmidxList(rpmidxdb idxdb, unsigned int **keylistp, unsigned int *nkeylistp, unsigned char **datap)
rpmRC rpmidxList(rpmidxdb idxdb, unsigned int **keylistp, unsigned int *nkeylistp, unsigned char **datap)
{
int rc;
*keylistp = 0;
Expand Down
15 changes: 11 additions & 4 deletions lib/backend/ndb/rpmidx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@
struct rpmidxdb_s;
typedef struct rpmidxdb_s *rpmidxdb;

#ifdef __cplusplus
extern "C" {
#endif

int rpmidxOpen(rpmidxdb *idxdbp, rpmpkgdb pkgdb, const char *filename, int flags, int mode);
int rpmidxOpenXdb(rpmidxdb *idxdbp, rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdbtag, int flags);
int rpmidxDelXdb(rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdbtag);
void rpmidxClose(rpmidxdb idxdbp);

int rpmidxGet(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int **pkgidxlist, unsigned int *pkgidxnum);
int rpmidxPut(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx);
int rpmidxDel(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx);
int rpmidxList(rpmidxdb idxdb, unsigned int **keylistp, unsigned int *nkeylistp, unsigned char **datap);
rpmRC rpmidxGet(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int **pkgidxlist, unsigned int *pkgidxnum);
rpmRC rpmidxPut(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx);
rpmRC rpmidxDel(rpmidxdb idxdb, const unsigned char *key, unsigned int keyl, unsigned int pkgidx, unsigned int datidx);
rpmRC rpmidxList(rpmidxdb idxdb, unsigned int **keylistp, unsigned int *nkeylistp, unsigned char **datap);

int rpmidxStats(rpmidxdb idxdb);

#ifdef __cplusplus
}
#endif
19 changes: 7 additions & 12 deletions lib/backend/ndb/rpmpkg.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@

#include "rpmpkg.h"

#define RPMRC_FAIL 2
#define RPMRC_NOTFOUND 1
#define RPMRC_OK 0


static int rpmpkgVerifyblob(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned int blkoff, unsigned int blkcnt);

typedef struct pkgslot_s {
Expand Down Expand Up @@ -1062,7 +1057,7 @@ void rpmpkgSetFsync(rpmpkgdb pkgdb, int dofsync)
}


static int rpmpkgGetInternal(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsigned int *bloblp)
static rpmRC rpmpkgGetInternal(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsigned int *bloblp)
{
pkgslot *slot;
unsigned char *blob;
Expand Down Expand Up @@ -1264,7 +1259,7 @@ static int rpmpkgVerifyInternal(rpmpkgdb pkgdb)
return RPMRC_OK;
}

int rpmpkgGet(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsigned int *bloblp)
rpmRC rpmpkgGet(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsigned int *bloblp)
{
int rc;

Expand All @@ -1279,7 +1274,7 @@ int rpmpkgGet(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsign
return rc;
}

int rpmpkgPut(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char *blob, unsigned int blobl)
rpmRC rpmpkgPut(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char *blob, unsigned int blobl)
{
int rc;

Expand All @@ -1293,7 +1288,7 @@ int rpmpkgPut(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char *blob, unsigned
return rc;
}

int rpmpkgDel(rpmpkgdb pkgdb, unsigned int pkgidx)
rpmRC rpmpkgDel(rpmpkgdb pkgdb, unsigned int pkgidx)
{
int rc;

Expand All @@ -1307,7 +1302,7 @@ int rpmpkgDel(rpmpkgdb pkgdb, unsigned int pkgidx)
return rc;
}

int rpmpkgList(rpmpkgdb pkgdb, unsigned int **pkgidxlistp, unsigned int *npkgidxlistp)
rpmRC rpmpkgList(rpmpkgdb pkgdb, unsigned int **pkgidxlistp, unsigned int *npkgidxlistp)
{
int rc;
if (pkgidxlistp)
Expand All @@ -1320,7 +1315,7 @@ int rpmpkgList(rpmpkgdb pkgdb, unsigned int **pkgidxlistp, unsigned int *npkgidx
return rc;
}

int rpmpkgVerify(rpmpkgdb pkgdb)
rpmRC rpmpkgVerify(rpmpkgdb pkgdb)
{
int rc;
if (rpmpkgLockReadHeader(pkgdb, 0))
Expand All @@ -1330,7 +1325,7 @@ int rpmpkgVerify(rpmpkgdb pkgdb)
return rc;
}

int rpmpkgNextPkgIdx(rpmpkgdb pkgdb, unsigned int *pkgidxp)
rpmRC rpmpkgNextPkgIdx(rpmpkgdb pkgdb, unsigned int *pkgidxp)
{
if (rpmpkgLockReadHeader(pkgdb, 1) || !pkgdb->nextpkgidx)
return RPMRC_FAIL;
Expand Down
21 changes: 15 additions & 6 deletions lib/backend/ndb/rpmpkg.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include <rpm/rpmtypes.h>

struct rpmpkgdb_s;
typedef struct rpmpkgdb_s *rpmpkgdb;

#ifdef __cplusplus
extern "C" {
#endif

int rpmpkgOpen(rpmpkgdb *pkgdbp, const char *filename, int flags, int mode);
int rpmpkgSalvage(rpmpkgdb *pkgdbp, const char *filename);
void rpmpkgClose(rpmpkgdb pkgdbp);
Expand All @@ -9,14 +15,17 @@ void rpmpkgSetFsync(rpmpkgdb pkgdbp, int dofsync);
int rpmpkgLock(rpmpkgdb pkgdb, int excl);
int rpmpkgUnlock(rpmpkgdb pkgdb, int excl);

int rpmpkgGet(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsigned int *bloblp);
int rpmpkgPut(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char *blob, unsigned int blobl);
int rpmpkgDel(rpmpkgdb pkgdb, unsigned int pkgidx);
int rpmpkgList(rpmpkgdb pkgdb, unsigned int **pkgidxlistp, unsigned int *npkgidxlistp);
int rpmpkgVerify(rpmpkgdb pkgdb);
rpmRC rpmpkgGet(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char **blobp, unsigned int *bloblp);
rpmRC rpmpkgPut(rpmpkgdb pkgdb, unsigned int pkgidx, unsigned char *blob, unsigned int blobl);
rpmRC rpmpkgDel(rpmpkgdb pkgdb, unsigned int pkgidx);
rpmRC rpmpkgList(rpmpkgdb pkgdb, unsigned int **pkgidxlistp, unsigned int *npkgidxlistp);
rpmRC rpmpkgVerify(rpmpkgdb pkgdb);

int rpmpkgNextPkgIdx(rpmpkgdb pkgdb, unsigned int *pkgidxp);
rpmRC rpmpkgNextPkgIdx(rpmpkgdb pkgdb, unsigned int *pkgidxp);
int rpmpkgGeneration(rpmpkgdb pkgdb, unsigned int *generationp);

int rpmpkgStats(rpmpkgdb pkgdb);

#ifdef __cplusplus
}
#endif
4 changes: 0 additions & 4 deletions lib/backend/ndb/rpmxdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

#include "rpmxdb.h"

#define RPMRC_OK 0
#define RPMRC_NOTFOUND 1
#define RPMRC_FAIL 2

typedef struct rpmxdb_s {
rpmpkgdb pkgdb; /* main database */
char *filename;
Expand Down
7 changes: 7 additions & 0 deletions lib/backend/ndb/rpmxdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
struct rpmxdb_s;
typedef struct rpmxdb_s *rpmxdb;

#ifdef __cplusplus
extern "C" {
#endif

int rpmxdbOpen(rpmxdb *xdbp, rpmpkgdb pkgdb, const char *filename, int flags, int mode);
void rpmxdbClose(rpmxdb xdb);
void rpmxdbSetFsync(rpmxdb xdb, int dofsync);
Expand All @@ -27,3 +31,6 @@ int rpmxdbGetUserGeneration(rpmxdb xdb, unsigned int *usergenerationp);

int rpmxdbStats(rpmxdb xdb);

#ifdef __cplusplus
}
#endif
24 changes: 11 additions & 13 deletions lib/formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

#include "debug.h"

#define RPM_ANY_CLASS 255

typedef char * (*headerTagFormatFunction) (rpmtd td, char **emsg);

/** \ingroup header
Expand All @@ -32,7 +30,7 @@ typedef char * (*headerTagFormatFunction) (rpmtd td, char **emsg);
struct headerFmt_s {
rpmtdFormats fmt; /*!< Value of extension */
const char *name; /*!< Name of extension. */
rpmTagClass tclass; /*!< Class of source data (RPM_ANY_CLASS for any) */
rpmTagClass tclass; /*!< Class of source data (RPM_NULL_CLASS for any) */
headerTagFormatFunction func; /*!< Pointer to formatter function. */
};

Expand Down Expand Up @@ -571,9 +569,9 @@ static char *tagnumFormat(rpmtd td, char **emsg)

static const struct headerFmt_s rpmHeaderFormats[] = {
{ RPMTD_FORMAT_STRING, "string",
RPM_ANY_CLASS, stringFormat },
RPM_NULL_CLASS, stringFormat },
{ RPMTD_FORMAT_ARMOR, "armor",
RPM_ANY_CLASS, armorFormat },
RPM_NULL_CLASS, armorFormat },
{ RPMTD_FORMAT_BASE64, "base64",
RPM_BINARY_CLASS, base64Format },
{ RPMTD_FORMAT_PGPSIG, "pgpsig",
Expand All @@ -591,7 +589,7 @@ static const struct headerFmt_s rpmHeaderFormats[] = {
{ RPMTD_FORMAT_TRIGGERTYPE, "triggertype",
RPM_NUMERIC_CLASS, triggertypeFormat },
{ RPMTD_FORMAT_XML, "xml",
RPM_ANY_CLASS, xmlFormat },
RPM_NULL_CLASS, xmlFormat },
{ RPMTD_FORMAT_OCTAL, "octal",
RPM_NUMERIC_CLASS, octalFormat },
{ RPMTD_FORMAT_HEX, "hex",
Expand All @@ -601,9 +599,9 @@ static const struct headerFmt_s rpmHeaderFormats[] = {
{ RPMTD_FORMAT_DAY, "day",
RPM_NUMERIC_CLASS, dayFormat },
{ RPMTD_FORMAT_SHESCAPE, "shescape",
RPM_ANY_CLASS, shescapeFormat },
RPM_NULL_CLASS, shescapeFormat },
{ RPMTD_FORMAT_ARRAYSIZE, "arraysize",
RPM_ANY_CLASS, arraysizeFormat },
RPM_NULL_CLASS, arraysizeFormat },
{ RPMTD_FORMAT_FSTATE, "fstate",
RPM_NUMERIC_CLASS, fstateFormat },
{ RPMTD_FORMAT_VFLAGS, "vflags",
Expand All @@ -617,12 +615,12 @@ static const struct headerFmt_s rpmHeaderFormats[] = {
{ RPMTD_FORMAT_HUMANIEC, "humaniec",
RPM_NUMERIC_CLASS, humaniecFormat },
{ RPMTD_FORMAT_TAGNAME, "tagname",
RPM_ANY_CLASS, tagnameFormat },
RPM_NULL_CLASS, tagnameFormat },
{ RPMTD_FORMAT_TAGNUM, "tagnum",
RPM_ANY_CLASS, tagnumFormat },
RPM_NULL_CLASS, tagnumFormat },
{ RPMTD_FORMAT_JSON, "json",
RPM_ANY_CLASS, jsonFormat },
{ -1, NULL, 0, NULL }
RPM_NULL_CLASS, jsonFormat },
{ RPMTD_FORMAT_STRING, NULL, RPM_NULL_CLASS, NULL }
};

headerFmt rpmHeaderFormatByName(const char *fmt)
Expand Down Expand Up @@ -652,7 +650,7 @@ char *rpmHeaderFormatCall(headerFmt fmt, rpmtd td)
char *ret = NULL;
char *err = NULL;

if (fmt->tclass != RPM_ANY_CLASS && rpmtdClass(td) != fmt->tclass)
if (fmt->tclass != RPM_NULL_CLASS && rpmtdClass(td) != fmt->tclass)
err = xstrdup(classEr(fmt->tclass));
else
ret = fmt->func(td, &err);
Expand Down