From patchwork Tue Aug 14 11:24:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 957443 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-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41qVcX6p1Rz9s9F; Tue, 14 Aug 2018 21:24:44 +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 1fpXRJ-0007mO-7B; Tue, 14 Aug 2018 11:24:41 +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 1fpXRH-0007kk-Mt for fwts-devel@lists.ubuntu.com; Tue, 14 Aug 2018 11:24:39 +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 1fpXRH-0001yS-Bb; Tue, 14 Aug 2018 11:24:39 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 08/13] lib: fwts_keymap: some minor fwts coding style changes Date: Tue, 14 Aug 2018 12:24:30 +0100 Message-Id: <20180814112435.22166-9-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814112435.22166-1-colin.king@canonical.com> References: <20180814112435.22166-1-colin.king@canonical.com> 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 No functional change. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_keymap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/src/fwts_keymap.c b/src/lib/src/fwts_keymap.c index a3256630..296c7443 100644 --- a/src/lib/src/fwts_keymap.c +++ b/src/lib/src/fwts_keymap.c @@ -31,6 +31,7 @@ static void fwts_keymap_keycode_free(void *data) { fwts_keycode *keycode = (fwts_keycode*)data; + free(keycode->keyname); free(keycode->keytext); free(keycode); @@ -70,24 +71,23 @@ fwts_list *fwts_keymap_load(const char *machine) while (fgets(buffer, sizeof(buffer), fp) != NULL) { fwts_keycode *key; char *str = buffer; - int scancode; char *keyname = NULL; char *keytext = NULL; + int scancode; scancode = strtoul(buffer, &str, 16); - - if (str == NULL || *str == '\0') + if ((str == NULL) || (*str == '\0')) continue; /* Skip over whitespace */ - while (*str != '\0' && isspace(*str)) + while ((*str != '\0') && isspace(*str)) str++; if (*str == '\0') continue; keyname = str; /* Skip over keyname */ - while (*str != '\0' && !isspace(*str)) + while ((*str != '\0') && !isspace(*str)) str++; keytext = keyname; /* Default if we cannot find human readable name */ @@ -132,6 +132,7 @@ fwts_keycode *fwts_keymap_find_scancode(fwts_list *keymap, const int scancode) fwts_list_foreach(item, keymap) { fwts_keycode *keycode = fwts_list_data(fwts_keycode*, item); + if (keycode->scancode == scancode) return keycode; }