From patchwork Thu Jun 16 20:29:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1995 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B390723E54 for ; Thu, 16 Jun 2011 20:31:48 +0000 (UTC) Received: from mail-vx0-f180.google.com (mail-vx0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id 83544A18585 for ; Thu, 16 Jun 2011 20:31:48 +0000 (UTC) Received: by mail-vx0-f180.google.com with SMTP id 12so2092663vxk.11 for ; Thu, 16 Jun 2011 13:31:48 -0700 (PDT) Received: by 10.52.98.97 with SMTP id eh1mr1965067vdb.7.1308256308322; Thu, 16 Jun 2011 13:31:48 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs211209vdc; Thu, 16 Jun 2011 13:31:47 -0700 (PDT) Received: by 10.227.9.131 with SMTP id l3mr1405129wbl.54.1308256304302; Thu, 16 Jun 2011 13:31:44 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr [80.12.242.130]) by mx.google.com with ESMTP id o17si1342977wbh.88.2011.06.16.13.31.43; Thu, 16 Jun 2011 13:31:44 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.130 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.130; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.130 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([92.134.76.78]) by mwinf5d16 with ME id wkXf1g0031hMfSL03kXjJc; Thu, 16 Jun 2011 22:31:43 +0200 From: Daniel Lezcano To: patches@linaro.org Subject: [PATCH 10/28] fix segfault when the default window is not the clock Date: Thu, 16 Jun 2011 22:29:39 +0200 Message-Id: <1308256197-29155-10-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308256197-29155-1-git-send-email-daniel.lezcano@linaro.org> References: <1308256197-29155-1-git-send-email-daniel.lezcano@linaro.org> Signed-off-by: Daniel Lezcano --- clocks.c | 2 +- powerdebug.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/clocks.c b/clocks.c index d08c926..ecc72ea 100644 --- a/clocks.c +++ b/clocks.c @@ -255,7 +255,7 @@ int read_and_print_clock_info(int verbose, int hrow, int selected) read_clock_info(clk_dir_path); } - if (!clocks_info->num_children) { + if (!clocks_info || !clocks_info->num_children) { fprintf(stderr, "powerdebug: No clocks found. Exiting..\n"); exit(1); } diff --git a/powerdebug.c b/powerdebug.c index 5fe07de..94dd31a 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -251,19 +251,18 @@ int mainloop(struct powerdebug_options *options, create_windows(options->selectedwindow); show_header(options->selectedwindow); + create_selectedwindow(options->selectedwindow); - if (options->regulators || options->selectedwindow == REGULATOR) { + if (options->selectedwindow == REGULATOR) { regulator_read_info(reg_info, nr_reg); - create_selectedwindow(options->selectedwindow); show_regulator_info(reg_info, nr_reg, options->verbose); } - if (options->clocks || options->selectedwindow == CLOCK) { + if (options->selectedwindow == CLOCK) { int hrow; - create_selectedwindow(options->selectedwindow); if (!findparent_ncurses) { int command = 0; @@ -282,10 +281,8 @@ int mainloop(struct powerdebug_options *options, enter_hit); } - if (options->sensors || options->selectedwindow == SENSOR) { - create_selectedwindow(options->selectedwindow); + if (options->selectedwindow == SENSOR) print_sensor_header(); - } FD_ZERO(&readfds); FD_SET(0, &readfds);