* [PATCH 2/2] lsm: rename variable to avoid shadowing
@ 2024-11-25 10:59 Christian Göttsche
2024-11-25 10:59 ` [PATCH 1/2] lsm: constify function parameters Christian Göttsche
2025-01-05 3:04 ` [PATCH 2/2] lsm: rename variable to avoid shadowing Paul Moore
0 siblings, 2 replies; 4+ messages in thread
From: Christian Göttsche @ 2024-11-25 10:59 UTC (permalink / raw)
Cc: Christian Göttsche, Paul Moore, James Morris,
Serge E. Hallyn, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-security-module, linux-kernel,
llvm
From: Christian Göttsche <cgzones@googlemail.com>
The function dump_common_audit_data() contains two variables with the
name comm: one declared at the top and one nested one.
Rename the nested variable to improve readability and make future refactorings
of the function less error prone.
Reported by clang:
security/lsm_audit.c:302:10: error: declaration shadows a local variable [-Werror,-Wshadow]
302 | char comm[sizeof(tsk->comm)];
| ^
security/lsm_audit.c:200:7: note: previous declaration is here
200 | char comm[sizeof(current->comm)];
| ^
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
security/lsm_audit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/lsm_audit.c b/security/lsm_audit.c
index f1fe99f2221d..429096bf8fe0 100644
--- a/security/lsm_audit.c
+++ b/security/lsm_audit.c
@@ -299,10 +299,10 @@ static void dump_common_audit_data(struct audit_buffer *ab,
if (tsk) {
pid_t pid = task_tgid_nr(tsk);
if (pid) {
- char comm[sizeof(tsk->comm)];
+ char tskcomm[sizeof(tsk->comm)];
audit_log_format(ab, " opid=%d ocomm=", pid);
audit_log_untrustedstring(ab,
- memcpy(comm, tsk->comm, sizeof(comm)));
+ memcpy(tskcomm, tsk->comm, sizeof(tskcomm)));
}
}
break;
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] lsm: constify function parameters
2024-11-25 10:59 [PATCH 2/2] lsm: rename variable to avoid shadowing Christian Göttsche
@ 2024-11-25 10:59 ` Christian Göttsche
2025-01-05 3:04 ` Paul Moore
2025-01-05 3:04 ` [PATCH 2/2] lsm: rename variable to avoid shadowing Paul Moore
1 sibling, 1 reply; 4+ messages in thread
From: Christian Göttsche @ 2024-11-25 10:59 UTC (permalink / raw)
Cc: Christian Göttsche, Paul Moore, James Morris,
Serge E. Hallyn, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, linux-security-module, linux-kernel,
llvm
From: Christian Göttsche <cgzones@googlemail.com>
The functions print_ipv4_addr() and print_ipv6_addr() are called with
string literals and do not modify these parameters internally.
Reported by clang:
security/lsm_audit.c:324:7: warning: passing 'const char[6]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
324 | "laddr", "lport");
| ^~~~~~~
security/lsm_audit.c:183:27: note: passing argument to parameter 'name1' here
183 | __be16 port, char *name1, char *name2)
| ^
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
security/lsm_audit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/lsm_audit.c b/security/lsm_audit.c
index 849e832719e2..f1fe99f2221d 100644
--- a/security/lsm_audit.c
+++ b/security/lsm_audit.c
@@ -171,7 +171,7 @@ int ipv6_skb_to_auditdata(struct sk_buff *skb,
static inline void print_ipv6_addr(struct audit_buffer *ab,
const struct in6_addr *addr, __be16 port,
- char *name1, char *name2)
+ const char *name1, const char *name2)
{
if (!ipv6_addr_any(addr))
audit_log_format(ab, " %s=%pI6c", name1, addr);
@@ -180,7 +180,7 @@ static inline void print_ipv6_addr(struct audit_buffer *ab,
}
static inline void print_ipv4_addr(struct audit_buffer *ab, __be32 addr,
- __be16 port, char *name1, char *name2)
+ __be16 port, const char *name1, const char *name2)
{
if (addr)
audit_log_format(ab, " %s=%pI4", name1, &addr);
--
2.45.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] lsm: constify function parameters
2024-11-25 10:59 ` [PATCH 1/2] lsm: constify function parameters Christian Göttsche
@ 2025-01-05 3:04 ` Paul Moore
0 siblings, 0 replies; 4+ messages in thread
From: Paul Moore @ 2025-01-05 3:04 UTC (permalink / raw)
To: Christian Göttsche
Cc: Christian Göttsche, James Morris, Serge E. Hallyn,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-security-module, linux-kernel, llvm
On Nov 25, 2024 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgoettsche@seltendoof.de> wrote:
>
> The functions print_ipv4_addr() and print_ipv6_addr() are called with
> string literals and do not modify these parameters internally.
>
> Reported by clang:
>
> security/lsm_audit.c:324:7: warning: passing 'const char[6]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
> 324 | "laddr", "lport");
> | ^~~~~~~
> security/lsm_audit.c:183:27: note: passing argument to parameter 'name1' here
> 183 | __be16 port, char *name1, char *name2)
> | ^
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
> security/lsm_audit.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Merged into lsm/dev, thanks.
--
paul-moore.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] lsm: rename variable to avoid shadowing
2024-11-25 10:59 [PATCH 2/2] lsm: rename variable to avoid shadowing Christian Göttsche
2024-11-25 10:59 ` [PATCH 1/2] lsm: constify function parameters Christian Göttsche
@ 2025-01-05 3:04 ` Paul Moore
1 sibling, 0 replies; 4+ messages in thread
From: Paul Moore @ 2025-01-05 3:04 UTC (permalink / raw)
To: Christian Göttsche
Cc: Christian Göttsche, James Morris, Serge E. Hallyn,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-security-module, linux-kernel, llvm
On Nov 25, 2024 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgoettsche@seltendoof.de> wrote:
>
> The function dump_common_audit_data() contains two variables with the
> name comm: one declared at the top and one nested one.
> Rename the nested variable to improve readability and make future refactorings
> of the function less error prone.
>
> Reported by clang:
>
> security/lsm_audit.c:302:10: error: declaration shadows a local variable [-Werror,-Wshadow]
> 302 | char comm[sizeof(tsk->comm)];
> | ^
> security/lsm_audit.c:200:7: note: previous declaration is here
> 200 | char comm[sizeof(current->comm)];
> | ^
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
> security/lsm_audit.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Merged into lsm/dev, thanks.
--
paul-moore.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-05 3:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 10:59 [PATCH 2/2] lsm: rename variable to avoid shadowing Christian Göttsche
2024-11-25 10:59 ` [PATCH 1/2] lsm: constify function parameters Christian Göttsche
2025-01-05 3:04 ` Paul Moore
2025-01-05 3:04 ` [PATCH 2/2] lsm: rename variable to avoid shadowing Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®