Move the install-only payload reading to the install-only code

- Besides simplifying the common path everything takes, this removes
  the need to map error returns back and forth when we can just
  detect the end of payload directly in the loop and break out.
This commit is contained in:
Panu Matilainen 2012-04-17 16:53:12 +03:00
parent 9e73ca9fcc
commit d852a56e17
1 changed files with 9 additions and 18 deletions

View File

@ -1410,17 +1410,6 @@ static int fsmInit(FSM_t fsm)
{
int rc = 0;
if (fsm->goal == FSM_PKGINSTALL) {
/* Read next payload header. */
rc = rpmcpioHeaderRead(fsm->archive, &(fsm->path), &(fsm->sb));
if (rc) return rc;
if (rstreq(fsm->path, CPIO_TRAILER)) { /* Detect end-of-payload. */
fsm->path = _free(fsm->path);
rc = CPIOERR_HDR_TRAILER;
}
}
if (rc) return rc;
/* Identify mapping index. */
fsm->ix = ((fsm->goal == FSM_PKGINSTALL)
? mapFind(fsm->iter, fsm->path) : mapNextIterator(fsm->iter));
@ -1782,14 +1771,16 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
/* Clean fsm, free'ing memory. */
fsmReset(fsm);
/* Read next archive header. */
rc = fsmInit(fsm);
/* Read next payload header. */
rc = rpmcpioHeaderRead(fsm->archive, &(fsm->path), &(fsm->sb));
/* Exit on end-of-payload. */
if (rc == CPIOERR_HDR_TRAILER) {
rc = 0;
break;
}
/* Detect and exit on end-of-payload. */
if (!rc && rstreq(fsm->path, CPIO_TRAILER))
break;
if (rc) break;
rc = fsmInit(fsm);
/* Exit on error. */
if (rc) {