From patchwork Mon Jun 10 11:10:36 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: 1113029 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 45Mr5s345Tz9sDX; Mon, 10 Jun 2019 21:10:40 +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 1haICD-0004dQ-QA; Mon, 10 Jun 2019 11:10:37 +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 1haICC-0004dK-LT for fwts-devel@lists.ubuntu.com; Mon, 10 Jun 2019 11:10:36 +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 1haICC-00024s-91; Mon, 10 Jun 2019 11:10:36 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] lib: fwts_cpu: only assign a string if it has not yet been assigned Date: Mon, 10 Jun 2019 12:10:36 +0100 Message-Id: <20190610111036.22630-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 This just cleans up some static analysis warnings Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_cpu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/src/fwts_cpu.c b/src/lib/src/fwts_cpu.c index e866d1dc..71e0e877 100644 --- a/src/lib/src/fwts_cpu.c +++ b/src/lib/src/fwts_cpu.c @@ -151,7 +151,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu) found = true; - if (!strncmp(buffer, "vendor_id", 9)) { + if (!cpu->vendor_id && !strncmp(buffer, "vendor_id", 9)) { cpu->vendor_id = strdup(ptr); continue; } @@ -159,7 +159,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu) sscanf(ptr, "%d", &cpu->x86); continue; } - if (!strncmp(buffer, "model name", 10)) { + if (!cpu->model_name && !strncmp(buffer, "model name", 10)) { cpu->model_name = strdup(ptr); continue; } @@ -171,7 +171,7 @@ fwts_cpuinfo_x86 *fwts_cpu_get_info(int which_cpu) sscanf(ptr, "%d", &cpu->stepping); continue; } - if (!strncmp(buffer, "flags", 5)) { + if (!cpu->flags && !strncmp(buffer, "flags", 5)) { cpu->flags = strdup(ptr); continue; }