From patchwork Thu Apr 5 07:39:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 132844 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp5973505ljb; Thu, 5 Apr 2018 00:39:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/8nfyarSdJtBB4l+z2TsDnA9foBRu0zxvHZnEbiTpYN7aBLDHDhC+9UkrrGAq36hbgHbgn X-Received: by 10.99.182.73 with SMTP id v9mr13953771pgt.158.1522913956389; Thu, 05 Apr 2018 00:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522913956; cv=none; d=google.com; s=arc-20160816; b=fNG+Te71h9mdlfOA0OWSRBqmrnKLw6c+tl8WwF67dhnP1z2Jt39iG0/WvWCgBF9P7H hzwWxPFpep2LVEt5IhRN7nHTO63fWqEZgd5MmxCjL2LqMitr7jGli0Agx4vii6dCVcnv VUHvSBKZNvZuGSDT2eTguEjhC/NzRTKNxZ7tA10UDFxLmRQFiIEjehDhfE11EPgjqMf/ Z3iZit5sbzgOVG4xxne8SN6tLVImlIbMO90pyppKv/bVKMyXJZcKnXr7GwokZl7URHaN x2KwjYa/45mXzQXlPWwFBcqwJvwR3wioI8bVrSQ6bfHAmaFeBnRwe3NOhvo6xtG6Quz8 2QKQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=EbLXaGPGrnqli6mj8yoKM+14md8vLgU9Dn4bmtzTz5g=; b=F+/ntZBEYX1eng+Jlju7bJJj5ppvGRWm0RkH/v0PNenKDFIkMzCPkumtXJIzg6Hzrq ghS+B6ud8XWHNw9c1aA/mi1Ow4h103MXLpOosjZkaadmK3Za0iD38EeXkZR9hKoogkxk Z6LBx7zPxovBsTlv0Lz+JRgrhXo9FnnWl3Mswuv0nC0+Z/UJL/6VC9niHz4oebBHUPy6 E0RcD0eturot3uodm8na1CGhaPhyoJyxWbUMM2LAjXFz2lcjYT6IvF2xZEdHjMJziQ3Q tE3lOik+i8ukfDHbBmtR7JEXtHioFTiXWMX/SBps548re8wqg/2anOsQqtW7Te1lNqlA Sk6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jrtjesCi; 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 k76si5732284pfb.146.2018.04.05.00.39.16; Thu, 05 Apr 2018 00:39:16 -0700 (PDT) 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=jrtjesCi; 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 S1751277AbeDEHjO (ORCPT + 29 others); Thu, 5 Apr 2018 03:39:14 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33282 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751097AbeDEHjM (ORCPT ); Thu, 5 Apr 2018 03:39:12 -0400 Received: by mail-wm0-f65.google.com with SMTP id o23so1603994wmf.0 for ; Thu, 05 Apr 2018 00:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EbLXaGPGrnqli6mj8yoKM+14md8vLgU9Dn4bmtzTz5g=; b=jrtjesCiOUKaI5oxouOFyRf3cKNUTw0BYWKXhDJ2wHU4LF9uuNuK4vVE1jW0xatF0M b+ymdiE8iKQLbcDLXEAChJM/bi7T2Qk2PGr47+Tw/062dwQa3PdJtHJrnFlBOLZ4EiTp /5uGiV/EiGqu5WF8+do4flHZ13dRB9+5oGnqA= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=EbLXaGPGrnqli6mj8yoKM+14md8vLgU9Dn4bmtzTz5g=; b=Jrm7Hf3i1xZp4iwhny9FaCrnD+5MgR2LbCaGlBoOoVCO85LVNme7WCP+O+MvLtc5xX SwoGmgqdXoZrS/ZfleyLjChBeI33qwA9f/pkOOhMHZbyFHwlqc9jomqADpqcYssIJDrw KewjFNPc6oFuAZcTQddppselXlrTiEc1SpP+2OYOdOLu+CtqS1RYEP5FPK44tZONJhqf ZsDcM0+cwCFPbb9OWpaV8EZnjTw9TDoVe7SRHeYa1UPpmkLOcQF4SCeJxTQvjw78R5cJ 4PF68i6oWt+svQZrau4ugmSYdGuoRQRBznjI8anAjxVzarTfgPsfVI5xAG1Koh1cdh9j snzA== X-Gm-Message-State: ALQs6tBcQgFwQTk1uQVJizbeMiPpFP++09TmnzFeVMPhuOtfhLDcFNsc x97iXU8THh4ZCUBjAMSWO/Gk+g== X-Received: by 10.46.156.13 with SMTP id s13mr13019293lji.29.1522913950955; Thu, 05 Apr 2018 00:39:10 -0700 (PDT) Received: from localhost (c-4c3770d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.55.76]) by smtp.gmail.com with ESMTPSA id l25sm1175996lja.25.2018.04.05.00.39.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Apr 2018 00:39:10 -0700 (PDT) From: Anders Roxell To: shuah@kernel.org, pintu.ping@gmail.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Anders Roxell Subject: [PATCH v2] selftests/android/ion: fix heap_type may be uninitialized Date: Thu, 5 Apr 2018 09:39:07 +0200 Message-Id: <20180405073907.30615-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180308134845.32409-1-anders.roxell@linaro.org> References: <20180308134845.32409-1-anders.roxell@linaro.org> 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 --- tools/testing/selftests/android/ion/ionapp_export.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 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..67a0263a7f28 100644 --- a/tools/testing/selftests/android/ion/ionapp_export.c +++ b/tools/testing/selftests/android/ion/ionapp_export.c @@ -31,8 +31,10 @@ void print_usage(int argc, char *argv[]) { - printf("Usage: %s [-h ] [-i ] [-s ]\n", + printf("Usage: %s [-h ] -i -s \n", argv[0]); + printf(" Supported heap id's 0 or 1\n"); + printf(" Heap size > 0\n"); } int main(int argc, char *argv[]) @@ -40,7 +42,8 @@ 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 +53,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 +72,7 @@ int main(int argc, char *argv[]) heap_type = ION_HEAP_TYPE_SYSTEM_CONTIG; break; default: - printf("ERROR: heap type not supported\n"); + print_usage(argc, argv); exit(1); } break; @@ -82,8 +86,7 @@ int main(int argc, char *argv[]) } } - if (heap_size <= 0) { - printf("heap_size cannot be 0\n"); + if (heap_size <= 0 || heap_type < 0) { print_usage(argc, argv); exit(1); }