diff options
author | Panu Matilainen <Panu Matilainen pmatilai@redhat.com> | 2011-07-06 12:42:56 +0300 |
---|---|---|
committer | Panu Matilainen <Panu Matilainen pmatilai@redhat.com> | 2011-07-06 12:42:56 +0300 |
commit | da53e0d66e70dc20762ef00b360783f6e818ee19 (patch) | |
tree | 904e7571a10ce6f83654c5ef954cc2ee844a5a39 /sign | |
parent | 2a2979db51959368e8aecd1beafcbb9370aac10a (diff) | |
download | librpm-tizen-da53e0d66e70dc20762ef00b360783f6e818ee19.tar.gz librpm-tizen-da53e0d66e70dc20762ef00b360783f6e818ee19.tar.bz2 librpm-tizen-da53e0d66e70dc20762ef00b360783f6e818ee19.zip |
Make rpmLeadRead() return an allocated lead, fixup callers
- Requiring callers to allocate a lead "buffer" for reading into
is just DUMB (greetings to self back in 2008, sigh). This avoids
having to deal with freeing the lead in case the read failed, and
allows getting rid of rpmLeadNew() completely.
Diffstat (limited to 'sign')
-rw-r--r-- | sign/rpmgensig.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c index 4f1099f40..6b332541b 100644 --- a/sign/rpmgensig.c +++ b/sign/rpmgensig.c @@ -430,7 +430,7 @@ static int rpmSign(const char *rpm, int deleting, const char *passPhrase) { FD_t fd = NULL; FD_t ofd = NULL; - rpmlead lead; + rpmlead lead = NULL; char *sigtarget = NULL, *trpm = NULL; Header sigh = NULL; char * msg; @@ -443,9 +443,7 @@ static int rpmSign(const char *rpm, int deleting, const char *passPhrase) if (manageFile(&fd, rpm, O_RDONLY)) goto exit; - lead = rpmLeadNew(); - - if ((rc = rpmLeadRead(fd, lead)) == RPMRC_OK) { + if ((rc = rpmLeadRead(fd, &lead)) == RPMRC_OK) { const char *lmsg = NULL; rc = rpmLeadCheck(lead, &lmsg); if (rc != RPMRC_OK) @@ -453,7 +451,6 @@ static int rpmSign(const char *rpm, int deleting, const char *passPhrase) } if (rc != RPMRC_OK) { - lead = rpmLeadFree(lead); goto exit; } @@ -552,7 +549,6 @@ static int rpmSign(const char *rpm, int deleting, const char *passPhrase) /* Write the lead/signature of the output rpm */ rc = rpmLeadWrite(ofd, lead); - lead = rpmLeadFree(lead); if (rc != RPMRC_OK) { rpmlog(RPMLOG_ERR, _("%s: writeLead failed: %s\n"), trpm, Fstrerror(ofd)); @@ -584,6 +580,7 @@ exit: if (ofd) (void) closeFile(&ofd); rpmFreeSignature(sigh); + rpmLeadFree(lead); /* Clean up intermediate target */ if (sigtarget) { |