From patchwork Thu Nov 24 00:16:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 9444521 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 4B9F660778 for ; Thu, 24 Nov 2016 00:16:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 473532621B for ; Thu, 24 Nov 2016 00:16:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3911426223; Thu, 24 Nov 2016 00:16:28 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 BC2EA2621B for ; Thu, 24 Nov 2016 00:16:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934820AbcKXAQ1 (ORCPT ); Wed, 23 Nov 2016 19:16:27 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:35040 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933573AbcKXAQ0 (ORCPT ); Wed, 23 Nov 2016 19:16:26 -0500 Received: by mail-io0-f195.google.com with SMTP id h133so3402130ioe.2 for ; Wed, 23 Nov 2016 16:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=UpQF6TOgt735NF8BbB1h6jGDQcivQXbQb65XQ2GHRaA=; b=PP+DCKhOZesNIQ0SXvisLy8ihQt0nlAZxVDFGQJSRyAw7X3LVzuTcuoWQocJmcz92G tRty0cwA3DTZ6ehEa/XEilPrXJNsGyFhxSXUHwBGn7UEE9YpHbu1xubiTuKiivmIkUMY irbLl1qAQiojMFt24M7cfmhu0QdbZbdYrmL7xzl6Bk7p1ftUuew1CfWyA7dOSHE8PQjM MuVT0bBxdkS+vjcGWNeIPxwODp3Epe3KhcT+SdBKq+MIHGq8FZ+V8YktBRUcQD9MezXN Rdf6OFdUG5tDZkrjaIWyCqgTjtAX1VVSAt9XY7O1oPh0zpL0p+TixUMgfbW4G+R6a2jB 4Ueg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=UpQF6TOgt735NF8BbB1h6jGDQcivQXbQb65XQ2GHRaA=; b=lFYd546qmS9Fzgza34/PH3OaWoOywKXnHGDN+GzlDap2FdK9g7i9txh2dqYzXKMYXB LHms1SFoBLVglfzKyN5b2WxGYrxPRj5i1pMVIMl1zPivqxs9IgTd8ucuvL7DvirV1+iE mL+1NSkxi/VfgFSXThgf8qAle0C8dwu94/F4ZjIyzTH31waKpsFAzqK/brgo3WZpKk7V bDiwMqWeeJVJEaRlX6UgKTDx3e47iIN0C93G5/oSvU3XdPOifFX+VNZmNV0KiR0rpAZI PrMZSDUfOyP5nIHcJ4Bo3p02Nx5zcQgonYkiv5duys5B7MkH6mzvXmdWt4MJfmlIgLn/ rF5g== X-Gm-Message-State: AKaTC02BIOS4bltwft/e1p1E3xlWYLWcM36tP+faPMCFy+dGEsfG5FtqPesnocVgqT4xR1ck+u4pFCQTswV0HA== X-Received: by 10.36.178.81 with SMTP id h17mr9741242iti.98.1479946585337; Wed, 23 Nov 2016 16:16:25 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.209.68 with HTTP; Wed, 23 Nov 2016 16:16:24 -0800 (PST) In-Reply-To: <1479932572-12543-1-git-send-email-mst@redhat.com> References: <1479932572-12543-1-git-send-email-mst@redhat.com> From: Christopher Li Date: Thu, 24 Nov 2016 08:16:24 +0800 X-Google-Sender-Auth: Hagu8_ZcTU86wQPGv1IgvMgqJU0 Message-ID: Subject: Re: [PATCH] lib: __builtin_object_size should accept void * To: "Michael S. Tsirkin" Cc: Josh Triplett , Linux-Sparse 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 A similar patch has been applied: Chris commit f2bf519e1da89779380fd781c0eb28aae415979d Author: Lance Richardson Date: Wed Sep 21 10:13:58 2016 -0400 sparse: update __builtin_object_size() prototype Sparse emits a large number of warnings for the linux kernel source tree of the form: ./arch/x86/include/asm/uaccess.h:735:18: \ warning: incorrect type in argument 1 (different modifiers) ./arch/x86/include/asm/uaccess.h:735:18: expected void * ./arch/x86/include/asm/uaccess.h:735:18: got void const *from Fix by making the first parameter to __builtin_object_size() type "const void *" instead of "void *", which is consistent with GCC behavior (the prototype for this builtin in GCC documentation is evidently incorrect). Signed-off-by: Lance Richardson Acked-by: Luc Van Oostenryck Signed-off-by: Christopher Li 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"); On Thu, Nov 24, 2016 at 4:24 AM, Michael S. Tsirkin wrote: > 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"); > -- > MST > -- > To unsubscribe from this list: send the line "unsubscribe linux-sparse" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 *,