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

Fixes for issues reported by OpenScanHub #335

Closed
wants to merge 1 commit into from

Conversation

zdohnal
Copy link
Contributor

@zdohnal zdohnal commented Feb 8, 2024

No description provided.

Copy link
Owner

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

if (job->state_reasons & PAPPL_JREASON_WARNINGS_DETECTED)
job->state_reasons |= PAPPL_JREASON_JOB_COMPLETED_WITH_WARNINGS;
}
if (job->state == state)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have this be != and put the state change code in the block, rather than adding another exit point from the function...

Copy link
Contributor Author

@zdohnal zdohnal Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelrsweet I've caught this habit from times when I wrote code for a python project - in the end I liked how simple and straight the final code is, instead of closing it in another block.
I can think of a disadvantage being that you have to unlock/free any relevant memory at every exit point. Is there other disadvantage or is it a matter of habit in person's code style?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zdohnal If there is no cleanup needed, I do a return (like for the "job" NULL check). But when you have lock (or other) cleanup I either use code blocks or "goto" to make sure that a) I don't have a lot of duplicate code that I have to keep in sync and b) I fully understand the implications of whatever recovery a particular piece of code requires.

@@ -793,6 +793,8 @@ _papplJobSubmitFile(
pappl_job_t *job, // I - Job
const char *filename) // I - Filename
{
_papplRWLockRead(job->system);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change isn't necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked into the code more deeply and now I see why it is not necessary - FTR for myself and others - guarding job->format there is unnecessary - every function which calls this function creates its own instance of job, so there are no threads which would change format for the same job at the moment.

@michaelrsweet
Copy link
Owner

[v1.4.x 7fd86e1] Fix some issues discovered by OpenScanHub (Issue #335)

@michaelrsweet michaelrsweet self-assigned this Feb 8, 2024
@michaelrsweet michaelrsweet added bug Something isn't working priority-medium labels Feb 8, 2024
@michaelrsweet michaelrsweet added this to the Stable milestone Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants