diff mbox

[1/2] cpufreq: exynos: Initialise return variable

Message ID 1358764194-22753-1-git-send-email-sachin.kamat@linaro.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Sachin Kamat Jan. 21, 2013, 10:29 a.m. UTC
'ret' is undefined when the function returns from the first
error condition. Without this patch we get the following warning:

drivers/cpufreq/exynos-cpufreq.c: In function ‘exynos_target’:
drivers/cpufreq/exynos-cpufreq.c:182:2: warning:
‘ret’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Jonghwan Choi <jhbird.choi@samsung.com>
---
 drivers/cpufreq/exynos-cpufreq.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

Comments

Sachin Kamat Jan. 21, 2013, 11:53 a.m. UTC | #1
Hi,
On 21 January 2013 17:15, jonghwan Choi <jhbird.choi@gmail.com> wrote:
> Hi.
> I already send a patch to fix it.
> But i set the 0 as a initial value.
> Because i thought that
> “
> if (frequeny_locked)
>      goto out; “
> is not a error case.
> How about your opinion?

I thought it was an error condition and hence assigned -EINVAL.
If it is not then 0 should be good enough as it represents success for
that function.

>
> 2013. 1. 21. ?? 7:38? "Sachin Kamat" <sachin.kamat@linaro.org>?? ??:
>>
>> 'ret' is undefined when the function returns from the first
>> error condition. Without this patch we get the following warning:
>>
>> drivers/cpufreq/exynos-cpufreq.c: In function ‘exynos_target’:
>> drivers/cpufreq/exynos-cpufreq.c:182:2: warning:
>> ‘ret’ may be used uninitialized in this function [-Wuninitialized]
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> Cc: Jonghwan Choi <jhbird.choi@samsung.com>
>> ---
>>  drivers/cpufreq/exynos-cpufreq.c |    6 ++----
>>  1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/cpufreq/exynos-cpufreq.c
>> b/drivers/cpufreq/exynos-cpufreq.c
>> index 218b3ce..38c6158 100644
>> --- a/drivers/cpufreq/exynos-cpufreq.c
>> +++ b/drivers/cpufreq/exynos-cpufreq.c
>> @@ -159,7 +159,7 @@ static int exynos_target(struct cpufreq_policy
>> *policy,
>>  {
>>         struct cpufreq_frequency_table *freq_table =
>> exynos_info->freq_table;
>>         unsigned int index;
>> -       int ret;
>> +       int ret = -EINVAL;
>>
>>         mutex_lock(&cpufreq_lock);
>>
>> @@ -167,10 +167,8 @@ static int exynos_target(struct cpufreq_policy
>> *policy,
>>                 goto out;
>>
>>         if (cpufreq_frequency_table_target(policy, freq_table,
>> -                                          target_freq, relation, &index))
>> {
>> -               ret = -EINVAL;
>> +                                          target_freq, relation, &index))
>>                 goto out;
>> -       }
>>
>>         freqs.new = freq_table[index].frequency;
>>
>> --
>> 1.7.4.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe cpufreq" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael Wysocki Jan. 22, 2013, 1:59 p.m. UTC | #2
On Monday, January 21, 2013 03:59:53 PM Sachin Kamat wrote:
> 'ret' is undefined when the function returns from the first
> error condition. Without this patch we get the following warning:
> 
> drivers/cpufreq/exynos-cpufreq.c: In function ‘exynos_target’:
> drivers/cpufreq/exynos-cpufreq.c:182:2: warning:
> ‘ret’ may be used uninitialized in this function [-Wuninitialized]

I'd prefer these two patches to go through the Exynos tree.

Thanks,
Rafael


> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Jonghwan Choi <jhbird.choi@samsung.com>
> ---
>  drivers/cpufreq/exynos-cpufreq.c |    6 ++----
>  1 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
> index 218b3ce..38c6158 100644
> --- a/drivers/cpufreq/exynos-cpufreq.c
> +++ b/drivers/cpufreq/exynos-cpufreq.c
> @@ -159,7 +159,7 @@ static int exynos_target(struct cpufreq_policy *policy,
>  {
>  	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
>  	unsigned int index;
> -	int ret;
> +	int ret = -EINVAL;
>  
>  	mutex_lock(&cpufreq_lock);
>  
> @@ -167,10 +167,8 @@ static int exynos_target(struct cpufreq_policy *policy,
>  		goto out;
>  
>  	if (cpufreq_frequency_table_target(policy, freq_table,
> -					   target_freq, relation, &index)) {
> -		ret = -EINVAL;
> +					   target_freq, relation, &index))
>  		goto out;
> -	}
>  
>  	freqs.new = freq_table[index].frequency;
>  
>
Sachin Kamat Jan. 23, 2013, 3:27 a.m. UTC | #3
+cc Kukjin

On 22 January 2013 19:29, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Monday, January 21, 2013 03:59:53 PM Sachin Kamat wrote:
>> 'ret' is undefined when the function returns from the first
>> error condition. Without this patch we get the following warning:
>>
>> drivers/cpufreq/exynos-cpufreq.c: In function ‘exynos_target’:
>> drivers/cpufreq/exynos-cpufreq.c:182:2: warning:
>> ‘ret’ may be used uninitialized in this function [-Wuninitialized]
>
> I'd prefer these two patches to go through the Exynos tree.

OK. I will post them to the Samsung list.

>
> Thanks,
> Rafael
>
>
diff mbox

Patch

diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 218b3ce..38c6158 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -159,7 +159,7 @@  static int exynos_target(struct cpufreq_policy *policy,
 {
 	struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
 	unsigned int index;
-	int ret;
+	int ret = -EINVAL;
 
 	mutex_lock(&cpufreq_lock);
 
@@ -167,10 +167,8 @@  static int exynos_target(struct cpufreq_policy *policy,
 		goto out;
 
 	if (cpufreq_frequency_table_target(policy, freq_table,
-					   target_freq, relation, &index)) {
-		ret = -EINVAL;
+					   target_freq, relation, &index))
 		goto out;
-	}
 
 	freqs.new = freq_table[index].frequency;