Skip to content

Add Replace RG check exit and add some comments#2254

Merged
jkbonfield merged 1 commit into
samtools:developfrom
mp15:addreplacerg_checkexit
Sep 11, 2025
Merged

Add Replace RG check exit and add some comments#2254
jkbonfield merged 1 commit into
samtools:developfrom
mp15:addreplacerg_checkexit

Conversation

@mp15

@mp15 mp15 commented Sep 4, 2025

Copy link
Copy Markdown
Member
  • Check for unclean file close in bam_addrprg.c and set EXIT_FAILURE if that happens.
  • Add comments to bam_addrprg.c and ensure non-trivial ifs are explicitly {}'d

Comment thread bam_addrprg.c Outdated
Comment on lines +361 to +364
if (opts->uncompressed) {
strcat(output_mode, "0");
if (opts->output_name) // File format auto-detection
}
if (opts->output_name) { // File format auto-detection
sam_open_mode(output_mode + strlen(output_mode),
opts->output_name, NULL);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You mention "ensure non-trivial ifs are explicitly {}'d". However both of these are single statements rather than compound ones.

Do you define a trivial if as one on the same line, rather than this?

if (foo)
    bar();

Generally our coding style is single-statements don't require bracing. I don't object if people do it for new code as it's a minor thing, but I don't see the benefit of changing old code to be that like, especially when there are other single statement if's left unchanged, eg your own if (!cleanup_state) below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to be fair the change to if (opts->uncompressed) I'm happy to drop. It was the multiline nature of sam_open_mode that gave me the urge to {} it

Comment thread bam_addrprg.c
Comment thread bam_addrprg.c Outdated

@jkbonfield jkbonfield left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't let my comments about style seem that I'm ungrateful though. Thank you for the changes. (If you don't have time then I'm sure one of us could reformat in a more house-style during merge if you wish. Plus fixing the trailing spaces from debian-gcc check)

@mp15 mp15 force-pushed the addreplacerg_checkexit branch from 4edb8e0 to 6bbfa7f Compare September 4, 2025 14:04
@mp15

mp15 commented Sep 4, 2025

Copy link
Copy Markdown
Member Author

I've tweaked the code a lil bit to address your points.

@mp15 mp15 force-pushed the addreplacerg_checkexit branch from 6bbfa7f to 7492a00 Compare September 4, 2025 14:33
- Check for unclean file close in bam_addrprg.c and set
  EXIT_FAILURE if that happens.
- Add comments to bam_addrprg.c and ensure ifs are explicitly {}'d
@mp15 mp15 force-pushed the addreplacerg_checkexit branch from 7492a00 to d9b3ef3 Compare September 4, 2025 14:50
@jkbonfield jkbonfield merged commit 23d70b0 into samtools:develop Sep 11, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants