From patchwork Tue Jun 11 09:13:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1113601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45NPSc6Vzbz9sDX; Tue, 11 Jun 2019 19:13:52 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hacqk-0005Ug-8w; Tue, 11 Jun 2019 09:13:50 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hacqj-0005UZ-Aw for fwts-devel@lists.ubuntu.com; Tue, 11 Jun 2019 09:13:49 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hacqi-0000DB-VQ; Tue, 11 Jun 2019 09:13:49 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] lib: fwts_formatting: use simpler style for assigments Date: Tue, 11 Jun 2019 10:13:48 +0100 Message-Id: <20190611091348.27785-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King Don't do double assignments and a null check in one go. Use a simpler code style to match coding style and clean up cppcheck warnings. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_formatting.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/src/fwts_formatting.c b/src/lib/src/fwts_formatting.c index 4e910d51..aee19388 100644 --- a/src/lib/src/fwts_formatting.c +++ b/src/lib/src/fwts_formatting.c @@ -40,9 +40,11 @@ static char *dup_line(const char *start, const char *end, const size_t width) if (maxlen < width) maxlen = width; - if ((bufptr = buffer = calloc(1, maxlen + 1)) == NULL) + buffer = calloc(1, maxlen + 1); + if (!buffer) return NULL; + bufptr = buffer; while (*start && start < end) *bufptr++ = *start++;