From patchwork Tue Jul 29 16:12:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Renninger X-Patchwork-Id: 4641161 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5BEA2C0338 for ; Tue, 29 Jul 2014 16:12:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83A0820142 for ; Tue, 29 Jul 2014 16:12:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCA582012D for ; Tue, 29 Jul 2014 16:12:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752154AbaG2QMw (ORCPT ); Tue, 29 Jul 2014 12:12:52 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48925 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063AbaG2QMw (ORCPT ); Tue, 29 Jul 2014 12:12:52 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7B630AC1F; Tue, 29 Jul 2014 16:12:44 +0000 (UTC) From: Thomas Renninger To: rjw@rjwysocki.net Cc: linux-pm@vger.kernel.org, Peter Senna Tschudin , Thomas Renninger Subject: [PATCH 3/3] cpupower: Remove redundant error check Date: Tue, 29 Jul 2014 18:12:20 +0200 Message-Id: <1406650340-38644-3-git-send-email-trenn@suse.de> X-Mailer: git-send-email 1.7.6.1 In-Reply-To: <1406650340-38644-1-git-send-email-trenn@suse.de> References: <2377922.j9jRKZAKtD@vostro.rjw.lan> <1406650340-38644-1-git-send-email-trenn@suse.de> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Senna Tschudin Remove double checks, and move the call to print_error to the first check. Replace break by return, and return 0 on success. The simplified version of the coccinelle semantic patch that fixes this issue is as follows: // @@ expression E; identifier pr; expression list es; @@ for(...;...;...){ ... - if (E) break; + if (E){ + pr(es); + break; + } ... } - if(E) pr(es); // Untested. Signed-off-by: Peter Senna Tschudin Signed-off-by: Thomas Renninger --- tools/power/cpupower/utils/cpufreq-set.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/power/cpupower/utils/cpufreq-set.c b/tools/power/cpupower/utils/cpufreq-set.c index a416de8..f656e58 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) - break; + if (ret) { + print_error(); + return ret; + } } - if (ret) - print_error(); - - return ret; + return 0; }