summaryrefslogtreecommitdiff
path: root/lib/fsm.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-04-17 19:18:28 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-04-17 19:18:28 +0300
commit189dec7ba940dc13caba43fa5fb151645ce77e50 (patch)
treee2698bfc8ad80076f995a73fc66bea7cf41c70ce /lib/fsm.c
parent00629aa636ab54cabdb4bb7dcd3698ead2024be7 (diff)
downloadlibrpm-tizen-189dec7ba940dc13caba43fa5fb151645ce77e50.tar.gz
librpm-tizen-189dec7ba940dc13caba43fa5fb151645ce77e50.tar.bz2
librpm-tizen-189dec7ba940dc13caba43fa5fb151645ce77e50.zip
Push fsm archive size down to the only caller who cares
- Archive size is only relevant for build code, no need for tracking this in the big struct. Just return the archiveSize at end of build process.
Diffstat (limited to 'lib/fsm.c')
-rw-r--r--lib/fsm.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/fsm.c b/lib/fsm.c
index 57a38821e..210b726d8 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -103,7 +103,6 @@ struct fsm_s {
int ix; /*!< Current file iterator index. */
hardLink_t links; /*!< Pending hard linked file(s). */
hardLink_t li; /*!< Current hard linked file(s). */
- rpm_loff_t * archiveSize; /*!< Pointer to archive size. */
char ** failedFile; /*!< First file name that failed. */
const char * osuffix; /*!< Old, preserved, file suffix. */
const char * nsuffix; /*!< New, created, file suffix. */
@@ -582,7 +581,7 @@ static hardLink_t freeHardLink(hardLink_t li)
static int fsmSetup(FSM_t fsm, fileStage goal,
rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
- rpm_loff_t * archiveSize, char ** failedFile)
+ char ** failedFile)
{
int rc = 0;
int isSrc = rpmteIsSource(te);
@@ -612,9 +611,6 @@ static int fsmSetup(FSM_t fsm, fileStage goal,
fsm->buf = xmalloc(fsm->bufsize);
}
- fsm->archiveSize = archiveSize;
- if (fsm->archiveSize)
- *fsm->archiveSize = 0;
fsm->failedFile = failedFile;
if (fsm->failedFile)
*fsm->failedFile = NULL;
@@ -629,9 +625,6 @@ static int fsmTeardown(FSM_t fsm)
{
int rc = fsm->rc;
- if (fsm->archiveSize && rc == 0)
- *fsm->archiveSize = rpmcpioTell(fsm->archive);
-
if (!rc) {
/* Check for hard links missing from payload. */
while ((fsm->li = fsm->links) != NULL) {
@@ -1714,7 +1707,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
int rc = 0;
int ec = 0;
- rc = fsmSetup(fsm, FSM_PKGINSTALL, ts, te, fi, cfd, NULL, failedFile);
+ rc = fsmSetup(fsm, FSM_PKGINSTALL, ts, te, fi, cfd, failedFile);
/* transaction id used for temporary path suffix while installing */
rasprintf(&fsm->suffix, ";%08x", (unsigned)rpmtsGetTid(ts));
@@ -1870,7 +1863,7 @@ int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfi fi,
int rc = 0;
int ec = 0;
- rc = fsmSetup(fsm, FSM_PKGERASE, ts, te, fi, NULL, NULL, failedFile);
+ rc = fsmSetup(fsm, FSM_PKGERASE, ts, te, fi, NULL, failedFile);
while (!rc) {
/* Clean fsm, free'ing memory. */
@@ -1949,7 +1942,7 @@ int rpmPackageFilesArchive(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
int rc = 0;
int ec = 0;
- rc = fsmSetup(fsm, FSM_PKGBUILD, ts, te, fi, cfd, archiveSize, failedFile);
+ rc = fsmSetup(fsm, FSM_PKGBUILD, ts, te, fi, cfd, failedFile);
while (!rc) {
fsmReset(fsm);
@@ -1991,6 +1984,9 @@ int rpmPackageFilesArchive(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
if (!rc)
rc = writeLinks(fsm);
+ if (archiveSize)
+ *archiveSize = (rc == 0) ? rpmcpioTell(fsm->archive) : 0;
+
ec = fsmTeardown(fsm);
/* Return the relevant code: if setup failed, teardown doesn't matter */