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

Clang14 tidy #1048

Merged
merged 7 commits into from
Jul 28, 2023
Merged

Clang14 tidy #1048

merged 7 commits into from
Jul 28, 2023

Conversation

TingDaoK
Copy link
Contributor

@TingDaoK TingDaoK commented Jul 27, 2023

  • Upgrade our clang tidy to llvm14
  • Disable warnings for:
    • bugprone-easily-swappable-parameters
    • readability-identifier-length -- variable name needs to be more than 3 chars :)
    • misc-no-recursion -- :)
    • readability-function-cognitive-complexity -- Nice to have, but waay too late, and way to many
    • readability-magic-numbers -- Const numbers should be declared as variables, not too bad, but just waay too many in our codebase

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -10,8 +10,7 @@

AWS_PUSH_SANE_WARNING_LEVEL

#define AWS_DATE_TIME_STR_MAX_LEN 100
#define AWS_DATE_TIME_STR_MAX_BASIC_LEN 20
enum { AWS_DATE_TIME_STR_MAX_LEN = 100, AWS_DATE_TIME_STR_MAX_BASIC_LEN = 20 };
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: both constants on same line look really awkward

@@ -291,7 +291,7 @@ static void *s_cf_allocator_reallocate(void *ptr, CFIndex new_size, CFOptionFlag
aws_mem_realloc(allocator, &original_allocation, original_size, (size_t)new_size);

size_t new_allocation_size = (size_t)new_size;
memcpy(original_allocation, &new_allocation_size, sizeof(size_t));
memcpy(original_allocation, &new_allocation_size, sizeof(size_t)); /* NOLINT(clang-analyzer-unix.cstring.NullArg) */
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth enforcing this case with fatal assert instead of ignoring the warning?

source/posix/condition_variable.c Outdated Show resolved Hide resolved
@@ -58,8 +58,10 @@ enum aws_log_level {
typedef uint32_t aws_log_subject_t;

/* Each library gets space for 2^^10 log subject entries */
#define AWS_LOG_SUBJECT_STRIDE_BITS 10
#define AWS_LOG_SUBJECT_STRIDE (1U << AWS_LOG_SUBJECT_STRIDE_BITS)
enum {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a fan of this change. Adjacent integral constant defines is not necessarily something that should be an enum

Copy link
Contributor

Choose a reason for hiding this comment

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

is your concern mostly with just grouping of unrelated constants under the same enum or enum usage for constants in general?

#define AWS_LOG_SUBJECT_STRIDE (1U << AWS_LOG_SUBJECT_STRIDE_BITS)
enum {
AWS_LOG_SUBJECT_STRIDE_BITS = 10,
AWS_LOG_SUBJECT_STRIDE = (1U << AWS_LOG_SUBJECT_STRIDE_BITS),
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be changing AWS_LOG_SUBJECT_STRIDE from unsigned to signed.
all enums are int in C
but it looks like the old #define was trying to be unsigned

#define AWS_CRT_STATISTICS_CATEGORY_STRIDE (1U << AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS)
enum {
AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS = 8,
AWS_CRT_STATISTICS_CATEGORY_STRIDE = (1U << AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS)
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing with signed/unsigned

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (c6faf8a) 82.23% compared to head (7f09d01) 82.25%.
Report is 2 commits behind head on pickup-cjson.

Additional details and impacted files
@@               Coverage Diff                @@
##           pickup-cjson    #1048      +/-   ##
================================================
+ Coverage         82.23%   82.25%   +0.01%     
================================================
  Files                52       52              
  Lines              5641     5641              
================================================
+ Hits               4639     4640       +1     
+ Misses             1002     1001       -1     
Files Changed Coverage Δ
source/encoding.c 74.78% <ø> (ø)
source/log_formatter.c 88.65% <ø> (ø)
source/logging.c 49.76% <ø> (ø)
source/memtrace.c 99.54% <ø> (ø)
source/posix/clock.c 90.00% <ø> (ø)
source/posix/system_info.c 20.88% <ø> (ø)
source/posix/thread.c 80.47% <ø> (ø)
source/process_common.c 87.87% <ø> (ø)
source/thread_shared.c 100.00% <ø> (ø)
source/allocator.c 97.36% <100.00%> (ø)
... and 7 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TingDaoK TingDaoK merged commit 0f7f946 into pickup-cjson Jul 28, 2023
51 checks passed
@TingDaoK TingDaoK deleted the clang14-tidy branch July 28, 2023 20:40
TingDaoK added a commit that referenced this pull request Jul 31, 2023
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.

5 participants