From patchwork Thu Mar 8 13:48:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 131021 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp6498383lja; Thu, 8 Mar 2018 05:49:02 -0800 (PST) X-Google-Smtp-Source: AG47ELtBRYKD17sPFz7HbeidR5qbHs47iRCLi6Y4Agur+qlYDFNXgLXEqhe0Y8AqJQ2kC3PqtK4d X-Received: by 10.99.124.14 with SMTP id x14mr21152239pgc.290.1520516942336; Thu, 08 Mar 2018 05:49:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520516942; cv=none; d=google.com; s=arc-20160816; b=m0XMrsuN0TR09gJ9RvT6tJSCwdyx0XHJgEKjdcEpIAR1pci/kLNMW22sMUK1N7usuF 5AGKEvSNFrMd64iXaw7kfKnZBfYMWLKmp8qKguRRn0J+W4MmF2RmdDS8WvYGg5U6E1Rt HFkNkzgFDOC+Leqa3e4RfYzZhimLGaN/vN9krzHQjf3jDMYyRCJnunslSQOSxlrkqnUP XOSj0Q9lXs9pSdCcxRr8+heRwrVI5Nk0Mxpoq1m1rz5leczTI2rntMtrST7PudNuAenO SZkX7dPTbH3MhvVi6sfXgT7NXQfVpjWv7nZtrq7pwgY2ONi0ND9KOA1KD3gXQvfNG5FH ZQwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=zhTiCAN+ob/S0H3FZ/pgsIvXhvCTP/L/w3ghNkEu0CA=; b=J4Xjs1KZgtVBOiwiLWpPY8oBx4yKXpWOTtSdaew7FI7xSHJk8oRbykYuiFK8Ha+Zuy eDVTvcKE5i511ASXvrhfGthnXQN09J9Bq3IOQMa0R821jtQ71y2kHNmsAiD1ODGY9UBg lyLM+aoXh+dUFPemMOTzt9SMc2mZCztqFcBveZl5stO2BBnUQ1kT8l1Iuu6EUGRtkqJi V/gZ5Atm0zWxDgcMXQyueteV475+2WPWOuFZtc22wQjf1h1Z7xsm7N5MRgUkPVTrpEOW LJSY3G4hLGVxMH+jq2a1lrtjr26PAya9uc4BGGad+BrQ1Cf30ZEIznrW0bv8gdsxPOmA FASA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b5wRXkwj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n64si15692778pfb.281.2018.03.08.05.49.01; Thu, 08 Mar 2018 05:49:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b5wRXkwj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755929AbeCHNs6 (ORCPT + 28 others); Thu, 8 Mar 2018 08:48:58 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:38200 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755898AbeCHNs5 (ORCPT ); Thu, 8 Mar 2018 08:48:57 -0500 Received: by mail-lf0-f68.google.com with SMTP id i80-v6so8402792lfg.5 for ; Thu, 08 Mar 2018 05:48:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zhTiCAN+ob/S0H3FZ/pgsIvXhvCTP/L/w3ghNkEu0CA=; b=b5wRXkwj5UFbpVLNNACJ76YPOWqNN1DGNld+bMRy9EkG6Dzr7N99hXWXHx5JdksDx4 e3e8lA/oB8P7OmL4whdmtSZG7KSnwOsc8qqnoXUiTEb/15xxVOE3qhkUB5sMWNraWxt8 zh9pBbtYhZZkt+6eoEXQr62DJm2U1t52WsqfM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zhTiCAN+ob/S0H3FZ/pgsIvXhvCTP/L/w3ghNkEu0CA=; b=Ml8vA1jQprQf9JNOcwyHqY7U+RXzQ/s7kL8p+murxkMTmNu8lvpZtmT5kE1H4DOXfD Qxu5vGyfouM8ng5aGlFuGWhLW5VRWqlbpSGRkzWMiAlKcj4FI+Lb5T3a6nqhm9QhUgzJ zmvfhnClxWWR1bJT6feoGjvBH2cTY/Cjz/jD6CBVHvmHkyRS/o/lPPqRIfVdoRA/+7pl nI6v1U9LztIofpC3WiT1kBQIRUAalC4Xi71duDyLG+QtQQs69V+jtDdm82GXqchfWsge wXMpeY2y5Ui9S32mYmZEhZuBM5I7y9MPqi4x3UyB8tPWtE3nfM6aNJ38WXmI9CyXbkDY u7GA== X-Gm-Message-State: APf1xPCgG2WRNnaPl6Eut+Wpes0stu5SGg7Hjmz3XXviYgPRx4GieBoq 4COj0kulECneo/NK/4KR2myjVp7pyms= X-Received: by 10.46.86.201 with SMTP id k70mr18179779lje.16.1520516935611; Thu, 08 Mar 2018 05:48:55 -0800 (PST) Received: from localhost (c-2c3d70d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.61.44]) by smtp.gmail.com with ESMTPSA id b76sm272002lfh.65.2018.03.08.05.48.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 05:48:54 -0800 (PST) From: Anders Roxell To: shuah@kernel.org Cc: pintu.ping@gmail.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Anders Roxell Subject: [PATCH] selftests/android/ion: fix heap_type may be uninitialized Date: Thu, 8 Mar 2018 14:48:45 +0100 Message-Id: <20180308134845.32409-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc warns that 'heap_type' is not initialized if we don't come through any of the two 'case' statesments before: ionapp_export.c:91:2: warning: ‘heap_type’ may be used uninitialized in this function [-Wmaybe-uninitialized] printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the current code, we initialize the heap_type to -1 before the 'case' statements. We also change the print_usage function to state that heap_type and heap_size isn't optional, they are mandatory. Fixes: 47a18c42d992 ("android/ion: userspace test utility for ion buffer sharing") Signed-off-by: Anders Roxell --- .../testing/selftests/android/ion/ionapp_export.c | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/tools/testing/selftests/android/ion/ionapp_export.c b/tools/testing/selftests/android/ion/ionapp_export.c index a944e72621a9..b42f803e9d2a 100644 --- a/tools/testing/selftests/android/ion/ionapp_export.c +++ b/tools/testing/selftests/android/ion/ionapp_export.c @@ -31,16 +31,24 @@ void print_usage(int argc, char *argv[]) { - printf("Usage: %s [-h ] [-i ] [-s ]\n", + printf("Usage: %s [-h ] -i -s \n", argv[0]); } +void heap_type_error_text(void) +{ + printf("heap_type must be specified\n"); + printf(" need to specify -i \n"); + printf(" supported heap types 0 or 1\n"); +} + int main(int argc, char *argv[]) { int opt, ret, status, heapid; int sockfd, client_fd, shared_fd; unsigned char *map_buf; - unsigned long map_len, heap_type, heap_size, flags; + unsigned long map_len, heap_size, flags; + long heap_type; struct ion_buffer_info info; struct socket_info skinfo; @@ -50,6 +58,7 @@ int main(int argc, char *argv[]) } heap_size = 0; + heap_type = -1; flags = 0; while ((opt = getopt(argc, argv, "hi:s:")) != -1) { @@ -68,7 +77,8 @@ int main(int argc, char *argv[]) heap_type = ION_HEAP_TYPE_SYSTEM_CONTIG; break; default: - printf("ERROR: heap type not supported\n"); + heap_type_error_text(); + print_usage(argc, argv); exit(1); } break; @@ -82,8 +92,15 @@ int main(int argc, char *argv[]) } } + if (heap_type < 0) { + heap_type_error_text(); + print_usage(argc, argv); + exit(1); + } + if (heap_size <= 0) { printf("heap_size cannot be 0\n"); + printf(" need to specify -s \n"); print_usage(argc, argv); exit(1); }