From patchwork Wed Nov 23 20:24:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 9444321 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 4D3756075F for ; Wed, 23 Nov 2016 20:24:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5033927CAF for ; Wed, 23 Nov 2016 20:24:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4515E27D76; Wed, 23 Nov 2016 20:24:47 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAA8327CAF for ; Wed, 23 Nov 2016 20:24:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934007AbcKWUYq (ORCPT ); Wed, 23 Nov 2016 15:24:46 -0500 Received: from mail.kernel.org ([198.145.29.136]:45456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933402AbcKWUYp (ORCPT ); Wed, 23 Nov 2016 15:24:45 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 634CC20396; Wed, 23 Nov 2016 20:24:44 +0000 (UTC) Received: from redhat.com (pool-173-76-102-160.bstnma.fios.verizon.net [173.76.102.160]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3809120383; Wed, 23 Nov 2016 20:24:43 +0000 (UTC) Date: Wed, 23 Nov 2016 22:24:41 +0200 From: "Michael S. Tsirkin" To: Josh Triplett Cc: linux-sparse@vger.kernel.org Subject: [PATCH] lib: __builtin_object_size should accept void * Message-ID: <1479932572-12543-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email 2.8.0.287.g0deeb61 X-Mutt-Fcc: =sent X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I'm seeing these warnings with current Linux: ./arch/x86/include/asm/uaccess.h:705:18: warning: incorrect type in argument 1 (different modifiers) ./arch/x86/include/asm/uaccess.h:705:18: expected void * ./arch/x86/include/asm/uaccess.h:705:18: got void const *from Because of this code: static __always_inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n) { int sz = __compiletime_object_size(from); ... } where we have # define __compiletime_object_size(obj) __builtin_object_size(obj, 0) to fix, mark the argument as const void *. Signed-off-by: Michael S. Tsirkin --- Sorry if this has already been reported/fixed. lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.c b/lib.c index d5b56b0..2d66aa0 100644 --- a/lib.c +++ b/lib.c @@ -888,7 +888,7 @@ void declare_builtin_functions(void) add_pre_buffer("extern long double __builtin_nanl(const char *);\n"); /* And some __FORTIFY_SOURCE ones.. */ - add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(void *, int);\n"); + add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(const void *, int);\n"); add_pre_buffer ("extern void * __builtin___memcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n"); add_pre_buffer ("extern void * __builtin___memmove_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n"); add_pre_buffer ("extern void * __builtin___mempcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");