From patchwork Mon Sep 4 05:17:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 9936697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 46645601EB for ; Mon, 4 Sep 2017 05:23:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36D1C2867D for ; Mon, 4 Sep 2017 05:23:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B294286DD; Mon, 4 Sep 2017 05:23:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B8F192867D for ; Mon, 4 Sep 2017 05:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=BmmpRQEBOVPST2VULuGMCxpzGkqEuR2sgLaOtueVc+0=; b=Z3jlYKBf/hPqhT 7OLPaCalNJWbG6ZHRXqTlQQ6CTL/ENotivlHqvXVVyI59B7oqJvlzXElZeLoTLD4IRCzEXAF5j1zF KHEqs8nTlbUwbu5AKZxN8veZkThwr9aDMPFfM95FU1BPP+GN5FZxX+ebjGLG7fVDYxHWt95UL5POC cxqQBVLlOsXbO7LrIpAhQ4hnWgaRtb+JXLHkGIR7P7+7qEFVFcB7GfiDEwGU2MijZcW/pg01IOdAA HFT+JQzKwNygyGMpjTH5QYebqvwJT1MhHlStknXZKjtqf20HJzGW3fB7MYs5PYOw3mPz2mC77vlkT sD1ugWncK61PJ+BwhQYg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dojqg-0005jm-ES; Mon, 04 Sep 2017 05:23:02 +0000 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174] helo=mx0b-0016f401.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dojqd-0005cU-3W for linux-arm-kernel@lists.infradead.org; Mon, 04 Sep 2017 05:23:00 +0000 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v845JZ0K031972; Sun, 3 Sep 2017 22:22:34 -0700 Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2cqt0h6wyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 03 Sep 2017 22:22:34 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Sun, 3 Sep 2017 22:22:32 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Sun, 3 Sep 2017 22:22:32 -0700 Received: from xhacker.marvell.com (unknown [10.37.130.147]) by maili.marvell.com (Postfix) with ESMTP id 518213F703F; Sun, 3 Sep 2017 22:22:31 -0700 (PDT) From: Jisheng Zhang To: , , Subject: [PATCH] binder: fix "cast to pointer from integer of different size" warning Date: Mon, 4 Sep 2017 13:17:40 +0800 Message-ID: <20170904051740.2636-1-jszhang@marvell.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-04_03:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709040084 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170903_222259_158692_40169676 X-CRM114-Status: GOOD ( 10.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Jisheng Zhang , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The binder driver now could cause warnings as below on 32bit platforms if ANDROID_BINDER_IPC_32BIT is unselected: drivers/android/binder.c:1550:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] This patch fix all of them. Signed-off-by: Jisheng Zhang --- drivers/android/binder.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index f7665c31feca..2812586bfae5 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -1547,7 +1547,8 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, debug_id, (u64)fda->num_fds); continue; } - fd_array = (u32 *)(parent_buffer + fda->parent_offset); + fd_array = (u32 *)(parent_buffer + + (uintptr_t)fda->parent_offset); for (fd_index = 0; fd_index < fda->num_fds; fd_index++) task_close_fd(proc, fd_array[fd_index]); } break; @@ -1751,7 +1752,7 @@ static int binder_translate_fd_array(struct binder_fd_array_object *fda, * back to the kernel address space to access it */ parent_buffer = parent->buffer - target_proc->user_buffer_offset; - fd_array = (u32 *)(parent_buffer + fda->parent_offset); + fd_array = (u32 *)(parent_buffer + (uintptr_t)fda->parent_offset); if (!IS_ALIGNED((unsigned long)fd_array, sizeof(u32))) { binder_user_error("%d:%d parent offset not aligned correctly.\n", proc->pid, thread->pid); @@ -1786,7 +1787,7 @@ static int binder_fixup_parent(struct binder_transaction *t, binder_size_t last_fixup_min_off) { struct binder_buffer_object *parent; - u8 *parent_buffer; + uintptr_t parent_buffer; struct binder_buffer *b = t->buffer; struct binder_proc *proc = thread->proc; struct binder_proc *target_proc = t->to_proc; @@ -1817,9 +1818,9 @@ static int binder_fixup_parent(struct binder_transaction *t, proc->pid, thread->pid); return -EINVAL; } - parent_buffer = (u8 *)(parent->buffer - - target_proc->user_buffer_offset); - *(binder_uintptr_t *)(parent_buffer + bp->parent_offset) = bp->buffer; + parent_buffer = parent->buffer - target_proc->user_buffer_offset; + *(binder_uintptr_t *)(parent_buffer + + (uintptr_t)bp->parent_offset) = bp->buffer; return 0; }