Skip to content

Fix multiple issues#210

Closed
henrygab wants to merge 22 commits intogerbv:mainfrom
henrygab:first_pass_reduction
Closed

Fix multiple issues#210
henrygab wants to merge 22 commits intogerbv:mainfrom
henrygab:first_pass_reduction

Conversation

@henrygab
Copy link
Copy Markdown

@henrygab henrygab commented Sep 4, 2023

Highlights are as follows:

  1. Fix MIN/MAX macros ... they only worked from C++, failed in C11. See 45bc71a
  2. clang-format CI check was not applying the checked-in file style. See 0f74a9c.
  3. Convert unsage dprintf() to safer DPRINTF(()). See a831563
  4. Fix issue Drill files get scaled incorrectly #195. See c261beb
  5. Add checks for invariants. See d3c32df and f5d9c72

All commits build and pass tests. See https://github.com/henrygab/gerbv/pull/1 for automated build / test results for each commit.

Fixes #195.
Fixes #211.
Fixes #212.
Fixes #213.
Fixes #214.
Fixes #215.
Fixes #216.
Fixes #217.
Fixes #218.
Fixes #219.
Fixes #220.
Fixes #221.

@eyal0
Copy link
Copy Markdown
Collaborator

eyal0 commented Sep 5, 2023

It's hard to review with so much going on! Could this be multiple PRs please?

@henrygab
Copy link
Copy Markdown
Author

henrygab commented Sep 5, 2023

I broke every significant change into its own commit.

Can you review the commits in sequence?

Stop anytime. These were not undirected commits. Each was a reduction of work from my initial dev tree.

I'll consider rebase'ing, with changes at any commit.

@henrygab
Copy link
Copy Markdown
Author

henrygab commented Sep 5, 2023

Or just consider the above 22 separate PRs. 😆

@henrygab
Copy link
Copy Markdown
Author

henrygab commented Sep 5, 2023

It's hard to review with so much going on! Could this be multiple PRs please?

To help you with review, I've opened issues to help describe what the changes are addressing. That's a lot of issues. Where I could easily do so, I provided references to CERT coding standards. Thus, if you wonder why it's worth making a given change, the linked web page gives detailed descriptions of the "why" such practices help write solid, bug-free code.

Each commit here is focused on one type of change, which was an expressed preference. If you find that is not the case, let me know. I may be open to splitting, rebasing, and force-pushing.

However, given the multi-day timeframe for PR reviews, doing 22 individual PRs just doesn't make sense for either one of us.

@ooxi
Copy link
Copy Markdown
Contributor

ooxi commented Sep 7, 2023

@henrygab first of all, thank you very much for your tremendous work! It's very much appreciated!

I have skipped over most commits and they look reasonable. I'll see if GitHub has a way to mark individual commits as reviewed so we can split the effort and merge when all has been reviewed :-)

src/drill.c Outdated
DRILL_DATA
} drill_file_section_t;

static const char* drill_file_section_list[] = { "NONE", "HEADER", "DATA", NULL };
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could this be declared inside of the function below? If that function is the only one using it, might as well limit the scope, right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

true.

@henrygab
Copy link
Copy Markdown
Author

Do you want me to keep my fork / this branch around? I'm done with this fix, and want to mentally offload this work.

FYI, I'm not really vested in whether this PR gets accepted, heavily modified, or thrown away. Of course, I did ensure that each commit in this branch not only builds, but fully passed all the built-in CI tests. I looked into this because a company I sent a tiny PCB design to hit this bug.

I'm relatively happy to answer questions about any commit; Unfortunately, at some point my memory will fade....

@eyal0
Copy link
Copy Markdown
Collaborator

eyal0 commented Sep 23, 2023

I want to look at it, I've just been swamped. I'll get to it next week.

@eyal0 eyal0 mentioned this pull request Oct 11, 2023
* C11 does not support references.
* C11 does not support the `typeof` operator
  (although GCC allows it as an extension)
* Order of internal `drill_state_t` structure changed
* `drill_state_t->autod` changed to native `bool`
Excellon format is clear that only two values
are valid for `header_number_format`, and
which value is used depends on the units:
* Inches ==> FMT_00_0000
* Metric ==> FMT_000_000

Therefore, do not set to FMT_USER on those
occasions, but to the allowed format type.

Also added many more comments to
`drill_parse_header_is_metric()`, explaining
the implied logic.
Specifically, pull out the detection for two
edge cases (hacks for bad data) into separate
functions. These new functions ensure that,
if they return false, they leave the file descriptor
pointer where it was at entry.
Two issues with the prior method:
1. `dprintf()` is already defined in `stdio.h`,
   which reduces clarity.
2. The use of an `if` statement without braces
   can hide significant logic errors.

Example code that would have logic error:

```C
// Ensure number format is set to FMT_USER (and warn if not true).
if (state->number_format == FMT_USER)
    dprintf("Some debugging information here.")
else
    state->number_format = FMT_USER;
```

Bug in the above is that `number_format` is never set to `FMT_USER`.
@henrygab
Copy link
Copy Markdown
Author

henrygab commented Oct 18, 2023

I think your rebase resulted in a clang-format failure.

There is an explicit request to ensure that every commit will be working (e.g., for git bisect to be easily used in future). I put in the work to ensure every single commit would pass CI. This took about 15 minutes per commit. That's a lot of work that was discarded by the force-push.

With your force-push, the CI checks fails for at least one commit, and I cannot tell you which commit that this broke in. If I could, I would have undone your force-push. [[ I don't know if this is even possible to do with git. ]]

I think removing the extra blank line is all that was needed to fix this.

@eyal0
Copy link
Copy Markdown
Collaborator

eyal0 commented Oct 18, 2023

Sorry about that. I've been going through the commits one by one and putting them in as I review them. I rebased in order to see what work remains.

I can avoid the rebasing in the future.

@henrygab
Copy link
Copy Markdown
Author

I will defer to your choices in this matter. At the same time, I cannot ensure this branch is 100% clean (git bisect will always have working builds), as requested in prior PRs. With this understanding, party as you wish on the branch.

@henrygab
Copy link
Copy Markdown
Author

FYI, I have created a new PR (PR #226) today. I re-generated proof of each commit successfully completing the CI checks.
that other PR also fixes a typo in the fix for #195, where the leading and trailing digits were swapped in one case.
Otherwise, all those commits were programatically applied from this branch.

See 100% CI success rate at https://github.com/henrygab/gerbv/pull/3.

I am therefore closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment