Add casts that C++ requires but C doesn't across librpmio
In other words, a whole lot of "yes, really".
This commit is contained in:
parent
47974f4924
commit
62840a3cdf
|
@ -38,6 +38,18 @@ else()
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if (WITH_CXX)
|
||||
set (cxx_sources
|
||||
argv.c base64.c digest.c expression.c lposix.c macro.c
|
||||
digest_libgcrypt.c digest_openssl.c
|
||||
rgetopt.c rpmfileutil.c rpmglob.c rpmhook.c rpmio.c
|
||||
rpmkeyring.c rpmlog.c rpmlua.c rpmpgp.c rpm_sequoia.c rpmsq.c
|
||||
rpmsw.c rpmstring.c rpmstrpool.c
|
||||
rpmver.c rpmvercmp.c url.c
|
||||
)
|
||||
set_source_files_properties(${cxx_sources} PROPERTIES LANGUAGE CXX)
|
||||
endif()
|
||||
|
||||
set_target_properties(librpmio PROPERTIES
|
||||
VERSION ${RPM_LIBVERSION}
|
||||
SOVERSION ${RPM_SOVERSION}
|
||||
|
|
12
rpmio/argv.c
12
rpmio/argv.c
|
@ -27,7 +27,7 @@ void argvPrint(const char * msg, ARGV_const_t argv, FILE * fp)
|
|||
|
||||
ARGV_t argvNew(void)
|
||||
{
|
||||
ARGV_t argv = xcalloc(1, sizeof(*argv));
|
||||
ARGV_t argv = (ARGV_t)xcalloc(1, sizeof(*argv));
|
||||
return argv;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ ARGV_t argvSearch(ARGV_const_t argv, const char *val,
|
|||
return NULL;
|
||||
if (compar == NULL)
|
||||
compar = argvCmp;
|
||||
return bsearch(&val, argv, argvCount(argv), sizeof(*argv), compar);
|
||||
return (ARGV_t)bsearch(&val, argv, argvCount(argv), sizeof(*argv), compar);
|
||||
}
|
||||
|
||||
int argiAdd(ARGI_t * argip, int ix, int val)
|
||||
|
@ -114,7 +114,7 @@ int argiAdd(ARGI_t * argip, int ix, int val)
|
|||
if (argip == NULL)
|
||||
return -1;
|
||||
if (*argip == NULL)
|
||||
*argip = xcalloc(1, sizeof(**argip));
|
||||
*argip = (ARGI_t)xcalloc(1, sizeof(**argip));
|
||||
argi = *argip;
|
||||
if (ix < 0)
|
||||
ix = argi->nvals;
|
||||
|
@ -186,7 +186,7 @@ ARGV_t argvSplitString(const char * str, const char * seps, argvFlags flags)
|
|||
if (str == NULL || seps == NULL)
|
||||
return NULL;
|
||||
|
||||
dest = xmalloc(strlen(str) + 1);
|
||||
dest = (char *)xmalloc(strlen(str) + 1);
|
||||
for (argc = 1, s = str, t = dest; (c = *s); s++, t++) {
|
||||
if (strchr(seps, c)) {
|
||||
argc++;
|
||||
|
@ -196,7 +196,7 @@ ARGV_t argvSplitString(const char * str, const char * seps, argvFlags flags)
|
|||
}
|
||||
*t = '\0';
|
||||
|
||||
argv = xmalloc( (argc + 1) * sizeof(*argv));
|
||||
argv = (ARGV_t)xmalloc( (argc + 1) * sizeof(*argv));
|
||||
|
||||
for (c = 0, s = dest; s < t; s+= strlen(s) + 1) {
|
||||
if (*s == '\0' && (flags & ARGV_SKIPEMPTY))
|
||||
|
@ -235,7 +235,7 @@ char *argvJoin(ARGV_const_t argv, const char *sep)
|
|||
size_t seplen = (sep != NULL) ? strlen(sep) : 0;
|
||||
char *p;
|
||||
|
||||
dest = xmalloc(argvlen + (seplen * (argc - 1)) + 1);
|
||||
dest = (char *)xmalloc(argvlen + (seplen * (argc - 1)) + 1);
|
||||
|
||||
p = stpcpy(dest, argv[0]);
|
||||
for (int i = 1; i < argc; i++) {
|
||||
|
|
|
@ -61,7 +61,7 @@ static char *base64_encode_block(const char *plaintext_in, int length_in, char *
|
|||
char *rpmBase64Encode(const void *data, size_t len, int linelen)
|
||||
{
|
||||
size_t encodedlen;
|
||||
const char *dataptr = data;
|
||||
const char *dataptr = (const char *)data;
|
||||
char *output;
|
||||
char *outptr;
|
||||
|
||||
|
@ -78,7 +78,7 @@ char *rpmBase64Encode(const void *data, size_t len, int linelen)
|
|||
}
|
||||
++encodedlen; /* for zero termination */
|
||||
|
||||
output = malloc(encodedlen);
|
||||
output = (char *)malloc(encodedlen);
|
||||
if (output == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -189,12 +189,12 @@ int rpmBase64Decode(const char *in, void **out, size_t *outlen)
|
|||
|
||||
outcnt = (outcnt / 4) * 3;
|
||||
|
||||
*out = malloc(outcnt + 1); /* base64_decode_block can write one extra character */
|
||||
*out = (char *)malloc(outcnt + 1); /* base64_decode_block can write one extra character */
|
||||
|
||||
if (*out == NULL)
|
||||
return 4;
|
||||
|
||||
*outlen = base64_decode_block(in, inptr - in, *out);
|
||||
*outlen = base64_decode_block(in, inptr - in, (char *)*out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ static int findID(rpmDigestBundle bundle, int id)
|
|||
|
||||
rpmDigestBundle rpmDigestBundleNew(void)
|
||||
{
|
||||
rpmDigestBundle bundle = xcalloc(1, sizeof(*bundle));
|
||||
rpmDigestBundle bundle = (rpmDigestBundle)xcalloc(1, sizeof(*bundle));
|
||||
return bundle;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ DIGEST_CTX rpmDigestInit(int hashalgo, rpmDigestFlags flags)
|
|||
if (!gcryalgo || gcry_md_open(&h, gcryalgo, 0) != 0)
|
||||
return NULL;
|
||||
|
||||
ctx = xcalloc(1, sizeof(*ctx));
|
||||
ctx = (DIGEST_CTX)xcalloc(1, sizeof(*ctx));
|
||||
ctx->flags = flags;
|
||||
ctx->algo = hashalgo;
|
||||
ctx->h = h;
|
||||
|
@ -129,7 +129,7 @@ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
|
|||
gcry_md_hd_t h;
|
||||
if (gcry_md_copy(&h, octx->h))
|
||||
return NULL;
|
||||
nctx = memcpy(xcalloc(1, sizeof(*nctx)), octx, sizeof(*nctx));
|
||||
nctx = (DIGEST_CTX)memcpy(xcalloc(1, sizeof(*nctx)), octx, sizeof(*nctx));
|
||||
nctx->h = h;
|
||||
}
|
||||
return nctx;
|
||||
|
|
|
@ -31,7 +31,7 @@ DIGEST_CTX rpmDigestDup(DIGEST_CTX octx)
|
|||
if (!octx) return NULL;
|
||||
|
||||
DIGEST_CTX nctx = NULL;
|
||||
nctx = xcalloc(1, sizeof(*nctx));
|
||||
nctx = (DIGEST_CTX)xcalloc(1, sizeof(*nctx));
|
||||
|
||||
nctx->flags = octx->flags;
|
||||
nctx->algo = octx->algo;
|
||||
|
@ -83,7 +83,7 @@ size_t rpmDigestLength(int hashalgo)
|
|||
|
||||
DIGEST_CTX rpmDigestInit(int hashalgo, rpmDigestFlags flags)
|
||||
{
|
||||
DIGEST_CTX ctx = xcalloc(1, sizeof(*ctx));
|
||||
DIGEST_CTX ctx = (DIGEST_CTX)xcalloc(1, sizeof(*ctx));
|
||||
|
||||
ctx->md_ctx = EVP_MD_CTX_new();
|
||||
if (!ctx->md_ctx) {
|
||||
|
@ -121,13 +121,13 @@ int rpmDigestUpdate(DIGEST_CTX ctx, const void *data, size_t len)
|
|||
int rpmDigestFinal(DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)
|
||||
{
|
||||
int ret;
|
||||
unsigned char *digest = NULL;
|
||||
uint8_t *digest = NULL;
|
||||
unsigned int digestlen;
|
||||
|
||||
if (ctx == NULL) return -1;
|
||||
|
||||
digestlen = EVP_MD_CTX_size(ctx->md_ctx);
|
||||
digest = xcalloc(digestlen, sizeof(*digest));
|
||||
digest = (uint8_t *)xcalloc(digestlen, sizeof(*digest));
|
||||
|
||||
ret = EVP_DigestFinal_ex(ctx->md_ctx, digest, &digestlen);
|
||||
if (ret != 1) goto done;
|
||||
|
|
|
@ -281,7 +281,7 @@ static char *getValuebuf(ParseState state, const char *p, size_t size)
|
|||
char *temp;
|
||||
if ((state->flags & RPMEXPR_DISCARD) != 0)
|
||||
size = 0;
|
||||
temp = xmalloc(size + 1);
|
||||
temp = (char *)xmalloc(size + 1);
|
||||
memcpy(temp, p, size);
|
||||
temp[size] = '\0';
|
||||
if (size && (state->flags & RPMEXPR_EXPAND) != 0) {
|
||||
|
@ -531,7 +531,7 @@ static Value doLuaFunction(ParseState state, const char *name, int argc, Value *
|
|||
if (state->flags & RPMEXPR_DISCARD)
|
||||
return valueMakeString(xstrdup(""));
|
||||
args = rpmhookArgsNew(argc);
|
||||
argt = xmalloc(argc + 1);
|
||||
argt = (char *)xmalloc(argc + 1);
|
||||
for (i = 0; i < argc; i++) {
|
||||
switch (argv[i]->type) {
|
||||
case VALUE_TYPE_INTEGER:
|
||||
|
@ -796,7 +796,7 @@ static Value doAddSubtract(ParseState state)
|
|||
goto err;
|
||||
}
|
||||
|
||||
copy = xmalloc(strlen(v1->data.s) + strlen(v2->data.s) + 1);
|
||||
copy = (char *)xmalloc(strlen(v1->data.s) + strlen(v2->data.s) + 1);
|
||||
(void) stpcpy( stpcpy(copy, v1->data.s), v2->data.s);
|
||||
|
||||
valueSetString(v1, copy);
|
||||
|
|
|
@ -200,7 +200,7 @@ static int Pdir(lua_State *L) /** dir([path]) */
|
|||
|
||||
static int aux_files(lua_State *L)
|
||||
{
|
||||
DIR *d = lua_touserdata(L, lua_upvalueindex(1));
|
||||
DIR *d = (DIR *)lua_touserdata(L, lua_upvalueindex(1));
|
||||
struct dirent *entry;
|
||||
if (d == NULL) return luaL_error(L, "attempt to use closed dir");
|
||||
entry = readdir(d);
|
||||
|
@ -346,7 +346,7 @@ static int Pexec(lua_State *L) /** exec(path,[args]) */
|
|||
|
||||
rpmSetCloseOnExec();
|
||||
|
||||
argv = malloc((n+1)*sizeof(char*));
|
||||
argv = (char **)malloc((n+1)*sizeof(char*));
|
||||
if (argv==NULL) return luaL_error(L,"not enough memory");
|
||||
argv[0] = (char*)path;
|
||||
for (i=1; i<n; i++) argv[i] = (char*)luaL_checkstring(L, i+1);
|
||||
|
@ -399,8 +399,8 @@ static int Pputenv(lua_State *L) /** putenv(string) */
|
|||
#ifdef HAVE_PUTENV
|
||||
size_t l;
|
||||
const char *s=luaL_checklstring(L, 1, &l);
|
||||
char *e=malloc(++l);
|
||||
return pushresult(L, (e==NULL) ? -1 : putenv(memcpy(e,s,l)), s);
|
||||
char *e=(char *)malloc(++l);
|
||||
return pushresult(L, (e==NULL) ? -1 : putenv((char *)memcpy(e,s,l)), s);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
|
@ -563,7 +563,7 @@ static int Pgetlogin(lua_State *L) /** getlogin() */
|
|||
|
||||
static int Fgetpasswd(lua_State *L, int i, const void *data)
|
||||
{
|
||||
const struct passwd *p=data;
|
||||
const struct passwd *p= (const struct passwd *)data;
|
||||
switch (i)
|
||||
{
|
||||
case 0: lua_pushstring(L, p->pw_name); break;
|
||||
|
@ -648,7 +648,7 @@ struct mytimes
|
|||
|
||||
static int Ftimes(lua_State *L, int i, const void *data)
|
||||
{
|
||||
const struct mytimes *t=data;
|
||||
const struct mytimes *t=(const struct mytimes *)data;
|
||||
switch (i)
|
||||
{
|
||||
case 0: pushtime(L, t->t.tms_utime); break;
|
||||
|
@ -684,7 +684,7 @@ struct mystat
|
|||
|
||||
static int Fstat(lua_State *L, int i, const void *data)
|
||||
{
|
||||
const struct mystat *s=data;
|
||||
const struct mystat *s=(const struct mystat *)data;
|
||||
switch (i)
|
||||
{
|
||||
case 0: lua_pushstring(L, s->mode); break;
|
||||
|
@ -755,7 +755,7 @@ static const int Kpathconf[] =
|
|||
|
||||
static int Fpathconf(lua_State *L, int i, const void *data)
|
||||
{
|
||||
const char *path=data;
|
||||
const char *path=(const char *)data;
|
||||
lua_pushnumber(L, pathconf(path, Kpathconf[i]));
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@ expandThis(rpmMacroBuf mb, const char * src, size_t slen, char **target, int *fl
|
|||
|
||||
static rpmMacroBuf mbCreate(rpmMacroContext mc, int flags)
|
||||
{
|
||||
rpmMacroBuf mb = xcalloc(1, sizeof(*mb));
|
||||
rpmMacroBuf mb = (rpmMacroBuf)xcalloc(1, sizeof(*mb));
|
||||
mb->buf = NULL;
|
||||
mb->depth = mc->depth;
|
||||
mb->level = mc->level;
|
||||
|
@ -477,7 +477,7 @@ static rpmMacroBuf mbCreate(rpmMacroContext mc, int flags)
|
|||
static void mbAllocBuf(rpmMacroBuf mb, size_t slen)
|
||||
{
|
||||
size_t blen = MACROBUFSIZ + slen;
|
||||
mb->buf = xmalloc(blen + 1);
|
||||
mb->buf = (char *)xmalloc(blen + 1);
|
||||
mb->buf[0] = '\0';
|
||||
mb->tpos = 0;
|
||||
mb->nb = blen;
|
||||
|
@ -684,7 +684,7 @@ doDefine(rpmMacroBuf mb, const char * se, int level, int expandbody, size_t *par
|
|||
{
|
||||
const char *start = se;
|
||||
const char *s = se;
|
||||
char *buf = xmalloc(strlen(s) + 3); /* Some leeway for termination issues... */
|
||||
char *buf = (char *)xmalloc(strlen(s) + 3); /* Some leeway for termination issues... */
|
||||
char *n = buf, *ne = n;
|
||||
char *o = NULL, *oe;
|
||||
char *b, *be, *ebody = NULL;
|
||||
|
@ -859,7 +859,7 @@ static void doDump(rpmMacroBuf mb, rpmMacroEntry me, ARGV_t argv, size_t *parsed
|
|||
|
||||
static int mbopt(int c, const char *oarg, int oint, void *data)
|
||||
{
|
||||
rpmMacroBuf mb = data;
|
||||
rpmMacroBuf mb = (rpmMacroBuf)data;
|
||||
char *name = NULL, *body = NULL;
|
||||
|
||||
/* Define option macros. */
|
||||
|
@ -1028,7 +1028,7 @@ char *unsplitQuoted(ARGV_const_t av, const char *sep)
|
|||
seplen = av[1] ? strlen(sep) : 0;
|
||||
for (av2 = av; *av2; av2++)
|
||||
len += strlen(*av2) + 2 + seplen;
|
||||
b = buf = xmalloc(len + 1 - seplen);
|
||||
b = buf = (char *)xmalloc(len + 1 - seplen);
|
||||
for (av2 = av; *av2; av2++) {
|
||||
*b++ = qchar;
|
||||
strcpy(b, *av2);
|
||||
|
@ -1848,7 +1848,7 @@ static void pushMacroAny(rpmMacroContext mc,
|
|||
rpmMacroEntry *mep = findEntry(mc, n, 0, &pos);
|
||||
if (mep) {
|
||||
/* entry with shared name */
|
||||
me = xmalloc(mesize);
|
||||
me = (rpmMacroEntry)xmalloc(mesize);
|
||||
p = me->arena;
|
||||
/* set name */
|
||||
me->name = (*mep)->name;
|
||||
|
@ -1857,7 +1857,7 @@ static void pushMacroAny(rpmMacroContext mc,
|
|||
/* entry with new name */
|
||||
mep = newEntry(mc, pos);
|
||||
size_t nlen = strlen(n);
|
||||
me = xmalloc(mesize + nlen + 1);
|
||||
me = (rpmMacroEntry)xmalloc(mesize + nlen + 1);
|
||||
p = me->arena;
|
||||
/* copy name */
|
||||
me->name = p;
|
||||
|
@ -1873,7 +1873,7 @@ static void pushMacroAny(rpmMacroContext mc,
|
|||
p += blen + 1;
|
||||
/* copy options */
|
||||
if (olen)
|
||||
me->opts = memcpy(p, o, olen + 1);
|
||||
me->opts = (char *)memcpy(p, o, olen + 1);
|
||||
else
|
||||
me->opts = o ? "" : NULL;
|
||||
/* initialize */
|
||||
|
@ -1920,7 +1920,7 @@ static void popMacro(rpmMacroContext mc, const char * n)
|
|||
|
||||
static int defineMacro(rpmMacroContext mc, const char * macro, int level)
|
||||
{
|
||||
rpmMacroBuf mb = xcalloc(1, sizeof(*mb));
|
||||
rpmMacroBuf mb = (rpmMacroBuf)xcalloc(1, sizeof(*mb));
|
||||
int rc;
|
||||
size_t parsed = 0;
|
||||
|
||||
|
@ -1935,7 +1935,7 @@ static int defineMacro(rpmMacroContext mc, const char * macro, int level)
|
|||
static void linenoMacro(rpmMacroBuf mb,
|
||||
rpmMacroEntry me, ARGV_t margs, size_t *parsed)
|
||||
{
|
||||
int *lineno = rpmMacroEntryPriv(me);
|
||||
int *lineno = (int *)rpmMacroEntryPriv(me);
|
||||
if (lineno) {
|
||||
char lnobuf[16];
|
||||
snprintf(lnobuf, sizeof(lnobuf), "%d", *lineno);
|
||||
|
@ -1947,7 +1947,7 @@ static int loadMacroFile(rpmMacroContext mc, const char * fn)
|
|||
{
|
||||
FILE *fd = fopen(fn, "r");
|
||||
size_t blen = MACROBUFSIZ;
|
||||
char *buf = xmalloc(blen);
|
||||
char *buf = (char *)xmalloc(blen);
|
||||
int rc = -1;
|
||||
int nfailed = 0;
|
||||
int lineno = 0;
|
||||
|
@ -2241,7 +2241,7 @@ rpmExpand(const char *arg, ...)
|
|||
blen += strlen(s);
|
||||
va_end(ap);
|
||||
|
||||
buf = xmalloc(blen + 1);
|
||||
buf = (char *)xmalloc(blen + 1);
|
||||
buf[0] = '\0';
|
||||
|
||||
va_start(ap, arg);
|
||||
|
|
|
@ -25,7 +25,7 @@ int rpmDoDigest(int algo, const char * fn,int asAscii, unsigned char * digest)
|
|||
{
|
||||
unsigned char * dig = NULL;
|
||||
size_t diglen, buflen = 32 * BUFSIZ;
|
||||
unsigned char *buf = xmalloc(buflen);
|
||||
unsigned char *buf = (unsigned char *)xmalloc(buflen);
|
||||
int rc = 0;
|
||||
|
||||
FD_t fd = Fopen(fn, "r.ufdio");
|
||||
|
@ -394,7 +394,7 @@ static char * rpmEscapeChars(const char *s, const char *accept, int (*fn)(int))
|
|||
}
|
||||
nb++;
|
||||
|
||||
t = te = xmalloc(nb);
|
||||
t = te = (char *)xmalloc(nb);
|
||||
for (se = s; *se; se++) {
|
||||
if ((accept && strchr(accept, *se)) || (fn && fn(*se)))
|
||||
*te++ = '\\';
|
||||
|
|
|
@ -137,7 +137,7 @@ static void rpmhookTableAddItem(rpmhookTable *table, const char *name,
|
|||
(*table)->used++;
|
||||
}
|
||||
while (*item) item = &(*item)->next;
|
||||
*item = xcalloc(1, sizeof(**item));
|
||||
*item = (rpmhookItem)xcalloc(1, sizeof(**item));
|
||||
(*item)->func = func;
|
||||
(*item)->data = data;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ static void fdSetFdno(FD_t fd, int fdno)
|
|||
|
||||
static void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno)
|
||||
{
|
||||
FDSTACK_t fps = xcalloc(1, sizeof(*fps));
|
||||
FDSTACK_t fps = (FDSTACK_t) xcalloc(1, sizeof(*fps));
|
||||
fps->io = io;
|
||||
fps->fp = fp;
|
||||
fps->fdno = fdno;
|
||||
|
@ -335,12 +335,12 @@ FD_t fdFree( FD_t fd)
|
|||
|
||||
static FD_t fdNew(int fdno, const char *descr)
|
||||
{
|
||||
FD_t fd = xcalloc(1, sizeof(*fd));
|
||||
FD_t fd = (FD_t)xcalloc(1, sizeof(*fd));
|
||||
fd->nrefs = 0;
|
||||
fd->flags = 0;
|
||||
fd->magic = FDMAGIC;
|
||||
fd->urlType = URL_IS_UNKNOWN;
|
||||
fd->stats = xcalloc(1, sizeof(*fd->stats));
|
||||
fd->stats = (FDSTAT_t)xcalloc(1, sizeof(*fd->stats));
|
||||
fd->digests = NULL;
|
||||
fd->descr = descr ? xstrdup(descr) : NULL;
|
||||
|
||||
|
@ -771,7 +771,7 @@ static LZFILE *lzopen_internal(const char *mode, int fd, int xz)
|
|||
fp = fdopen(fd, encoding ? "w" : "r");
|
||||
if (!fp)
|
||||
return NULL;
|
||||
lzfile = calloc(1, sizeof(*lzfile));
|
||||
lzfile = (LZFILE *)calloc(1, sizeof(*lzfile));
|
||||
lzfile->file = fp;
|
||||
lzfile->encoding = encoding;
|
||||
lzfile->eof = 0;
|
||||
|
@ -858,7 +858,7 @@ static ssize_t lzread(LZFILE *lzfile, void *buf, size_t len)
|
|||
return -1;
|
||||
if (lzfile->eof)
|
||||
return 0;
|
||||
lzfile->strm.next_out = buf;
|
||||
lzfile->strm.next_out = (uint8_t *)buf;
|
||||
lzfile->strm.avail_out = len;
|
||||
for (;;) {
|
||||
if (!lzfile->strm.avail_in) {
|
||||
|
@ -889,7 +889,7 @@ static ssize_t lzwrite(LZFILE *lzfile, void *buf, size_t len)
|
|||
return -1;
|
||||
if (!len)
|
||||
return 0;
|
||||
lzfile->strm.next_in = buf;
|
||||
lzfile->strm.next_in = (uint8_t *)buf;
|
||||
lzfile->strm.avail_in = len;
|
||||
for (;;) {
|
||||
lzfile->strm.next_out = lzfile->buf;
|
||||
|
@ -1131,7 +1131,7 @@ static rpmzstd rpmzstdNew(int fdno, const char *fmode)
|
|||
zstd->level = level;
|
||||
zstd->fp = fp;
|
||||
zstd->nb = nb;
|
||||
zstd->b = xmalloc(nb);
|
||||
zstd->b = (uint8_t *)xmalloc(nb);
|
||||
|
||||
return zstd;
|
||||
|
||||
|
@ -1700,7 +1700,7 @@ int rpmioSlurp(const char * fn, uint8_t ** bp, ssize_t * blenp)
|
|||
blen = (size >= 0 ? size : blenmax);
|
||||
if (blen) {
|
||||
int nb;
|
||||
b = xmalloc(blen+1);
|
||||
b = (uint8_t *)xmalloc(blen+1);
|
||||
b[0] = '\0';
|
||||
nb = Fread(b, sizeof(*b), blen, fd);
|
||||
if (Ferror(fd) || (size > 0 && nb != blen)) {
|
||||
|
|
|
@ -39,7 +39,7 @@ static int keyidcmp(const void *k1, const void *k2)
|
|||
|
||||
rpmKeyring rpmKeyringNew(void)
|
||||
{
|
||||
rpmKeyring keyring = xcalloc(1, sizeof(*keyring));
|
||||
rpmKeyring keyring = (rpmKeyring)xcalloc(1, sizeof(*keyring));
|
||||
keyring->keys = NULL;
|
||||
keyring->numkeys = 0;
|
||||
keyring->nrefs = 1;
|
||||
|
@ -73,7 +73,7 @@ static rpmPubkey rpmKeyringFindKeyid(rpmKeyring keyring, rpmPubkey key)
|
|||
{
|
||||
rpmPubkey *found = NULL;
|
||||
if (key && keyring->keys) {
|
||||
found = bsearch(&key, keyring->keys, keyring->numkeys,
|
||||
found = (rpmPubkey *)bsearch(&key, keyring->keys, keyring->numkeys,
|
||||
sizeof(*keyring->keys), keyidcmp);
|
||||
}
|
||||
return found ? *found : NULL;
|
||||
|
@ -142,8 +142,8 @@ rpmPubkey rpmPubkeyNew(const uint8_t *pkt, size_t pktlen)
|
|||
if (pgpPrtParams(pkt, pktlen, PGPTAG_PUBLIC_KEY, &pgpkey))
|
||||
goto exit;
|
||||
|
||||
key = xcalloc(1, sizeof(*key));
|
||||
key->pkt = xmalloc(pktlen);
|
||||
key = (rpmPubkey)xcalloc(1, sizeof(*key));
|
||||
key->pkt = (uint8_t *)xmalloc(pktlen);
|
||||
key->pktlen = pktlen;
|
||||
key->pgpkey = pgpkey;
|
||||
key->nrefs = 1;
|
||||
|
@ -165,10 +165,10 @@ rpmPubkey *rpmGetSubkeys(rpmPubkey mainkey, int *count)
|
|||
if (mainkey && !pgpPrtParamsSubkeys(mainkey->pkt, mainkey->pktlen,
|
||||
mainkey->pgpkey, &pgpsubkeys, &pgpsubkeysCount)) {
|
||||
|
||||
subkeys = xmalloc(pgpsubkeysCount * sizeof(*subkeys));
|
||||
subkeys = (rpmPubkey *)xmalloc(pgpsubkeysCount * sizeof(*subkeys));
|
||||
|
||||
for (i = 0; i < pgpsubkeysCount; i++) {
|
||||
rpmPubkey subkey = xcalloc(1, sizeof(*subkey));
|
||||
rpmPubkey subkey = (rpmPubkey)xcalloc(1, sizeof(*subkey));
|
||||
subkeys[i] = subkey;
|
||||
|
||||
/* Packets with all subkeys already stored in main key */
|
||||
|
|
|
@ -445,14 +445,14 @@ void rpmlog (int code, const char *fmt, ...)
|
|||
if (n >= -1) {
|
||||
struct rpmlogRec_s rec;
|
||||
size_t nb = n + 1;
|
||||
char *msg = xmalloc(nb);
|
||||
char *msg = (char *)xmalloc(nb);
|
||||
|
||||
va_start(ap, fmt);
|
||||
n = vsnprintf(msg, nb, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
rec.code = code;
|
||||
rec.pri = pri;
|
||||
rec.pri = (rpmlogLvl)pri;
|
||||
rec.message = msg;
|
||||
|
||||
dolog(&rec, saverec);
|
||||
|
|
|
@ -181,7 +181,7 @@ void * rpmluaGetLua(rpmlua lua)
|
|||
void rpmluaPushPrintBuffer(rpmlua lua)
|
||||
{
|
||||
INITSTATE(lua);
|
||||
rpmluapb prbuf = xcalloc(1, sizeof(*prbuf));
|
||||
rpmluapb prbuf = (rpmluapb)xcalloc(1, sizeof(*prbuf));
|
||||
prbuf->buf = NULL;
|
||||
prbuf->alloced = 0;
|
||||
prbuf->used = 0;
|
||||
|
@ -224,7 +224,7 @@ int rpmluaCheckScript(rpmlua lua, const char *script, const char *name)
|
|||
|
||||
static int luaopt(int c, const char *oarg, int oint, void *data)
|
||||
{
|
||||
lua_State *L = data;
|
||||
lua_State *L = (lua_State *)data;
|
||||
char key[2] = { (char)c, '\0' };
|
||||
|
||||
lua_pushstring(L, oarg ? oarg : "");
|
||||
|
@ -527,7 +527,7 @@ static int rpm_b64decode(lua_State *L)
|
|||
void *data = NULL;
|
||||
size_t len = 0;
|
||||
if (rpmBase64Decode(str, &data, &len) == 0) {
|
||||
lua_pushlstring(L, data, len);
|
||||
lua_pushlstring(L, (char *)data, len);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ static int rpm_register(lua_State *L)
|
|||
(void) luaL_argerror(L, 2, "function expected");
|
||||
} else {
|
||||
rpmluaHookData hookdata =
|
||||
lua_newuserdata(L, sizeof(struct rpmluaHookData_s));
|
||||
(rpmluaHookData)lua_newuserdata(L, sizeof(struct rpmluaHookData_s));
|
||||
lua_pushvalue(L, -1);
|
||||
hookdata->dataRef = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
lua_pushvalue(L, 2);
|
||||
|
@ -818,7 +818,7 @@ static int rpm_execute(lua_State *L)
|
|||
int status;
|
||||
pid_t pid;
|
||||
|
||||
char **argv = malloc((n + 1) * sizeof(char *));
|
||||
char **argv = (char **)malloc((n + 1) * sizeof(char *));
|
||||
if (argv == NULL)
|
||||
return luaL_error(L, "not enough memory");
|
||||
argv[0] = (char *)file;
|
||||
|
@ -903,8 +903,8 @@ static int rpm_glob(lua_State *L)
|
|||
static int newinstance(lua_State *L, const char *name, void *p)
|
||||
{
|
||||
if (p != NULL) {
|
||||
intptr_t **pp = lua_newuserdata(L, sizeof(*pp));
|
||||
*pp = p;
|
||||
intptr_t **pp = (intptr_t **)lua_newuserdata(L, sizeof(*pp));
|
||||
*pp = (intptr_t *)p;
|
||||
luaL_getmetatable(L, name);
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ static int createclass(lua_State *L, const char *name, const luaL_Reg *methods)
|
|||
|
||||
static rpmver * checkver(lua_State *L, int ix)
|
||||
{
|
||||
rpmver *vp = lua_touserdata(L, ix);
|
||||
rpmver *vp = (rpmver *)lua_touserdata(L, ix);
|
||||
luaL_checkudata(L, ix, "rpm.ver");
|
||||
return vp;
|
||||
}
|
||||
|
@ -1016,7 +1016,7 @@ static const luaL_Reg ver_m[] = {
|
|||
|
||||
static FD_t * checkfd(lua_State *L, int ix)
|
||||
{
|
||||
FD_t *fdp = lua_touserdata(L, ix);
|
||||
FD_t *fdp = (FD_t *)lua_touserdata(L, ix);
|
||||
luaL_checkudata(L, ix, "rpm.fd");
|
||||
return fdp;
|
||||
}
|
||||
|
@ -1168,7 +1168,7 @@ static const luaL_Reg fd_m[] = {
|
|||
|
||||
static rpmMacroContext *checkmc(lua_State *L, int ix)
|
||||
{
|
||||
rpmMacroContext *mc = lua_touserdata(L, ix);
|
||||
rpmMacroContext *mc = (rpmMacroContext *)lua_touserdata(L, ix);
|
||||
luaL_checkudata(L, ix, "rpm.mc");
|
||||
return mc;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
char *rpmhex(const uint8_t *p, size_t plen)
|
||||
{
|
||||
char *t, *str;
|
||||
str = t = xmalloc(plen * 2 + 1);
|
||||
str = t = (char *)xmalloc(plen * 2 + 1);
|
||||
static char const hex[] = "0123456789abcdef";
|
||||
while (plen-- > 0) {
|
||||
size_t i;
|
||||
|
@ -81,7 +81,7 @@ int rvasprintf(char **strp, const char *fmt, va_list ap)
|
|||
|
||||
if (n >= -1) {
|
||||
size_t nb = n + 1;
|
||||
p = xmalloc(nb);
|
||||
p = (char *)xmalloc(nb);
|
||||
va_copy(aq, ap);
|
||||
n = vsnprintf(p, nb, fmt, aq);
|
||||
va_end(aq);
|
||||
|
|
|
@ -124,9 +124,9 @@ static poolHash poolHashCreate(int numBuckets)
|
|||
{
|
||||
poolHash ht;
|
||||
|
||||
ht = xmalloc(sizeof(*ht));
|
||||
ht = (poolHash)xmalloc(sizeof(*ht));
|
||||
ht->numBuckets = numBuckets;
|
||||
ht->buckets = xcalloc(numBuckets, sizeof(*ht->buckets));
|
||||
ht->buckets = (poolHashBucket *)xcalloc(numBuckets, sizeof(*ht->buckets));
|
||||
ht->keyCount = 0;
|
||||
return ht;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ static poolHash poolHashCreate(int numBuckets)
|
|||
static void poolHashResize(rpmstrPool pool, int numBuckets)
|
||||
{
|
||||
poolHash ht = pool->hash;
|
||||
poolHashBucket * buckets = xcalloc(numBuckets, sizeof(*ht->buckets));
|
||||
poolHashBucket * buckets = (poolHashBucket *)xcalloc(numBuckets, sizeof(*ht->buckets));
|
||||
|
||||
for (int i=0; i<ht->numBuckets; i++) {
|
||||
if (!ht->buckets[i].keyid) continue;
|
||||
|
@ -244,16 +244,16 @@ static void rpmstrPoolRehash(rpmstrPool pool)
|
|||
|
||||
rpmstrPool rpmstrPoolCreate(void)
|
||||
{
|
||||
rpmstrPool pool = xcalloc(1, sizeof(*pool));
|
||||
rpmstrPool pool = (rpmstrPool)xcalloc(1, sizeof(*pool));
|
||||
|
||||
pool->offs_alloced = STROFFS_CHUNK;
|
||||
pool->offs = xcalloc(pool->offs_alloced, sizeof(*pool->offs));
|
||||
pool->offs = (const char **)xcalloc(pool->offs_alloced, sizeof(*pool->offs));
|
||||
|
||||
pool->chunks_allocated = STRDATA_CHUNKS;
|
||||
pool->chunks = xcalloc(pool->chunks_allocated, sizeof(*pool->chunks));
|
||||
pool->chunks = (char **)xcalloc(pool->chunks_allocated, sizeof(*pool->chunks));
|
||||
pool->chunks_size = 1;
|
||||
pool->chunk_allocated = STRDATA_CHUNK;
|
||||
pool->chunks[pool->chunks_size] = xcalloc(1, pool->chunk_allocated);
|
||||
pool->chunks[pool->chunks_size] = (char *)xcalloc(1, pool->chunk_allocated);
|
||||
pool->offs[1] = pool->chunks[pool->chunks_size];
|
||||
|
||||
rpmstrPoolRehash(pool);
|
||||
|
@ -353,12 +353,12 @@ static rpmsid rpmstrPoolPut(rpmstrPool pool, const char *s, size_t slen, unsigne
|
|||
pool->chunk_allocated = 2 * ssize;
|
||||
}
|
||||
|
||||
pool->chunks[pool->chunks_size] = xcalloc(1, pool->chunk_allocated);
|
||||
pool->chunks[pool->chunks_size] = (char *)xcalloc(1, pool->chunk_allocated);
|
||||
pool->chunk_used = 0;
|
||||
}
|
||||
|
||||
/* Copy the string into current chunk, ensure termination */
|
||||
t = memcpy(pool->chunks[pool->chunks_size] + pool->chunk_used, s, slen);
|
||||
t = (char *)memcpy(pool->chunks[pool->chunks_size] + pool->chunk_used, s, slen);
|
||||
t[slen] = '\0';
|
||||
pool->chunk_used += ssize;
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ rpmver rpmverParse(const char *evr)
|
|||
rpmver rv = NULL;
|
||||
if (evr && *evr) {
|
||||
size_t evrlen = strlen(evr) + 1;
|
||||
rv = xmalloc(sizeof(*rv) + evrlen);
|
||||
rv = (rpmver)xmalloc(sizeof(*rv) + evrlen);
|
||||
memcpy(rv->arena, evr, evrlen);
|
||||
parseEVR(rv->arena, &rv->e, &rv->v, &rv->r);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ rpmver rpmverNew(const char *e, const char *v, const char *r)
|
|||
size_t nb = strlen(v) + 1;
|
||||
nb += (e != NULL) ? strlen(e) + 1 : 0;
|
||||
nb += (r != NULL) ? strlen(r) + 1 : 0;
|
||||
rv = xmalloc(sizeof(*rv) + nb);
|
||||
rv = (rpmver)xmalloc(sizeof(*rv) + nb);
|
||||
|
||||
rv->e = NULL;
|
||||
rv->v = NULL;
|
||||
|
|
Loading…
Reference in New Issue