Skip to contentSkip to conversation

drivers: cpufreq: Mark function as static in cpufreq.c

PATCH Superseded Rashika Kheria 5 participants 9 messages Feb 26, 2014 – Mar 3, 2014 1 message not in the archive CPU frequency scaling framework

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]@rashika

#1 lore raw

PATCH v2 1/1 drivers: cpufreq: Mark function as static in cpufreq.c

Mark function as static in cpufreq.c because it is not used outside this file.

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for ‘show_boost’ [-Wmissing-prototypes]

---
 drivers/cpufreq/cpufreq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
index 08ca8c9..54fd670 100644
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
 /*********************************************************************
  *                          SYSFS INTERFACE                          *
  *********************************************************************/
-ssize_t show_boost(struct kobject *kobj,
+static ssize_t show_boost(struct kobject *kobj,
 				 struct attribute *attr, char *buf)
 {
 	return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 7 lines · Rashika Kheria

Mark function as static in cpufreq.c because it is not used outside this file.

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for ‘show_boost’ [-Wmissing-prototypes]

I don't see any uses of this function in cpufreq.c; have uses appeared in a development branch?

Quoted 19 lines
 drivers/cpufreq/cpufreq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
index 08ca8c9..54fd670 100644
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
 /*********************************************************************
  *                          SYSFS INTERFACE                          *
  *********************************************************************/
-ssize_t show_boost(struct kobject *kobj,
+static ssize_t show_boost(struct kobject *kobj,
 				 struct attribute *attr, char *buf)
 {
 	return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
Signature · 1 line
1.7.9.5
#3 lore raw
Quoted 4 lines · Josh Triplett
Quoted 3 lines · Rashika Kheria

Mark function as static in cpufreq.c because it is not used outside this file.

Quoted 8 lines
Quoted 4 lines

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for 'show_boost' [-Wmissing-prototypes]

I don't see any uses of this function in cpufreq.c; have uses appeared in a development branch?

It isn't used directly but through "define_one_global_rw(boost);".

The "define_one_global_rw()" is defined in include/linux/cpufreq.h. It therefore, need the definition of the function.

Quoted 19 lines
Quoted 19 lines
 drivers/cpufreq/cpufreq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -2
index 08ca8c9..54fd670 100644
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
 /*********************************************************************
  *                          SYSFS INTERFACE                          *
  *********************************************************************/
-ssize_t show_boost(struct kobject *kobj,
+static ssize_t show_boost(struct kobject *kobj,
                               struct attribute *attr, char *buf)
 {
      return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
--

1.7.9.5

Signature · 3 lines
Rashika Kheria
B.Tech CSE
IIIT Hyderabad
Reviewed-by
#4 lore raw
Quoted 10 lines · Rashika Kheria
Quoted 9 lines · Josh Triplett
Quoted 7 lines · Rashika Kheria

Mark function as static in cpufreq.c because it is not used outside this file.

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for 'show_boost' [-Wmissing-prototypes]

Quoted 8 lines
Quoted 3 lines

I don't see any uses of this function in cpufreq.c; have uses appeared in a development branch?

It isn't used directly but through "define_one_global_rw(boost);".

The "define_one_global_rw()" is defined in include/linux/cpufreq.h. It therefore, need the definition of the function.

Ah, that's quite non-obvious. Hiding the "show_" makes that hard to grep for.

Quoted 26 lines
Quoted 19 lines
Quoted 19 lines
 drivers/cpufreq/cpufreq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -2
index 08ca8c9..54fd670 100644
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
 /*********************************************************************
  *                          SYSFS INTERFACE                          *
  *********************************************************************/
-ssize_t show_boost(struct kobject *kobj,
+static ssize_t show_boost(struct kobject *kobj,
                               struct attribute *attr, char *buf)
 {
      return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
--

1.7.9.5

Signature · 3 lines
Rashika Kheria
B.Tech CSE
IIIT Hyderabad
maintainer
#5 lore raw

Hi Rashika,

Quoted 5 lines · Rashika Kheria

Mark function as static in cpufreq.c because it is not used outside this file.

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for 'show_boost' [-Wmissing-prototypes]

Can you please elaborate how this warning is related to the non-static definition of this function?

Quoted 21 lines
---
 drivers/cpufreq/cpufreq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -2
index 08ca8c9..54fd670 100644
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
 /*********************************************************************
  *                          SYSFS INTERFACE                          *
  *********************************************************************/
-ssize_t show_boost(struct kobject *kobj,
+static ssize_t show_boost(struct kobject *kobj,
                                 struct attribute *attr, char *buf)
 {
        return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
--

1.7.9.5

maintainer
#6 lore raw
Quoted 11 lines · Viresh Kumar

Hi Rashika,

Quoted 5 lines · Rashika Kheria

Mark function as static in cpufreq.c because it is not used outside this file.

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for 'show_boost' [-Wmissing-prototypes]

Can you please elaborate how this warning is related to the non-static definition of this function?

Ping!!

#7 lore raw
In reply to Viresh Kumar
Quoted 11 lines · Viresh Kumar

Hi Rashika,

Quoted 5 lines · Rashika Kheria

Mark function as static in cpufreq.c because it is not used outside this file.

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for 'show_boost' [-Wmissing-prototypes]

Can you please elaborate how this warning is related to the non-static definition of this function?

-Wmissing-prototypes warns when a non-static function is defined before a corresponding prototype (usually inside an included header file) is declared. In such a case, it is impossible to reference the non-static function from another file, and therefore the function should be marked static (usually). Hope that makes sense!

maintainer
#8 lore raw
Quoted 5 lines · Patrick Palka

-Wmissing-prototypes warns when a non-static function is defined before a corresponding prototype (usually inside an included header file) is declared. In such a case, it is impossible to reference the non-static function from another file, and therefore the function should be marked static (usually). Hope that makes sense!

I understand that it should be made static as we don't have a prototype in any other header file, but I thought we shouldn't get the warning we are getting.

warning: no previous prototype for 'show_boost'

Because we have prototype/definition of function before it is used. Maybe a warning like:

local function should be marked static could have been there ;)

#9 lore raw
In reply to Josh Triplett
Quoted 4 lines · Josh Triplett
Quoted 3 lines · Rashika Kheria

Mark function as static in cpufreq.c because it is not used outside this file.

Quoted 8 lines
Quoted 4 lines

This eliminates the following warning in cpufreq.c:
drivers/cpufreq/cpufreq.c:355:9: warning: no previous prototype for ‘show_boost’ [-Wmissing-prototypes]

I don't see any uses of this function in cpufreq.c; have uses appeared in a development branch?

This is a sysfs accessor used to control the boost feature it is not used by the core but userspace.

Quoted 24 lines
Quoted 17 lines
  drivers/cpufreq/cpufreq.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -2
index 08ca8c9..54fd670 100644
@@ -352,7 +352,7 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_post_transition);
  /*********************************************************************
   *                          SYSFS INTERFACE                          *
   *********************************************************************/
-ssize_t show_boost(struct kobject *kobj,
+static ssize_t show_boost(struct kobject *kobj,
  				 struct attribute *attr, char *buf)
  {
  	return sprintf(buf, "%d\n", cpufreq_driver->boost_enabled);
--
Quoted 2 lines

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe cpufreq" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html