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

Avoid shadowing locks with locks taken in macros #603

Merged
merged 1 commit into from
Feb 14, 2025
Merged

Conversation

JelteF
Copy link
Collaborator

@JelteF JelteF commented Feb 14, 2025

I got some warnings when using pd_log in certain places. This fixes those. It also changes the name in the __PostgresFunctionGuard__ template to lock, because variables in templates don't shadow variables at invocation.

@JelteF JelteF requested a review from Y-- February 14, 2025 14:51
@@ -81,7 +81,7 @@ struct PostgresScopedStackReset {
template <typename Func, Func func, typename... FuncArgs>
typename std::invoke_result<Func, FuncArgs...>::type
__PostgresFunctionGuard__(const char *func_name, FuncArgs... args) {
std::lock_guard<std::recursive_mutex> lk(pgduckdb::GlobalProcessLock::GetLock());
std::lock_guard<std::recursive_mutex> __pg_func_guard_lock(pgduckdb::GlobalProcessLock::GetLock());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's rename this to lock: this is not a macro but a template

@JelteF JelteF force-pushed the avoid-shadow-warnings branch from 6c3b084 to 39a585b Compare February 14, 2025 15:05
@JelteF JelteF enabled auto-merge (squash) February 14, 2025 15:06
@JelteF JelteF force-pushed the avoid-shadow-warnings branch from 39a585b to a283ba8 Compare February 14, 2025 15:08
@JelteF JelteF merged commit 3789e4c into main Feb 14, 2025
5 checks passed
@JelteF JelteF deleted the avoid-shadow-warnings branch February 14, 2025 16:09
@dentiny
Copy link
Contributor

dentiny commented Feb 16, 2025

Just came across this PR, a commonly used technique in macro is to assigned it a unique suffix, this is what I did in ray:

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.

3 participants