Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1378138iob; Sat, 14 May 2022 07:28:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYbEvdM9mOhZiGNNXExVxFbkF1R5VQzlpu7ZwUEq5O4gsT67f4FojNF7Z0Xo2Xcai3WZ3/ X-Received: by 2002:a05:600c:1d08:b0:394:54ee:c994 with SMTP id l8-20020a05600c1d0800b0039454eec994mr9149889wms.137.1652538482765; Sat, 14 May 2022 07:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652538482; cv=none; d=google.com; s=arc-20160816; b=dMsqUvCLuW6Zb3xCjT7sp3XKiPF4FiLwLDvDcqBZhqZSaoRdNCAWqCC4k/t455NamS MG17f3gp2n7Fwzp2rlq5Yo88XnepELMMx4V7oxd2/JwKhbYzLtxIzxVSLmHoCZasTiLE n73/sOPt9mM0if/1LGsfj5/zfB/f3Jn9FbpP+JUm9tRVh7Y92ilfOTzvs+2PbHSQskNu lKSc5xCWCJwe5nnPMT1ES6TvVIVbsYk5vsQAhlwSqL1+d83kGgT0Vjy4mql2PDoLwcte 8850UD1UNyiNa7qVug3GGEnf8N9vDug57Xv9oYGZHAf+ZRUinyKn9unLRr0yCW5JFYFY qOsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id:dkim-signature; bh=71mBNyH9B09u2q3LU3Ju59I/HS2yC5xAPDJGFqnY1VY=; b=q5Pa+zpVFl/PbUy8LHjnshVPsb/7eVI/K2cqQ2WPsY5Bl7iejCDZkJtDdUW5AevvNa Tnvd0E4Kgq3S6cxlKD5XsW4GXtROdaIx4E344anAA2/7EjO6e7NcaZSO4dYDAhID80RC 61HLfs5xacEUGHzVO4kjFIxGrFUIYSHTL+2oRRgGlkvM4T3VRP04Pvm9LC+UQcJBLNJY +cs1c7Aow8HSQcnd6lq+e0u5CsWFBE7b8X9Bn23jOh8uWDPiKxJYtXEKHgNwGv/qUX6g Z8TYh59kcZ1f0ZRWD4hL+oNT7f0/kr70orGFsu2KwrwRkHLnzRg6gESLYdx6aVncFJsv BXhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=aDNslnbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a5d588e000000b0020abfd7fc87si4652914wrf.579.2022.05.14.07.27.22; Sat, 14 May 2022 07:28:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=aDNslnbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbiENKWf (ORCPT + 99 others); Sat, 14 May 2022 06:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbiENKWd (ORCPT ); Sat, 14 May 2022 06:22:33 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 763BC3153D for ; Sat, 14 May 2022 03:22:31 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id t25so18317284lfg.7 for ; Sat, 14 May 2022 03:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :content-language:content-transfer-encoding; bh=71mBNyH9B09u2q3LU3Ju59I/HS2yC5xAPDJGFqnY1VY=; b=aDNslnbKSGb4N2xm1Lxo4JxC4fAdYDbFa2mX+wCqkePx5mKCMbOD5iCq1sfQ4987Ly pknma9OKnD55wK9708N0oBvqAdYOUcm5Az6rId19fcg02Ws62hKcfzOhMqR3M/o8PrLT gj6GmVJmadt1Q6ikgZmpoha1PxC2zu9pP27midOTTvFra8OJt0emu5vd+7PT0uiq6Y9d 12DQijP7/V04zHpW/6n8kdepYQ97ZFhJf+PtwkCHdsOBLtENyltKd4LGYu1SWRWsvYA+ nFL4NUStGXtMLH9yefk27zuXk9ipvER/7g6r1EYIOYlifhm6zULorvCMq4FGU1drfKW2 iMng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:content-language:content-transfer-encoding; bh=71mBNyH9B09u2q3LU3Ju59I/HS2yC5xAPDJGFqnY1VY=; b=Mf1IF8J3pf80XhOcHHifOx/agQt2w+uYQRydyrsgpX/jFjPmCPFrGU1ELqTHFs3LAq 6FXKa69XUSEOGweFXRAFA/PK9twhXY5S3Lk9wFNKMtT0BQwAsQcY0ZND+oZos4QNyCHb KXyu3FydxEH0yxIXaUwx0HLXv70yVOWjtLVOQDISHtr3McoKXdk1XLlWeq5Jglo1ozQn a93G2JszRhDMfnOWa4PtHWzKrjN5Ung5PmVZXEDQdVpZ+YNTZ0one1qzp5K+rldVew54 Nvhxm8m+tf7gQ8ULjKAmGRPfiCZeWdUdpZNYeyaMethsg4Zpj8Ft/W+OgwA4P8DjOLwb JcUw== X-Gm-Message-State: AOAM530iBfmGCq9Ecvac6ykH1MCHu4GchLZ+bL91fpCnISoW+gfdk5vm OAxAyBC+cn6UnYN5d/3bsacECEUb4Axs4A== X-Received: by 2002:a05:6512:39c1:b0:471:b37e:fe5a with SMTP id k1-20020a05651239c100b00471b37efe5amr6108692lfu.527.1652523749833; Sat, 14 May 2022 03:22:29 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.177]) by smtp.gmail.com with ESMTPSA id m22-20020a195216000000b0047255d21149sm665060lfb.120.2022.05.14.03.22.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 14 May 2022 03:22:29 -0700 (PDT) Message-ID: <1eb3b298-4f7e-32ad-74ae-12044ed637ed@openvz.org> Date: Sat, 14 May 2022 13:22:28 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: Vasily Averin Subject: [PATCH] sparse: use force attribute for fmode_t casts To: Jan Kara , Alexander Viro Cc: kernel@openvz.org, linux-kernel@vger.kernel.org, Amir Goldstein , Matthew Bobrowski , linux-fsdevel@vger.kernel.org Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixes sparce warnings: fs/notify/fanotify/fanotify_user.c:267:63: sparse: warning: restricted fmode_t degrades to integer fs/notify/fanotify/fanotify_user.c:1351:28: sparse: warning: restricted fmode_t degrades to integer fs/proc/base.c:2240:25: sparse: warning: cast to restricted fmode_t fs/proc/base.c:2297:42: sparse: warning: cast from restricted fmode_t fs/proc/base.c:2394:48: sparse: warning: cast from restricted fmode_t fs/open.c:1024:21: sparse: warning: restricted fmode_t degrades to integer Signed-off-by: Vasily Averin --- fs/notify/fanotify/fanotify_user.c | 4 ++-- fs/open.c | 2 +- fs/proc/base.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 9b32b76a9c30..6b058828e412 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -264,7 +264,7 @@ static int create_fd(struct fsnotify_group *group, struct path *path, * originally opened O_WRONLY. */ new_file = dentry_open(path, - group->fanotify_data.f_flags | FMODE_NONOTIFY, + group->fanotify_data.f_flags | (__force int)FMODE_NONOTIFY, current_cred()); if (IS_ERR(new_file)) { /* @@ -1348,7 +1348,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) (!(fid_mode & FAN_REPORT_NAME) || !(fid_mode & FAN_REPORT_FID))) return -EINVAL; - f_flags = O_RDWR | FMODE_NONOTIFY; + f_flags = O_RDWR | (__force int)FMODE_NONOTIFY; if (flags & FAN_CLOEXEC) f_flags |= O_CLOEXEC; if (flags & FAN_NONBLOCK) diff --git a/fs/open.c b/fs/open.c index 1315253e0247..b5ff39ccebfd 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1021,7 +1021,7 @@ inline struct open_how build_open_how(int flags, umode_t mode) inline int build_open_flags(const struct open_how *how, struct open_flags *op) { u64 flags = how->flags; - u64 strip = FMODE_NONOTIFY | O_CLOEXEC; + u64 strip = (__force u64)FMODE_NONOTIFY | O_CLOEXEC; int lookup_flags = 0; int acc_mode = ACC_MODE(flags); diff --git a/fs/proc/base.c b/fs/proc/base.c index c1031843cc6a..194b5ac069e7 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2237,7 +2237,7 @@ static struct dentry * proc_map_files_instantiate(struct dentry *dentry, struct task_struct *task, const void *ptr) { - fmode_t mode = (fmode_t)(unsigned long)ptr; + fmode_t mode = (__force fmode_t)(unsigned long)ptr; struct proc_inode *ei; struct inode *inode; @@ -2294,7 +2294,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir, if (vma->vm_file) result = proc_map_files_instantiate(dentry, task, - (void *)(unsigned long)vma->vm_file->f_mode); + (void *)(__force unsigned long)vma->vm_file->f_mode); out_no_vma: mmap_read_unlock(mm); @@ -2391,7 +2391,7 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx) buf, len, proc_map_files_instantiate, task, - (void *)(unsigned long)p->mode)) + (void *)(__force unsigned long)p->mode)) break; ctx->pos++; } -- 2.31.1