From patchwork Mon Mar 28 15:23:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 64534 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1507242lbc; Mon, 28 Mar 2016 08:24:17 -0700 (PDT) X-Received: by 10.107.38.201 with SMTP id m192mr25899185iom.2.1459178656979; Mon, 28 Mar 2016 08:24:16 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id qo6si8703980igb.37.2016.03.28.08.24.16; Mon, 28 Mar 2016 08:24:16 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 676B661677; Mon, 28 Mar 2016 15:24:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D880F6168F; Mon, 28 Mar 2016 15:23:46 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1A22661611; Mon, 28 Mar 2016 15:23:43 +0000 (UTC) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by lists.linaro.org (Postfix) with ESMTPS id E4BC66160F for ; Mon, 28 Mar 2016 15:23:41 +0000 (UTC) Received: by mail-lb0-f175.google.com with SMTP id vo2so31105176lbb.1 for ; Mon, 28 Mar 2016 08:23:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=r0jQntbKe5UX6ibtLxkQujOQrcrq1lAYY7EWBkunJFo=; b=KmJa9txrst/LdDi2aBEaOd0j3VD3KOUwiFg90UMUkHkUktasHOPwrzGa2EoRyQ6n9s FbuZPIEg5iecKnOATp6WKrTg9uEYh4khvHGL606vvVFYjpmSUzttXG40BKg8pjYQcoyZ MawEszRs3eYKJAUba7wfUGZLtMoV3S7VBB0LrHOFPan8uPqvUEqM/f0hIJ8siY0L1BmC ek4pq0vLACj4whDJn8W/ZVCk0BO2sp0m4eWm/2JlQTXYAmB9vzc8fVFO0JIjUkYFW02E B9+XygfbZK0Tx1avx4RvL960v7vINEreZaIDNCOMWNVFLCOR+TpcYzuyszNAX0taO5// atGw== X-Gm-Message-State: AD7BkJJeCXvhbc2DrtywhQUjQEOLwwxF3+iL2q4DNvLz7vEDg1dSQYSJl5N3GymUgHZ9ctgLlCI= X-Received: by 10.112.172.233 with SMTP id bf9mr10243569lbc.121.1459178620792; Mon, 28 Mar 2016 08:23:40 -0700 (PDT) Received: from localhost.localdomain (ppp91-77-172-79.pppoe.mtu-net.ru. [91.77.172.79]) by smtp.gmail.com with ESMTPSA id f7sm4641720lfg.19.2016.03.28.08.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Mar 2016 08:23:40 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 28 Mar 2016 18:23:32 +0300 Message-Id: <1459178612-10830-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 In-Reply-To: <1459178612-10830-1-git-send-email-maxim.uvarov@linaro.org> References: <1459178612-10830-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 2/2] linux-generic: system info: check return codes for sscanf X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Check return codes for Coverity issues: https://bugs.linaro.org/show_bug.cgi?id=2129 Signed-off-by: Maxim Uvarov Reviewed-by: Mike Holmes --- platform/linux-generic/odp_system_info.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 395b274..0277c3b 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -66,7 +66,8 @@ static int systemcpu_cache_line_size(void) if (fgets(str, sizeof(str), file) != NULL) { /* Read cache line size */ - sscanf(str, "%i", &size); + if (sscanf(str, "%i", &size) != 1) + size = 0; } fclose(file); @@ -99,7 +100,9 @@ static int huge_page_size(void) while ((dirent = readdir(dir)) != NULL) { int temp = 0; - sscanf(dirent->d_name, "hugepages-%i", &temp); + + if (sscanf(dirent->d_name, "hugepages-%i", &temp) != 1) + continue; if (temp > size) size = temp; @@ -110,7 +113,7 @@ static int huge_page_size(void) return 0; } - return size*1024; + return size * 1024; }