Skip to content

Commit

Permalink
Merge pull request #1047 from RSilicon/f
Browse files Browse the repository at this point in the history
Avoid second call to ippFindAttribute
  • Loading branch information
michaelrsweet authored Sep 13, 2024
2 parents 2dad30d + 6a21f1d commit 7e1a313
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions scheduler/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -1695,28 +1695,26 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */
* Copy attribute data to the job object...
*/

if (!ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER))
if ((job->state = ippFindAttribute(job->attrs, "job-state",
IPP_TAG_ENUM)) == NULL)
{
cupsdLogJob(job, CUPSD_LOG_ERROR,
"Missing or bad time-at-creation attribute in control file.");
"Missing or bad job-state attribute in control file.");
goto error;
}

if ((job->state = ippFindAttribute(job->attrs, "job-state",
IPP_TAG_ENUM)) == NULL)
if ((attr = ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER)) == NULL)
{
cupsdLogJob(job, CUPSD_LOG_ERROR,
"Missing or bad job-state attribute in control file.");
"Missing or bad time-at-creation attribute in control file.");
goto error;
}

job->creation_time = attr->values[0].integer;
job->state_value = (ipp_jstate_t)job->state->values[0].integer;
job->file_time = 0;
job->history_time = 0;

if ((attr = ippFindAttribute(job->attrs, "time-at-creation", IPP_TAG_INTEGER)) != NULL)
job->creation_time = attr->values[0].integer;

if (job->state_value >= IPP_JSTATE_CANCELED && (attr = ippFindAttribute(job->attrs, "time-at-completed", IPP_TAG_INTEGER)) != NULL)
{
job->completed_time = attr->values[0].integer;
Expand Down

0 comments on commit 7e1a313

Please sign in to comment.