Skip to contentSkip to conversation

cpupower: remove extern declarations in cmd_set()

PATCH Superseded Kaushlendra Kumar 2 participants 5 messages Mar 31 – Apr 2 CPU power monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpupower: remove extern declarations in cmd_set()

extern char *optarg and extern int optind, opterr, optopt are already declared by <getopt.h>, which is included at the top of the file. Repeating extern declarations inside a function body is misleading and unnecessary.

---
 tools/power/cpupower/utils/cpupower-set.c | 2 --
 1 file changed, 2 deletions(-)
tools/power/cpupower/utils/cpupower-set.c +0 -2
index dcbdff5c9ae5..64d2d4b070b4 100644
@@ -51,8 +51,6 @@ static int parse_int_range(const char *arg, int min, int max, int *out)
 
 int cmd_set(int argc, char **argv)
 {
-	extern char *optarg;
-	extern int optind, opterr, optopt;
 	unsigned int cpu;
 	struct utsname uts;
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 4 lines · Kaushlendra Kumar

extern char *optarg and extern int optind, opterr, optopt are already declared by <getopt.h>, which is included at the top of the file. Repeating extern declarations inside a function body is misleading and unnecessary.

Okay - are there errors from compilers or static checkers? How did you find the problem?

Quoted 11 lines
---
  tools/power/cpupower/utils/cpupower-set.c | 2 --
  1 file changed, 2 deletions(-)
tools/power/cpupower/utils/cpupower-set.c +0 -0
index dcbdff5c9ae5..64d2d4b070b4 100644

tools/power/cpupower/utils/cpupower-set.c static int parse_int_range(const char *arg, int min, int max, int *out) · line 56

Quoted 8 lines
tools/power/cpupower/utils/cpupower-set.c +0 -2
@@ -51,8 +51,6 @@ static int parse_int_range(const char *arg, int min, int max, int *out)
 
  int cmd_set(int argc, char **argv)
  {
-	extern char *optarg;
-	extern int optind, opterr, optopt;
  	unsigned int cpu;
  	struct utsname uts;
 

thanks,
-- Shuah

#2 lore raw
Quoted 1 line · Shuah Khan

Okay - are there errors from compilers or static checkers? How did you find the problem?

No errors from compilers or static checkers. We found this while doing local code modifications to the file. During the review of the changes, we noticed the redundant extern declarations and cleaned them up as part of good housekeeping.

Thanks,
Kaushlendra Kumar

maintainer
#3 lore raw
Quoted 7 lines · Kaushlendra
Quoted 1 line · Shuah Khan

Okay - are there errors from compilers or static checkers? How did you find the problem?

No errors from compilers or static checkers. We found this while doing local code modifications to the file. During the review of the changes, we noticed the redundant extern declarations and cleaned them up as part of good housekeeping.

There are a few other places in cpupower that can be fixed. Send me a patch that removes just the extern declarations without the parse_int_range() stuff

extern char *optarg;
extern int optind, opterr, optopt;

thanks,
-- Shuah

#4 lore raw
Quoted 6 lines

There are a few other places in cpupower that can be fixed. Send me a patch that removes just the extern declarations without the parse_int_range() stuff

extern char *optarg;
extern int optind, opterr, optopt;

Sure, will do.

Thanks,
Kaushlendra