public inbox for [email protected]
help / color / mirror / Atom feedguc: make dereference style consistent in check_backtrace_functions
3+ messages / 3 participants
[nested] [flat]
* guc: make dereference style consistent in check_backtrace_functions
@ 2026-02-26 07:03 zhanghu <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: zhanghu @ 2026-02-26 07:03 UTC (permalink / raw)
To: [email protected]
Hi,
In check_backtrace_functions(), most accesses to the input string follow
the pattern (*newval)[i]. However, the empty-string check is currently
written as:
if (*newval[0] == '\0')
While functionally correct due to how the compiler handles the
address-of-address context here, this form is semantically misleading. It
relies on implicit operator precedence rather than explicit intent.
The attached patch rewrites it as:
if ((*newval)[0] == '\0')
This change ensures semantic clarity and maintains a consistent
dereferencing style throughout the function. No functional changes are
introduced.
Regards,
Zhang Hu
Attachments:
[application/octet-stream] v1-0001-guc-make-dereference-style-consistent-in-check_ba.patch (1.2K, 3-v1-0001-guc-make-dereference-style-consistent-in-check_ba.patch)
download | inline diff:
From 85919fa8f4500be466dbc2e0a37072e1b8732700 Mon Sep 17 00:00:00 2001
From: zhanghu <[email protected]>
Date: Thu, 26 Feb 2026 14:54:22 +0800
Subject: [PATCH v1] guc: make dereference style consistent in
check_backtrace_functions
In check_backtrace_functions(), the empty-string check is currently
implemented as:
if (*newval[0] == '\0')
while the rest of the function consistently accesses the string as
(*newval)[i]
This patch rewrites the check as:
if ((*newval)[0] == '\0')
This change ensures semantic clarity and maintains a consistent
dereferencing style throughout the function. No functional changes
are introduced.
Author: zhanghu <[email protected]>
---
src/backend/utils/error/elog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 0d0bf0f6aa5..650a79b7e12 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2627,7 +2627,7 @@ check_backtrace_functions(char **newval, void **extra, GucSource source)
return false;
}
- if (*newval[0] == '\0')
+ if ((*newval)[0] == '\0')
{
*extra = NULL;
return true;
--
2.33.0
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: guc: make dereference style consistent in check_backtrace_functions
@ 2026-02-26 09:21 Chao Li <[email protected]>
parent: zhanghu <[email protected]>
0 siblings, 1 reply; 3+ messages in thread
From: Chao Li @ 2026-02-26 09:21 UTC (permalink / raw)
To: zhanghu <[email protected]>; +Cc: [email protected]
> On Feb 26, 2026, at 15:03, zhanghu <[email protected]> wrote:
>
> Hi,
>
> In check_backtrace_functions(), most accesses to the input string follow the pattern (*newval)[i]. However, the empty-string check is currently written as:
>
> if (*newval[0] == '\0')
>
> While functionally correct due to how the compiler handles the address-of-address context here, this form is semantically misleading. It relies on implicit operator precedence rather than explicit intent.
>
> The attached patch rewrites it as:
>
> if ((*newval)[0] == '\0')
>
> This change ensures semantic clarity and maintains a consistent dereferencing style throughout the function. No functional changes are introduced.
>
> Regards,
> Zhang Hu
> <v1-0001-guc-make-dereference-style-consistent-in-check_ba.patch>
This is an interesting find.
[] has higher precedence than *, so:
- (*newval)[i] means to get the first string, then get the char at position i
- *newval[i] means to get the array element at position i, then get the first char
When i is 0, (*newval)[0] and *newval[0] happen to yield the same result, so this isn't a functional bug.
However, in the GUC context, newval is a point to a string rather than a two-dimension char array, *newval[i] is meaningless, so +1 for fixing this to improve readability.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: guc: make dereference style consistent in check_backtrace_functions
@ 2026-02-26 11:04 Junwang Zhao <[email protected]>
parent: Chao Li <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: Junwang Zhao @ 2026-02-26 11:04 UTC (permalink / raw)
To: Chao Li <[email protected]>; +Cc: zhanghu <[email protected]>; [email protected]
On Thu, Feb 26, 2026 at 5:21 PM Chao Li <[email protected]> wrote:
>
>
>
> > On Feb 26, 2026, at 15:03, zhanghu <[email protected]> wrote:
> >
> > Hi,
> >
> > In check_backtrace_functions(), most accesses to the input string follow the pattern (*newval)[i]. However, the empty-string check is currently written as:
> >
> > if (*newval[0] == '\0')
> >
> > While functionally correct due to how the compiler handles the address-of-address context here, this form is semantically misleading. It relies on implicit operator precedence rather than explicit intent.
> >
> > The attached patch rewrites it as:
> >
> > if ((*newval)[0] == '\0')
> >
> > This change ensures semantic clarity and maintains a consistent dereferencing style throughout the function. No functional changes are introduced.
> >
> > Regards,
> > Zhang Hu
> > <v1-0001-guc-make-dereference-style-consistent-in-check_ba.patch>
>
> This is an interesting find.
>
> [] has higher precedence than *, so:
>
> - (*newval)[i] means to get the first string, then get the char at position i
> - *newval[i] means to get the array element at position i, then get the first char
>
> When i is 0, (*newval)[0] and *newval[0] happen to yield the same result, so this isn't a functional bug.
>
> However, in the GUC context, newval is a point to a string rather than a two-dimension char array, *newval[i] is meaningless, so +1 for fixing this to improve readability.
+1
The double pointer indicates an output parameter, the commit
message should be adjusted though.
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>
>
>
--
Regards
Junwang Zhao
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-02-26 11:04 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26 07:03 guc: make dereference style consistent in check_backtrace_functions zhanghu <[email protected]>
2026-02-26 09:21 ` Chao Li <[email protected]>
2026-02-26 11:04 ` Junwang Zhao <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox