From patchwork Wed Jun 19 03:52:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 252473 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4D69D2C02BB for ; Wed, 19 Jun 2013 13:55:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6A034A052; Wed, 19 Jun 2013 05:54:49 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ELp248fnXbuI; Wed, 19 Jun 2013 05:54:49 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 44C1E4A053; Wed, 19 Jun 2013 05:53:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 062144A021 for ; Wed, 19 Jun 2013 05:53:33 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mJmwGLUMvOyP for ; Wed, 19 Jun 2013 05:53:24 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qe0-f74.google.com (mail-qe0-f74.google.com [209.85.128.74]) by theia.denx.de (Postfix) with ESMTPS id 3DB204A026 for ; Wed, 19 Jun 2013 05:53:04 +0200 (CEST) Received: by mail-qe0-f74.google.com with SMTP id a11so551017qen.3 for ; Tue, 18 Jun 2013 20:53:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/QzfWHTlJ2YeXFJNRRB2ICl2o3gQY8Wzkp9TkeHzvmA=; b=fLtBJLnaGAtt8c7Np4W08fmsG4aloNecZFscWo/NM4SEy8lERyrPui/E7Sp3mhEXf0 udYZ54VF+Jd9sPqnoyLVSffiJbyiQCNKqX6O6cdikjKlW3GtzbzzmiHcj0Mc7Pm+CWCl tjPRCO2ODm/rPbpKupDJmmOHgRd++5fF5z+r3xER1P2FAGmt+EClLw7P+g3IpxDt0MDG c6IwfuvNLnWWn3tqZwacv8BXnKTN3D/cWvqlVMDvpifcKPn+woQ5upgq9pZ2dxZ0EWoc i82hBxuTcUrig8U0cWnb8mvkQ9Dn+/akkpgLTt10srF9u18Hqn8HFCtVGr4wYmraSZVT z5Xg== X-Received: by 10.236.223.162 with SMTP id v32mr578438yhp.25.1371613983398; Tue, 18 Jun 2013 20:53:03 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id o24si1350550yhm.1.2013.06.18.20.53.03 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 18 Jun 2013 20:53:03 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 3EFBD31C016; Tue, 18 Jun 2013 20:53:03 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id EC5FA16099F; Tue, 18 Jun 2013 20:53:02 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 18 Jun 2013 20:52:29 -0700 Message-Id: <1371613960-28678-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.3 In-Reply-To: <1371613960-28678-1-git-send-email-sjg@chromium.org> References: <1371613960-28678-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmha4rqcJjeSmvClpCUsZSb4WAA1gH3VbYvO5ZYwKpjLO4XkJWmQW/kwr67o1PTSfHQhW7LQpvWkvagDaTjJruTAJDyq80aA6dMt5erWzZCHGSR5Y3K3WGovlo5dCJZsG+YJBVYol6AALMrAdvql88LS2oa9VfengUxzyLn+ASEIw4/tXE+I0Ribe52YxIuKtHyU4Nv Cc: Tom Rini , u-boot-review@google.com Subject: [U-Boot] [PATCH v3 05/16] Add cmd_process_error() to report and process errors X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de U-Boot now uses errors defined in include/errno.h which are negative integers. Commands which fail need to report the error and return 1 to indicate failure. Add this functionality in cmd_process_error(). For now this merely reports the error number. It would be possible also to produce a helpful error message by storing the error strings in U-Boot. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/command.c | 10 ++++++++++ include/command.h | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/common/command.c b/common/command.c index 305a236..70faa60 100644 --- a/common/command.c +++ b/common/command.c @@ -554,3 +554,13 @@ enum command_ret_t cmd_process(int flag, int argc, char * const argv[], rc = cmd_usage(cmdtp); return rc; } + +int cmd_process_error(cmd_tbl_t *cmdtp, int err) +{ + if (err) { + printf("Command '%s' failed: Error %d\n", cmdtp->name, err); + return 1; + } + + return 0; +} diff --git a/include/command.h b/include/command.h index 65692fd..e82c555 100644 --- a/include/command.h +++ b/include/command.h @@ -80,6 +80,15 @@ extern int var_complete(int argc, char * const argv[], char last_char, int maxv, extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp); #endif +/** + * cmd_process_error() - report and process a possible error + * + * @cmdtp: Command which caused the error + * @err: Error code (0 if none, -ve for error, like -EIO) + * @return 0 if there is not error, 1 (CMD_RET_FAILURE) if an error is found + */ +int cmd_process_error(cmd_tbl_t *cmdtp, int err); + /* * Monitor Command *