Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid second call to ippFindAttribute #1047

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading