Skip to contentSkip to conversation

cleanups

PATCH RESEND In review Jules Irenge 2 participants 7 messages Aug 3, 2020 – Aug 18, 2020 Audit

lore
Share & tools
lore
#0 lore raw

cover cleanups

I am proposing these 2 patches, one of which is recommendation of Joe Perches, namely the removing of unnecessary globals and change them to static. I am currently learning the core kernel the hard way.
I will appreciate any feedback negative or positive.
Thanks

Jules Irenge (2):
audit: change unnecessary globals into statics
audit: uninitialize variable audit_sig_sid

 kernel/audit.c | 6 +++---
 kernel/audit.h | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH RESEND 1/2 audit: change unnecessary globals into statics

Variables sig_pid, audit_sig_uid and audit_sig_sid are only used in the audit.c file across the kernel Hence it appears no reason for declaring them as globals This patch removes their global declarations from the .h file and change them into static in the .c file.

---
 kernel/audit.c | 6 +++---
 kernel/audit.h | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)
kernel/audit.c +3 -3
index b2301bdc9773..afd7827cf6e8 100644
@@ -123,9 +123,9 @@ static u32	audit_backlog_limit = 64;
 static u32	audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME;
 
 /* The identity of the user shutting down the audit system. */
-kuid_t		audit_sig_uid = INVALID_UID;
-pid_t		audit_sig_pid = -1;
-u32		audit_sig_sid = 0;
+static kuid_t		audit_sig_uid = INVALID_UID;
+static pid_t		audit_sig_pid = -1;
+static u32		audit_sig_sid = 0;
 
 /* Records can be lost in several ways:
    0) [suppressed in audit_alloc]
kernel/audit.h +0 -4
index ddc22878433d..3b9c0945225a 100644
@@ -327,10 +327,6 @@ static inline int audit_signal_info_syscall(struct task_struct *t)
 
 extern char *audit_unpack_string(void **bufp, size_t *remain, size_t len);
 
-extern pid_t audit_sig_pid;
-extern kuid_t audit_sig_uid;
-extern u32 audit_sig_sid;
-
 extern int audit_filter(int msgtype, unsigned int listtype);
 
 extern void audit_ctl_lock(void);
Signature · 1 line
2.26.2
maintainer
#2 lore raw

Re: [RESEND PATCH 1/2] audit: change unnecessary globals into statics

Quoted 7 lines · Jules Irenge

Variables sig_pid, audit_sig_uid and audit_sig_sid are only used in the audit.c file across the kernel Hence it appears no reason for declaring them as globals This patch removes their global declarations from the .h file and change them into static in the .c file.

Quoted 5 lines
---
 kernel/audit.c | 6 +++---
 kernel/audit.h | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)

Thanks Jules, this looks reasonable although I'm not going to merge them into audit/next until after the merge window closes. I'll send another reply once this has been merged.

Signature · 2 lines
paul moore
www.paul-moore.com
maintainer
#3 lore raw

Re: [RESEND PATCH 1/2] audit: change unnecessary globals into statics

Quoted 15 lines · Paul Moore
Quoted 7 lines · Jules Irenge

Variables sig_pid, audit_sig_uid and audit_sig_sid are only used in the audit.c file across the kernel Hence it appears no reason for declaring them as globals This patch removes their global declarations from the .h file and change them into static in the .c file.

Quoted 5 lines
---
 kernel/audit.c | 6 +++---
 kernel/audit.h | 4 ----
 2 files changed, 3 insertions(+), 7 deletions(-)
Quoted 3 lines

Thanks Jules, this looks reasonable although I'm not going to merge them into audit/next until after the merge window closes. I'll send another reply once this has been merged.

... and I just merged this into audit/next, thanks Jules.

Signature · 2 lines
paul moore
www.paul-moore.com
#4 lore raw

PATCH RESEND 2/2 audit: uninitialize variable audit_sig_sid

In reply to Jules Irenge

Checkpatch tool reports

"ERROR: do not initialise globals/statics to 0"

To fix this, audit_sig_sid is uninitialized
As this is stored in the .bss section,
the compiler can initialize the variable automatically.

---
 kernel/audit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/audit.c +1 -1
index afd7827cf6e8..1c74d1d788b6 100644
@@ -125,7 +125,7 @@ static u32	audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME;
 /* The identity of the user shutting down the audit system. */
 static kuid_t		audit_sig_uid = INVALID_UID;
 static pid_t		audit_sig_pid = -1;
-static u32		audit_sig_sid = 0;
+static u32		audit_sig_sid;
 
 /* Records can be lost in several ways:
    0) [suppressed in audit_alloc]
Signature · 1 line
2.26.2
maintainer
#5 lore raw

Re: [RESEND PATCH 2/2] audit: uninitialize variable audit_sig_sid

Quoted 5 lines · Jules Irenge

Checkpatch tool reports

"ERROR: do not initialise globals/statics to 0"

Quoted 8 lines

To fix this, audit_sig_sid is uninitialized
As this is stored in the .bss section,
the compiler can initialize the variable automatically.

---
 kernel/audit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Similar to patch 1/2, this will need to wait until after the merge window closes.

Signature · 7 lines
paul moore
www.paul-moore.com

--
Linux-audit mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-audit
maintainer
#6 lore raw

Re: [RESEND PATCH 2/2] audit: uninitialize variable audit_sig_sid

Quoted 11 lines · Paul Moore
Quoted 9 lines · Jules Irenge

Checkpatch tool reports

"ERROR: do not initialise globals/statics to 0"

To fix this, audit_sig_sid is uninitialized
As this is stored in the .bss section,
the compiler can initialize the variable automatically.

Quoted 7 lines
Quoted 4 lines
---
 kernel/audit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Similar to patch 1/2, this will need to wait until after the merge window closes.

... also merged this patch into audit/next. Thanks again.

Signature · 2 lines
paul moore
www.paul-moore.com