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

testing/sd_*: Restrict function and variable scope to current file. #2201

Merged
merged 2 commits into from
May 8, 2024

Conversation

g2gps
Copy link
Contributor

@g2gps g2gps commented Nov 17, 2023

Summary

Add the static keyword to required function and variable delcaration to reduce their scope. Stops namespace pollution in CONFIG_BUILD_FLAT

Impact

Stops symbol collision when CONFIG_TESTING_SD_BENCH and CONFIG_TESTING_SD_STRESS are enables simultaneously.

Testing

Enable CONFIG_TESTING_SD_BENCH and CONFIG_TESTING_SD_STRESS at the same time.

testing/sd_bench/sd_bench_main.c Outdated Show resolved Hide resolved
testing/sd_stress/sd_stress_main.c Outdated Show resolved Hide resolved
Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

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

Why not allocate these in a struct and reduce memory footprint that just including that app costs?

@pkarashchenko
Copy link
Contributor

pkarashchenko commented Nov 17, 2023

Why not allocate these in a struct and reduce memory footprint that just including that app costs?

Could you please expand more with maybe a kind of example. I'm not fully following your proposal. I think all those local static consts will be optimized out by compiler anyway.

@davids5
Copy link
Contributor

davids5 commented Nov 20, 2023

Why not allocate these in a struct and reduce memory footprint that just including that app costs?

Could you please expand more with maybe a kind of example. I'm not fully following your proposal. I think all those local static consts will be optimized out by compiler anyway.

I did not think these were local. Also as globals they do not conform to the coding standard.

My point was placing all the variables in a struct allocated at run time will reduce the data size to a single pointer or 0 if it is passed as an argument.

@acassis
Copy link
Contributor

acassis commented Apr 29, 2024

ping @g2gps

g2gps added 2 commits May 8, 2024 15:21
Add the static keyword to required function and variable delcaration to reduce their scope. Stops namespace pollution in CONFIG_BUILD_FLAT.
Add the static keyword to required function and variable delcaration to reduce their scope. Stops namespace pollution in CONFIG_BUILD_FLAT.
@g2gps
Copy link
Contributor Author

g2gps commented May 8, 2024

Sorry, I'd forgotten that this was pending.

These variables are marked static, so if I understand correctly, there scope is limited to the files the file they are declared in.

There is an opportunity to reduce the scope of some of these variables, if required I can refactor.

@xiaoxiang781216 xiaoxiang781216 merged commit 5f166c0 into apache:master May 8, 2024
25 checks passed
@g2gps g2gps deleted the sd-fix-scope branch May 9, 2024 22:20
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.

6 participants