From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E42DC433F5 for ; Sun, 22 May 2022 23:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234290AbiEVXEu (ORCPT ); Sun, 22 May 2022 19:04:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231491AbiEVXEt (ORCPT ); Sun, 22 May 2022 19:04:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F02724588; Sun, 22 May 2022 16:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8NenhAfYIMRmvTFmjGJtXIi8zEG3PIr7S+ROeDiY8Zw=; b=EHRCIlG9uIsnmzJjCasjyT1TGQ 366OoMh/4UUIiKf0OCJq65pZmJNHH7Uyv8cj+fwNOfmJWBPHkoLfcM27Yw4RYIxcm1mIAqncfa1hl +iLB0/F+9Y4KsZMZ/Oc+CJa7znjapRnJnrZgeyywx26vK6kZBF4zDUpYEWWc9Gq9z9dE2av/a07/2 7eDdu5wUOAstdtTKPKIU3n+jt37mBPc4eq+h/EAytcRp7X/1Xkko8p+3pNBFVXZ95x0d6HOO8vP68 K00E3haO6DD/82A0PpoBs9j4iHHEd52FcNsbYx/tZPOQR1d90k9YgPtVdtnr5ixykWq9p/UJ2XVJL WOrwVp9g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nsuct-00FfAN-3p; Sun, 22 May 2022 23:04:43 +0000 Date: Mon, 23 May 2022 00:04:43 +0100 From: Matthew Wilcox To: Vasily Averin Cc: Christoph Hellwig , kernel@openvz.org, linux-kernel@vger.kernel.org, Christian Brauner , Jan Kara , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3] fs/proc/base.c: fix incorrect fmode_t casts Message-ID: References: <31a6874c-1cb8-e081-f1ca-ef1a81f9dda0@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <31a6874c-1cb8-e081-f1ca-ef1a81f9dda0@openvz.org> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Sun, May 22, 2022 at 03:08:42PM +0300, Vasily Averin wrote: > diff --git a/fs/proc/base.c b/fs/proc/base.c > index c1031843cc6a..4e4edf9db5f0 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -2237,13 +2237,13 @@ 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; > + const fmode_t *mode = ptr; Why not ... fmode_t mode = *(fmode_t *)ptr; and then you don't need > - ((mode & FMODE_READ ) ? S_IRUSR : 0) | > - ((mode & FMODE_WRITE) ? S_IWUSR : 0)); > + ((*mode & FMODE_READ ) ? S_IRUSR : 0) | > + ((*mode & FMODE_WRITE) ? S_IWUSR : 0));