From: Dan Carpenter <dan.carpenter@oracle.com>
To: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>,
Thomas Renninger <trenn@suse.de>,
linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Alan Cox <alan@linux.intel.com>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/4] cpupower: Remove redundant error check
Date: Sat, 17 May 2014 20:22:55 +0000 [thread overview]
Message-ID: <20140517202255.GF15585@mwanda> (raw)
In-Reply-To: <1400350980-30455-2-git-send-email-peter.senna@gmail.com>
On Sat, May 17, 2014 at 08:22:58PM +0200, Peter Senna Tschudin wrote:
> diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
> index a416de8..4e2f35a 100644
> --- a/tools/power/cpupower/utils/cpufreq-set.c
> +++ b/tools/power/cpupower/utils/cpufreq-set.c
> @@ -320,12 +320,11 @@ int cmd_freq_set(int argc, char **argv)
>
> printf(_("Setting cpu: %d\n"), cpu);
> ret = do_one_cpu(cpu, &new_pol, freq, policychange);
> - if (ret)
> + if (ret) {
> + print_error();
> break;
Just return directly instead of break return;
> + }
> }
>
> - if (ret)
> - print_error();
> -
> return ret;
Are you sure this patch is correct? Theoretically, it's possible to
reach the end of this function without going hitting the
"ret = do_one_cpu(...);" assignment.
Don't be fooled by the "int ret = 0;" initialization, that is a trick
initialization to mislead the unwary. By the end of the do while loop
then "ret" is always -1.
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>,
Thomas Renninger <trenn@suse.de>,
linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Alan Cox <alan@linux.intel.com>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 2/4] cpupower: Remove redundant error check
Date: Sat, 17 May 2014 23:22:55 +0300 [thread overview]
Message-ID: <20140517202255.GF15585@mwanda> (raw)
In-Reply-To: <1400350980-30455-2-git-send-email-peter.senna@gmail.com>
On Sat, May 17, 2014 at 08:22:58PM +0200, Peter Senna Tschudin wrote:
> diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c
> index a416de8..4e2f35a 100644
> --- a/tools/power/cpupower/utils/cpufreq-set.c
> +++ b/tools/power/cpupower/utils/cpufreq-set.c
> @@ -320,12 +320,11 @@ int cmd_freq_set(int argc, char **argv)
>
> printf(_("Setting cpu: %d\n"), cpu);
> ret = do_one_cpu(cpu, &new_pol, freq, policychange);
> - if (ret)
> + if (ret) {
> + print_error();
> break;
Just return directly instead of break return;
> + }
> }
>
> - if (ret)
> - print_error();
> -
> return ret;
Are you sure this patch is correct? Theoretically, it's possible to
reach the end of this function without going hitting the
"ret = do_one_cpu(...);" assignment.
Don't be fooled by the "int ret = 0;" initialization, that is a trick
initialization to mislead the unwary. By the end of the do while loop
then "ret" is always -1.
regards,
dan carpenter
next prev parent reply other threads:[~2014-05-17 20:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-17 18:22 [PATCH 2/4] cpupower: Remove redundant error check Peter Senna Tschudin
2014-05-17 18:22 ` Peter Senna Tschudin
2014-05-17 20:22 ` Dan Carpenter [this message]
2014-05-17 20:22 ` Dan Carpenter
2014-05-17 21:34 ` Peter Senna Tschudin
2014-05-17 21:34 ` Peter Senna Tschudin
2014-05-17 21:56 ` Dan Carpenter
2014-05-17 21:56 ` Dan Carpenter
2014-05-17 22:31 ` Peter Senna Tschudin
2014-05-17 22:31 ` Peter Senna Tschudin
2014-05-17 22:42 ` Dan Carpenter
2014-05-17 22:42 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140517202255.GF15585@mwanda \
--to=dan.carpenter@oracle.com \
--cc=alan@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=peter.senna@gmail.com \
--cc=rafael.j.wysocki@intel.com \
--cc=trenn@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.