lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201020235126.1871815-5-fenghua.yu@intel.com>
Date:   Tue, 20 Oct 2020 23:51:09 +0000
From:   Fenghua Yu <fenghua.yu@...el.com>
To:     "Shuah Khan" <shuah@...nel.org>,
        "Reinette Chatre" <reinette.chatre@...el.com>,
        "Tony Luck" <tony.luck@...el.com>,
        "Babu Moger" <babu.moger@....com>,
        "James Morse" <james.morse@....com>,
        "Borislav Petkov" <bp@...en8.de>,
        "Thomas Gleixner" <tglx@...utronix.de>,
        "Ravi V Shankar" <ravi.v.shankar@...el.com>
Cc:     "linux-kselftest" <linux-kselftest@...r.kernel.org>,
        "linux-kernel" <linux-kernel@...r.kernel.org>,
        Fenghua Yu <fenghua.yu@...el.com>
Subject: [PATCH v3 04/21] selftests/resctrl: Declare global variables as extern

resctrl test suite uses global variables (E.g: bm_pid, ppid, llc_occup_path
and is_amd) that are used across .c files. These global variables are
defined in resctrl.h file and the header file is included in .c files where
needed. Sparse tool isn't very happy about defining global variables in .h
file and hence complains as below

resctrl.h:65:7: warning: symbol 'bm_pid' was not declared.
		Should it be static?
resctrl.h:65:15: warning: symbol 'ppid' was not declared.
		 Should it be static?
resctrl.h:66:5: warning: symbol 'tests_run' was not declared.
		Should it be static?
resctrl.h:68:6: warning: symbol 'llc_occup_path' was not declared.
		Should it be static?
resctrl.h:69:6: warning: symbol 'is_amd' was not declared.
		Should it be static?

Sparse tool thinks that since the variables are defined and not declared,
it assumes that the scope of these variables is limited to a .c file and
hence suggests making them static variables. But these variables are used
across .c files and hence cannot be static variables.

Fix these warnings by declaring the variables (i.e. use extern keyword)
rather than defining them in resctrl.h file.

Please note that sparse tool still complains about other issues and they
will be fixed in later patches.

Fixes: 591a6e8588fc ("selftests/resctrl: Add basic resctrl file
system operations and data")
Reported-by: Reinette Chatre <reinette.chatre@...el.com>
Signed-off-by: Fenghua Yu <fenghua.yu@...el.com>
---
 tools/testing/selftests/resctrl/resctrl.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h
index 68522b19b235..814d0dd517a4 100644
--- a/tools/testing/selftests/resctrl/resctrl.h
+++ b/tools/testing/selftests/resctrl/resctrl.h
@@ -62,11 +62,11 @@ struct resctrl_val_param {
 	int		(*setup)(int num, ...);
 };
 
-pid_t bm_pid, ppid;
-int tests_run;
+extern pid_t bm_pid, ppid;
+extern int tests_run;
 
-char llc_occup_path[1024];
-bool is_amd;
+extern char llc_occup_path[1024];
+extern bool is_amd;
 
 bool check_resctrlfs_support(void);
 int filter_dmesg(void);
-- 
2.29.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ