Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4764972rwl; Mon, 3 Apr 2023 09:15:26 -0700 (PDT) X-Google-Smtp-Source: AKy350behMxDmr10NmTEKmObxdG4KIvrhOIQqPO6/7Ikazg8pUkD8RzJOJzNWN0vQB8GAa9Pzo8m X-Received: by 2002:a17:907:7f0c:b0:93f:870f:a9e2 with SMTP id qf12-20020a1709077f0c00b0093f870fa9e2mr36194330ejc.16.1680538525940; Mon, 03 Apr 2023 09:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680538525; cv=none; d=google.com; s=arc-20160816; b=ZhheCQgo2HiYhXumYFXj6z8LVaookJGDOXgaYDETLgfCI0s9nvDshlyjpmDQuhmEg7 9KMyd+IYUrEgaWpwrHV75qvaGYcfaNYsYltKX0qIH56So3dU9TmWEpVCqCUgZ2CIKz6B qk50MiX7Mj973a94xMzo8BXvMhfZkAwn/fzKmuY4v/oR7YpKhQ3Xypwh9RRLZxPgZH+/ f1mEcQtKBcD0jmRCr9dmTwbtC8GdzcohlJc7NYz8hFhQgalH+wodpW7oCZOwJjRbIGiv WZ0UNrDDu0xHepHtitgsBrvORZ14USqVGxYWCr11VxE72QU8twWY7RIfWGGOEuQTBsoK bZcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=YGPfSRWoGSI5fAPyYyzDsXwKPDOG1dsimMuY8Qfc4g0=; b=nfYEAP4sFxJwIQT6g8D8AL2K0uJ/AmuUoCQHG77dgT0u4JM7cuv2bnDGRstm4qxhKV BaG/SII020nF9fwh+6mL5D8e0YA70HddbR+SAbDWZJTgUuuzJJkyh2Nm0rITSMePLlE7 k2Pdykvo77dkqNuzWWS9XZbM36uioMEo0cZmgRsJPCwxKH7siWuQeLNktGN3u/XSi6Jh /uPrTQ2dLWP/x3QOmpBB5JQvx4qGGhwbnwyKmhUBEueB9mVY1+GEtXQEd5em7/mrn6BG cvZeIstTYJJw29eZg15rgdgsEjyIo31bQKlNEvVMZIXMKp8RZX0EOcdGTiL3AOhHAVub VqiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=L7bZBbv+; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=G0ospTt3; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm28-20020a0564020b1c00b004acc6c7a631si3586351edb.179.2023.04.03.09.14.56; Mon, 03 Apr 2023 09:15:25 -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=@suse.cz header.s=susede2_rsa header.b=L7bZBbv+; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=G0ospTt3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbjDCQKt (ORCPT + 99 others); Mon, 3 Apr 2023 12:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbjDCQKs (ORCPT ); Mon, 3 Apr 2023 12:10:48 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28482D1; Mon, 3 Apr 2023 09:10:45 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D547121ED0; Mon, 3 Apr 2023 16:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1680538243; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YGPfSRWoGSI5fAPyYyzDsXwKPDOG1dsimMuY8Qfc4g0=; b=L7bZBbv+W6HfeLim3yfUjNHW01j9/SIIBfNVR04wJqM33iPUcmbg6ebLUe8kkXMTc65khp 3IaivgE/Er8L7xX4jJ3LvlpT65CirVnK7FRZENHiOPhHe8lFo4GRoNOZqD5s7FANDQNjrQ YFbsVwG67dMxOa1CDsW88PwRqvt6Av0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1680538243; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YGPfSRWoGSI5fAPyYyzDsXwKPDOG1dsimMuY8Qfc4g0=; b=G0ospTt3eSGE7rc+rl9ghc7DxVIPQ968VED0M1W6bgoFt5ZKchg1Jp9l8iFpLJ4uD9BbW7 Q6mEs4I2YimtoTCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C3DCE13416; Mon, 3 Apr 2023 16:10:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kA3BL4P6KmTTVQAAMHmgww (envelope-from ); Mon, 03 Apr 2023 16:10:43 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 558EBA0732; Mon, 3 Apr 2023 18:10:43 +0200 (CEST) Date: Mon, 3 Apr 2023 18:10:43 +0200 From: Jan Kara To: Jiapeng Chong Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Abaci Robot Subject: Re: [PATCH v2] fs/buffer: Remove redundant assignment to err Message-ID: <20230403161043.tecfvgmhacs4j3qp@quack3> References: <20230323023259.6924-1-jiapeng.chong@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230323023259.6924-1-jiapeng.chong@linux.alibaba.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=unavailable 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 On Thu 23-03-23 10:32:59, Jiapeng Chong wrote: > Variable 'err' set but not used. > > fs/buffer.c:2613:2: warning: Value stored to 'err' is never read. > > Reported-by: Abaci Robot > Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4589 > Signed-off-by: Jiapeng Chong I don't think the patch is quite correct (Christian, please drop it if I'm correct). See below: > diff --git a/fs/buffer.c b/fs/buffer.c > index d759b105c1e7..b3eb905f87d6 100644 > --- a/fs/buffer.c > +++ b/fs/buffer.c > @@ -2580,7 +2580,7 @@ int block_truncate_page(struct address_space *mapping, > struct inode *inode = mapping->host; > struct page *page; > struct buffer_head *bh; > - int err; > + int err = 0; > > blocksize = i_blocksize(inode); > length = offset & (blocksize - 1); > @@ -2593,9 +2593,8 @@ int block_truncate_page(struct address_space *mapping, > iblock = (sector_t)index << (PAGE_SHIFT - inode->i_blkbits); > > page = grab_cache_page(mapping, index); > - err = -ENOMEM; > if (!page) > - goto out; > + return -ENOMEM; > > if (!page_has_buffers(page)) > create_empty_buffers(page, blocksize, 0); > @@ -2609,7 +2608,6 @@ int block_truncate_page(struct address_space *mapping, > pos += blocksize; > } > > - err = 0; > if (!buffer_mapped(bh)) { > WARN_ON(bh->b_size != blocksize); > err = get_block(inode, iblock, bh, 0); > @@ -2633,12 +2631,11 @@ int block_truncate_page(struct address_space *mapping, > > zero_user(page, offset, length); > mark_buffer_dirty(bh); > - err = 0; There is: if (!buffer_uptodate(bh) && !buffer_delay(bh) && !buffer_unwritten(bh)) err = -EIO; above this assignment. So now we'll be returning -EIO if block_truncate_page() needs to read the block AFAICT. Did this pass fstests with some filesystem exercising this code (ext2 driver comes to mind)? Honza -- Jan Kara SUSE Labs, CR