Received: by 10.223.185.116 with SMTP id b49csp426763wrg; Sat, 10 Feb 2018 10:06:25 -0800 (PST) X-Google-Smtp-Source: AH8x226+yD84iEHSE5Pi2830Bgi70VUrGj4aSxFHbh73EV50mjOfczqdcEQfJfwe4a/kHmx+dfw6 X-Received: by 10.101.83.76 with SMTP id w12mr5332918pgr.95.1518285985630; Sat, 10 Feb 2018 10:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518285985; cv=none; d=google.com; s=arc-20160816; b=AyTzvFMt1DovelVZygwVDTPrLaRwbno74OeEyuof07ErTT/+sQTe8erHaTi1av/KqJ XAtbzBymcdwBt977bNt4ix9SF9NcZG8DHk0k0RhyA3p+YaUtNYcvx8ucvc2TTxAoR2xO C7IcZw9AEYu6aYZ6G2QVEGDHPKTOoMR8vJsKiAQWgivx3DveUhRhta6TqXLYi5KfvQiq 5LK4FSG1zdCnIT1TIKI8JrBgZEXPCA2RI0zzGKkZY0pmqDYRiSOAfwBAD6tUTt+3hA3N tcXyl8XRcQDPZ8cQQfNDHCnv+YiHbWLe0hdE6mtyujx6Q3AINNU9+ut2+XydsMldRAxg VnOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=UnsJmC2Hq+IDfZIdW+JIzvzIkl1S415rmxcG+OxGhg8=; b=VmKSyGWHxr45HLRdYBkDCuQJn9nPQEhOHR3vJ1HDWnG3md7vCcsdSJm7Svsu/zB90B U9THemrns7R4TyAMgyiOuGLG37AZ7VDHiHqQruCm+y1bgvpET1zsaCWeYMQ+JjBPRzMY 8PF3DTYYEDPM1iEVreWalOsYIwnnpCTQzDzV+vc6TtjBoAo47Vt0gcMlHGys+C7gx+z4 1UjGxpwobcyHS5hkuxqsXPpJSHkOkMYx+XPcwXag1ogdCR38i6NTMpcnQxQvjqKp72KP pvEFf3G//udNlFeiAGAKrKW9hYn42Gn4kxhPT0Ah9MvysGZLBGY5PclNs7iJgKFvpt5a UvmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9-v6si3278792pls.308.2018.02.10.10.06.11; Sat, 10 Feb 2018 10:06:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751570AbeBJSE2 (ORCPT + 99 others); Sat, 10 Feb 2018 13:04:28 -0500 Received: from smtprelay0091.hostedemail.com ([216.40.44.91]:52060 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751087AbeBJSE1 (ORCPT ); Sat, 10 Feb 2018 13:04:27 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 4A603182CED2A; Sat, 10 Feb 2018 18:04:26 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:2828:2895:2915:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3873:3874:4321:4605:5007:6691:7904:8660:10004:10400:10848:11232:11658:11914:12294:12295:12296:12740:12760:12895:13069:13148:13161:13229:13230:13311:13357:13439:14096:14097:14659:14721:21080:21611:21627:30054:30060:30069:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: neck24_7defc40f7e725 X-Filterd-Recvd-Size: 1976 Received: from XPS-9350 (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf13.hostedemail.com (Postfix) with ESMTPA; Sat, 10 Feb 2018 18:04:25 +0000 (UTC) Message-ID: <1518285863.16865.17.camel@perches.com> Subject: Re: [PATCH] seq_file: remove redundant assignment of index to m->index From: Joe Perches To: Donglin Peng , viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, Linux Kernel Mailing List Date: Sat, 10 Feb 2018 10:04:23 -0800 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2018-02-10 at 23:59 +0800, Donglin Peng wrote: > There are two redundant assignments in the traverse() function, because > the while loop will break after these two assignments, and after that > the variable index will be assigned to m->index again. [] > diff --git a/fs/seq_file.c b/fs/seq_file.c [] > @@ -120,14 +120,12 @@ static int traverse(struct seq_file *m, loff_t offset) > if (pos + m->count > offset) { > m->from = offset - pos; > m->count -= m->from; > - m->index = index; > break; > } > pos += m->count; > m->count = 0; > if (pos == offset) { > index++; > - m->index = index; > break; > } > p = m->op->next(m, p, &index); Of course this looks correct, but how are you _absolutely sure_ about this? Perhaps the m->op->stop(m, p) call below the break, which takes m as an argument, needs an updated m->index. Unless you can verify _all_ the indirect paths that stop() can take, this patch may not be correct.