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
5 changes: 3 additions & 2 deletions include/rpm/rpmtag.h
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
24 changes: 11 additions & 13 deletions lib/formats.c
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
2 changes: 1 addition & 1 deletion tools/rpmsign.c
Expand Up @@ -28,7 +28,7 @@ static char * fileSigningCert = NULL;
static char * verityAlgorithm = NULL;
#endif

static struct rpmSignArgs sargs = {NULL, 0, 0};
static struct rpmSignArgs sargs;

static struct poptOption signOptsTable[] = {
{ "addsign", '\0', (POPT_ARG_VAL|POPT_ARGFLAG_OR), &mode, MODE_ADDSIGN,
Expand Down