From: Panu Matilainen Date: Wed, 18 May 2011 08:55:59 +0000 (+0300) Subject: Simplify rpmio flags handling in writeRPM() / cpio_doio() X-Git-Tag: tznext/4.11.0.1.tizen20130304~1151 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=765cbedce448f0e65741de673ea1cd271b4f6011;p=tools%2Flibrpm-tizen.git Simplify rpmio flags handling in writeRPM() / cpio_doio() - The payload macros are already expanded in writeRPM(), no point re-expanding in cpio_doio() and handle fallback to default gzdio in writeRPM() already in case the payload is not set in config or is bogus. Also rpmExpand() cannot return NULL so there's no point in checking for that. --- diff --git a/build/pack.c b/build/pack.c index 5f27d24..4aedebf 100644 --- a/build/pack.c +++ b/build/pack.c @@ -35,8 +35,7 @@ typedef struct cpioSourceArchive_s { /** * @todo Create transaction set *much* earlier. */ -static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, - const char * fmodeMacro) +static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, const char * fmodeMacro) { rpmts ts = NULL; rpmfi fi = csa->cpioList; @@ -46,13 +45,9 @@ static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa, FD_t cfd; rpmRC rc = RPMRC_OK; int i; - char *fmode = rpmExpand(fmodeMacro, NULL); - if (!(fmode && fmode[0] == 'w')) - fmode = xstrdup("w9.gzdio"); (void) Fflush(fdo); - cfd = Fdopen(fdDup(Fileno(fdo)), fmode); - fmode = _free(fmode); + cfd = Fdopen(fdDup(Fileno(fdo)), fmodeMacro); if (cfd == NULL) return RPMRC_FAIL; @@ -337,8 +332,9 @@ static rpmRC writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileNam else rpmio_flags = rpmExpand("%{?_binary_payload}", NULL); - if (!(rpmio_flags && *rpmio_flags)) { - rpmio_flags = _free(rpmio_flags); + /* If not configured or bogus, fall back to gz */ + if (rpmio_flags[0] != 'w') { + free(rpmio_flags); rpmio_flags = xstrdup("w9.gzdio"); } s = strchr(rpmio_flags, '.');