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

Spring cleaning! #2977

Merged
merged 21 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f13a17c
Fix some int/enum confusion in the build code
pmatilai Mar 15, 2024
81a0574
Fixup an invalid enum use in %prep parse
pmatilai Mar 15, 2024
c161391
parseSpecSection() expects an enum, give it one
pmatilai Mar 15, 2024
7e021bc
An enumeration is not a bitfield, use an integer instead
pmatilai Mar 15, 2024
df7a559
Fixup type mismatches in rpmRC returns from plugins
pmatilai Mar 18, 2024
d7851de
Follow declaration order in fapolicyd_hooks initialization
pmatilai Mar 18, 2024
bcf58f3
Follow declaration order in rpmdb backend initialization
pmatilai Mar 18, 2024
12baa83
Follow declaration order in rpmrc context initialization
pmatilai Mar 18, 2024
f8e412a
Fix a couple of int/enum type mismatches in signing code
pmatilai Mar 18, 2024
9afc926
Undo weird designated initializers use in rpmsignfiles.c
pmatilai Mar 18, 2024
97643ae
Sanity check the IMA digest algo name lower bound too
pmatilai Mar 18, 2024
c3d8607
Drop silly "register" use from our allocation routines
pmatilai Mar 18, 2024
f5a265d
Avoid an unnecessary cast in selinux callback setting
pmatilai Mar 18, 2024
3084336
Fix an enum/int type mismatch in transaction verify code
pmatilai Mar 18, 2024
a243a8d
Fix enum type mismatch in rpmTagGetValue()
pmatilai Mar 18, 2024
ae24f03
Enums considered harmful (or at least annoying), part XXXII
pmatilai Mar 18, 2024
bb6f64c
Eliminate unused internal rpmfsGetState() API
pmatilai Mar 18, 2024
5aa9252
Fix an enum/int type mismatch in rpmfiArchiveReadToFilePsm()
pmatilai Mar 18, 2024
939558a
Fix an int/enum type mismatch in rpmfilesDecideFate()
pmatilai Mar 18, 2024
01014be
Add DB_CTRL_NONE to the dbCtrl enum for handling the not legit case
pmatilai Mar 18, 2024
a4237dd
Use the internal DB_CTRL* enum for intenal uses consistently
pmatilai Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions build/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static char * buildHost(void)

/**
*/
static rpmRC doRmSource(rpmSpec spec)
static int doRmSource(rpmSpec spec)
{
struct Source *p;
Package pkg;
Expand All @@ -100,7 +100,7 @@ static rpmRC doRmSource(rpmSpec spec)
}
}
exit:
return !rc ? 0 : 1;
return rc;
}

/*
Expand Down Expand Up @@ -290,9 +290,9 @@ static int doBuildRequires(rpmSpec spec, int test)
return rc;
}

static rpmRC doCheckBuildRequires(rpmts ts, rpmSpec spec, int test)
static int doCheckBuildRequires(rpmts ts, rpmSpec spec, int test)
{
rpmRC rc = RPMRC_OK;
int rc = RPMRC_OK;
rpmps ps = rpmSpecCheckDeps(ts, spec);

if (ps) {
Expand Down Expand Up @@ -323,9 +323,9 @@ static rpmRC doBuildDir(rpmSpec spec, int test, StringBuf *sbp)
return rc;
}

static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
static int buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
{
rpmRC rc = RPMRC_OK;
int rc = RPMRC_OK;
int missing_buildreqs = 0;
int test = (what & RPMBUILD_NOBUILD);
char *cookie = buildArgs->cookie ? xstrdup(buildArgs->cookie) : NULL;
Expand Down
2 changes: 1 addition & 1 deletion build/parsePrep.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void appendMb(rpmMacroBuf mb, const char *s, int nl)
*/
static int notCompressed(const char * fn)
{
rpmCompressedMagic compressed = -1;
rpmCompressedMagic compressed = COMPRESSED_OTHER; /* arbitrary non-zero */
struct stat sb;

if (lstat(fn, &sb) == 0)
Expand Down
2 changes: 1 addition & 1 deletion build/parseSpec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags,
spec->recursing = recursing;
spec->flags = flags;

if (parseSpecSection(&spec, 0) != RPMRC_OK)
if (parseSpecSection(&spec, PARSE_SPECFILE) != RPMRC_OK)
goto errxit;

if (spec->sections[SECT_CLEAN] == NULL) {
Expand Down
6 changes: 4 additions & 2 deletions include/rpm/rpmfileutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ typedef enum rpmCompressedMagic_e {
/** \ingroup rpmfileutil
* RPM glob flags, largely modelled after glob(3) flags.
*/
typedef enum rpmglobFlags_e {
enum rpmglobFlags_e {
RPMGLOB_NONE = 0,
RPMGLOB_NOCHECK = (1 << 0), /*!< same as GLOB_NOCHECK */
} rpmglobFlags;
};

typedef rpmFlags rpmglobFlags;

/** \ingroup rpmfileutil
* Calculate a file digest and size.
Expand Down
5 changes: 3 additions & 2 deletions include/rpm/rpmmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ extern const char * macrofiles;
#define RPMEXPAND_KEEP_QUOTED (1 << 1) /*!< do not remove quotes from expanded macros */
#define RPMEXPAND_HAVE_QUOTED (1 << 2) /*!< expanded macros contain quote characters */

typedef enum rpmMacroFlags_e {
enum rpmMacroFlags_e {
RPMMACRO_DEFAULT = 0,
RPMMACRO_LITERAL = (1 << 0), /*!< do not expand body of macro */
} rpmMacroFlags;
};
typedef rpmFlags rpmMacroFlags;

/** \ingroup rpmmacro
* Print macros to file stream.
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/bdb_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,9 @@ struct rpmdbOps_s bdbro_dbops = {
.cursorInit = bdbro_CursorInit,
.cursorFree = bdbro_CursorFree,

.pkgdbGet = bdbro_pkgdbGet,
.pkgdbPut = bdbro_pkgdbPut,
.pkgdbDel = bdbro_pkgdbDel,
.pkgdbGet = bdbro_pkgdbGet,
.pkgdbKey = bdbro_pkgdbKey,

.idxdbGet = bdbro_idxdbGet,
Expand Down
1 change: 1 addition & 0 deletions lib/backend/dbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum rpmdbFlags {
};

typedef enum dbCtrlOp_e {
DB_CTRL_NONE = 0,
DB_CTRL_LOCK_RO = 1,
DB_CTRL_UNLOCK_RO = 2,
DB_CTRL_LOCK_RW = 3,
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/dummydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ struct rpmdbOps_s dummydb_dbops = {
.cursorInit = dummydb_CursorInit,
.cursorFree = dummydb_CursorFree,

.pkgdbGet = dummydb_pkgdbGet,
.pkgdbPut = dummydb_pkgdbPut,
.pkgdbDel = dummydb_pkgdbDel,
.pkgdbGet = dummydb_pkgdbGet,
.pkgdbKey = dummydb_pkgdbKey,

.idxdbGet = dummydb_idxdbGet,
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/ndb/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ struct rpmdbOps_s ndb_dbops = {
.cursorInit = ndb_CursorInit,
.cursorFree = ndb_CursorFree,

.pkgdbGet = ndb_pkgdbGet,
.pkgdbPut = ndb_pkgdbPut,
.pkgdbDel = ndb_pkgdbDel,
.pkgdbGet = ndb_pkgdbGet,
.pkgdbKey = ndb_pkgdbKey,

.idxdbGet = ndb_idxdbGet,
Expand Down
2 changes: 1 addition & 1 deletion lib/backend/sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,9 @@ struct rpmdbOps_s sqlite_dbops = {
.cursorInit = sqlite_CursorInit,
.cursorFree = sqlite_CursorFree,

.pkgdbGet = sqlite_pkgdbGet,
.pkgdbPut = sqlite_pkgdbPut,
.pkgdbDel = sqlite_pkgdbDel,
.pkgdbGet = sqlite_pkgdbGet,
.pkgdbKey = sqlite_pkgdbKey,

.idxdbGet = sqlite_idxdbGet,
Expand Down
4 changes: 2 additions & 2 deletions lib/rpmdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int buildIndexes(rpmdb db)

dbSetFSync(db, 0);

dbCtrl(db, RPMDB_CTRL_LOCK_RW);
dbCtrl(db, DB_CTRL_LOCK_RW);

mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
while ((h = rpmdbNextIterator(mi))) {
Expand Down Expand Up @@ -2517,7 +2517,7 @@ int rpmdbRebuild(const char * prefix, rpmts ts,

int rpmdbCtrl(rpmdb db, rpmdbCtrlOp ctrl)
{
dbCtrlOp dbctrl = 0;
dbCtrlOp dbctrl = DB_CTRL_NONE;
switch (ctrl) {
case RPMDB_CTRL_LOCK_RO:
dbctrl = DB_CTRL_LOCK_RO;
Expand Down
6 changes: 3 additions & 3 deletions lib/rpmfi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,8 @@ rpmFileAction rpmfilesDecideFate(rpmfiles ofi, int oix,
char buffer[1024];
rpmFileTypes dbWhat, newWhat, diskWhat;
struct stat sb;
int save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE;
int action = FA_CREATE; /* assume we can create */
rpmFileAction save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE;
rpmFileAction action = FA_CREATE; /* assume we can create */

/* If the new file is a ghost, leave whatever might be on disk alone. */
if (newFlags & RPMFILE_GHOST) {
Expand Down Expand Up @@ -2384,7 +2384,7 @@ int rpmfiArchiveReadToFilePsm(rpmfi fi, FD_t fd, int nodigest, rpmpsm psm)

rpm_loff_t left = rpmfiFSize(fi);
const unsigned char * fidigest = NULL;
rpmHashAlgo digestalgo = 0;
int digestalgo = 0;
int rc = 0;
char buf[BUFSIZ*4];

Expand Down
7 changes: 0 additions & 7 deletions lib/rpmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state)
fs->states[ix] = state;
}

rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix)
{
assert(ix < fs->fc);
if (fs->states) return fs->states[ix];
return RPMFILE_STATE_MISSING;
}

rpm_fstate_t * rpmfsGetStates(rpmfs fs)
{
return (fs != NULL) ? fs->states : NULL;
Expand Down
3 changes: 0 additions & 3 deletions lib/rpmfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ sharedFileInfo rpmfsNextReplaced(rpmfs fs , sharedFileInfo replaced);
RPM_GNUC_INTERNAL
void rpmfsSetState(rpmfs fs, unsigned int ix, rpmfileState state);

RPM_GNUC_INTERNAL
rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix);

/* May return NULL */
RPM_GNUC_INTERNAL
rpm_fstate_t * rpmfsGetStates(rpmfs fs);
Expand Down
2 changes: 1 addition & 1 deletion lib/rpmrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ static const size_t optionTableSize = sizeof(optionTable) / sizeof(*optionTable)

typedef struct rpmrcCtx_s * rpmrcCtx;
struct rpmrcCtx_s {
pthread_rwlock_t lock;
ARGV_t platpat;
char *current[2];
int currTables[2];
struct rpmvarValue values[RPMVAR_NUM];
struct tableType_s tables[RPM_MACHTABLE_COUNT];
int machDefaults;
int pathDefaults;
pthread_rwlock_t lock;
};

/* prototypes */
Expand Down
2 changes: 1 addition & 1 deletion lib/tagexts.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "debug.h"

struct headerTagFunc_s {
rpmTag tag; /*!< Tag of extension. */
rpmTagVal tag; /*!< Tag of extension. */
headerTagTagFunction func; /*!< Pointer to formatter function. */
};

Expand Down
2 changes: 1 addition & 1 deletion lib/tagname.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ rpmTagType rpmTagGetType(rpmTagVal tag)
rpmTagVal rpmTagGetValue(const char * tagstr)
{
const struct headerTagTableEntry_s *t;
rpmTagType tagval = RPMTAG_NOT_FOUND;
rpmTagVal tagval = RPMTAG_NOT_FOUND;

pthread_once(&tagsLoaded, loadTags);

Expand Down
2 changes: 1 addition & 1 deletion lib/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ static int verifyPackageFiles(rpmts ts, rpm_loff_t total)
.vfylevel = vfylevel,
};
int verified = 0;
rpmRC prc = RPMRC_FAIL;
int prc = RPMRC_FAIL;

rpmtsNotify(ts, p, RPMCALLBACK_VERIFY_PROGRESS, oc++, total);
FD_t fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion plugins/dbus_announce.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static rpmRC send_ts_message(rpmPlugin plugin,

static rpmRC dbus_announce_tsm_pre(rpmPlugin plugin, rpmts ts)
{
int rc;
rpmRC rc;

rc = open_dbus(plugin, ts);
if (rc != RPMRC_OK)
Expand Down
2 changes: 1 addition & 1 deletion plugins/fapolicyd.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static rpmRC fapolicyd_fsm_file_prepare(rpmPlugin plugin, rpmfi fi,
struct rpmPluginHooks_s fapolicyd_hooks = {
.init = fapolicyd_init,
.cleanup = fapolicyd_cleanup,
.scriptlet_pre = fapolicyd_scriptlet_pre,
.tsm_post = fapolicyd_tsm_post,
.scriptlet_pre = fapolicyd_scriptlet_pre,
.fsm_file_prepare = fapolicyd_fsm_file_prepare,
};
2 changes: 1 addition & 1 deletion plugins/fsverity.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static rpmRC fsverity_fsm_file_prepare(rpmPlugin plugin, rpmfi fi, int fd,
const unsigned char * signature = NULL;
size_t len;
uint16_t algo = 0;
int rc = RPMRC_OK;
rpmRC rc = RPMRC_OK;
rpmFileAction action = XFO_ACTION(op);
char *buffer;

Expand Down
2 changes: 1 addition & 1 deletion plugins/ima.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static rpmRC ima_fsm_file_prepare(rpmPlugin plugin, rpmfi fi, int fd,
{
const unsigned char * fsig = NULL;
size_t len;
int rc = RPMRC_OK;
rpmRC rc = RPMRC_OK;
rpmFileAction action = XFO_ACTION(op);

/* Ignore skipped files and unowned directories */
Expand Down
4 changes: 3 additions & 1 deletion plugins/selinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ static rpmRC sehandle_init(int open_status)
return RPMRC_FAIL;

if (open_status) {
union selinux_callback cb;
selinux_status_close();
if (selinux_status_open(0) < 0) {
return RPMRC_FAIL;
}
selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback) &logcb);
cb.func_log = logcb;
selinux_set_callback(SELINUX_CB_LOG, cb);
} else if (!selinux_status_updated() && sehandle) {
return RPMRC_OK;
}
Expand Down
8 changes: 4 additions & 4 deletions rpmio/rpmmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rpmMemFailFunc rpmSetMemFail(rpmMemFailFunc func, void *data)

void * rmalloc (size_t size)
{
register void *value;
void *value;
if (size == 0) size++;
value = malloc (size);
if (value == NULL)
Expand All @@ -50,7 +50,7 @@ void * rmalloc (size_t size)

void * rcalloc (size_t nmemb, size_t size)
{
register void *value;
void *value;
if (size == 0) size++;
if (nmemb == 0) nmemb++;
value = calloc (nmemb, size);
Expand All @@ -61,7 +61,7 @@ void * rcalloc (size_t nmemb, size_t size)

void * rreallocn (void *ptr, size_t nmemb, size_t size)
{
register void *value = NULL;
void *value = NULL;
if (size == 0) size++;
if (nmemb == 0) nmemb++;
if (nmemb < SIZE_MAX / size)
Expand All @@ -73,7 +73,7 @@ void * rreallocn (void *ptr, size_t nmemb, size_t size)

void * rrealloc (void *ptr, size_t size)
{
register void *value;
void *value;
if (size == 0) size++;
value = realloc (ptr, size);
if (value == NULL)
Expand Down
11 changes: 7 additions & 4 deletions sign/rpmgensig.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,16 +522,19 @@ static int msgCb(struct rpmsinfo_s *sinfo, void *cbdata)
}

/* Require valid digests on entire package for signing. */
static int checkPkg(FD_t fd, char **msg)
static rpmRC checkPkg(FD_t fd, char **msg)
{
int rc;
rpmRC rc;
struct rpmvs_s *vs = rpmvsCreate(RPMSIG_DIGEST_TYPE, 0, NULL);
off_t offset = Ftell(fd);

Fseek(fd, 0, SEEK_SET);
rc = rpmpkgRead(vs, fd, NULL, NULL, msg);
if (!rc)
rc = rpmvsVerify(vs, RPMSIG_DIGEST_TYPE, msgCb, msg);
if (!rc) {
rc = rpmvsVerify(vs, RPMSIG_DIGEST_TYPE, msgCb, msg) ?
RPMRC_FAIL : RPMRC_OK;
}
Fseek(fd, offset, SEEK_SET);
Fseek(fd, offset, SEEK_SET);

rpmvsFree(vs);
Expand Down
23 changes: 12 additions & 11 deletions sign/rpmsignfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
#define MAX_SIGNATURE_LENGTH 1024

static const char *hash_algo_name[] = {
[RPM_HASH_MD5] = "md5",
[RPM_HASH_SHA1] = "sha1",
[RPM_HASH_RIPEMD160] = "rmd160",
[RPM_HASH_MD2] = "md2",
[RPM_HASH_TIGER192] = "tgr192",
[RPM_HASH_HAVAL_5_160] = "haval5160",
[RPM_HASH_SHA256] = "sha256",
[RPM_HASH_SHA384] = "sha384",
[RPM_HASH_SHA512] = "sha512",
[RPM_HASH_SHA224] = "sha224",
"none", /* invalid */
"md5", /* RPM_HASH_MD5 */
"sha1", /* RPM_HASH_SHA1 */
"rmd160", /* RPM_HASH_RIPEMD160 */
"md2", /* RPM_HASH_MD2 */
"tgr192", /* RPM_HASH_TIGER192 */
"haval5160",/* RPM_HASH_HAVAL_5_160 */
"sha256", /* RPM_HASH_SHA256 */
"sha384", /* RPM_HASH_SHA384 */
"sha512", /* RPM_HASH_SHA512 */
"sha224", /* RPM_HASH_SHA224 */
};

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
Expand Down Expand Up @@ -82,7 +83,7 @@ rpmRC rpmSignFiles(Header sigh, Header h, const char *key, char *keypass)
}

algo = rpmfiDigestAlgo(fi);
if (algo >= ARRAY_SIZE(hash_algo_name)) {
if (algo < 1 || algo >= ARRAY_SIZE(hash_algo_name)) {
rpmlog(RPMLOG_ERR, _("File digest algorithm id is invalid"));
goto exit;
}
Expand Down
Loading
Loading