Commit graph

14 commits

Author SHA1 Message Date
Sean McBride
e8d76b1a12 clang-tidy: Stop suppressing readability-misleading-indentation warnings
All such warnings are already fixed in master.

Closes #1479
2024-07-28 13:27:06 +02:00
Sean McBride
197e3052cd libusb.h: Match parameter names in declaration and definition
Took the name from the .c file.

Fixes all clang-tidy readability-inconsistent-declaration-parameter-name
warnings

References #1479
2024-07-28 13:27:06 +02:00
Sean McBride
55f8c95551 descriptor: Fix addition overflow by correcting casts
The addition could overflow, the upcast needs to be performed before,
not after.

Fixes all clang-tidy bugprone-misplaced-widening-cast warnings

References #1479
2024-07-28 13:27:06 +02:00
Sean McBride
e3ccc46b6e descriptor: Eliminate all duplicate branch bodies, as they are bug-prone
Copy-pasting can often result in mistakes like:

```
if (test_value(x)) {
  y++;
  do_something(x, y);
} else {
  y++;
  do_something(x, y);
}
```

Thus it is preferable that branch bodies be unique.

Fixes all clang-tidy bugprone-branch-clone warnings

References #1479
2024-07-28 13:27:06 +02:00
Sean McBride
9cf84577ce Avoid assignments within if statements
Fixes all clang-tidy bugprone-assignment-in-if-condition warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
a18a964aba darwin: Fix multiplication overflow by better matching type sizes
These multiplication could indeed have overflowed, but now they are
performed with a bigger type, matching the type they are ultimately
stored in.

Fixes all clang-tidy bugprone-implicit-widening-of-multiplication-result
warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
6883f84f93 darwin: Explicitly compare string compare function results to -1, 0, or 1
Fixes all clang-tidy bugprone-suspicious-string-compare warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
418aadc0f9 darwin: Always use uppercase literal suffixes for improved readability
Depending on the font, an l suffix can look like a 1. Consider "231l".
Thus prefer uppercase.

Fixes all clang-tidy readability-uppercase-literal-suffix warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
3616e751b1 examples/xusb: Match size of loop index to what is iterated
Fixes all clang-tidy bugprone-too-small-loop-variable warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
a7e471dd48 examples/xusb: Make some parameters const where possible
Fixes all clang-tidy readability-non-const-parameter warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
85055a412b examples/xusb: Make all macro replacement lists parenthesized
To protect any lower-precedence operators from the surrounding
expression.

Fixes all clang-tidy bugprone-macro-parentheses warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
9ffdb7fe6e examples/fxload: Eliminate all reserved C identifiers (leading underscores)
The C langugage reserves various identifiers for itself that user code
must not use.

Fixes all clang-tidy bugprone-reserved-identifier warnings

Also, 4 of 5 file extension tests were case insensitive, and 1 was not.
Changed it to be insensitive too.

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
00454ab087 examples/ezusb: Replace rewind with fseek, to check for errors
Replace rewind, which gives no error result, with fseek, which does.

Fixes all clang-tidy bugprone-unsafe-functions warnings

References #1479
2024-07-28 13:27:05 +02:00
Sean McBride
6cf58bac95 Add clang-tidy config file
All checks are enabled except for those that cause any warning.

This is a starting point, some of the currently-suppressed warnings can
be fixed hereafter.

Closes #1434
2024-02-26 22:46:29 +01:00