From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932285AbbEVAq4 (ORCPT ); Thu, 21 May 2015 20:46:56 -0400 Received: from li271-223.members.linode.com ([178.79.152.223]:58160 "EHLO mail.mleia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755225AbbEVAqx (ORCPT ); Thu, 21 May 2015 20:46:53 -0400 Message-ID: <555E7C7B.1080706@mleia.com> Date: Fri, 22 May 2015 03:46:51 +0300 From: Vladimir Zapolskiy User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.2.0 MIME-Version: 1.0 To: Tejun Heo CC: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs: sysfs: don't pass count == 0 to bin file readers References: <1432243276-27733-1-git-send-email-vz@mleia.com> <20150521221423.GK4914@htj.duckdns.org> <555E647F.7070907@mleia.com> <20150521232615.GA7099@htj.duckdns.org> In-Reply-To: <20150521232615.GA7099@htj.duckdns.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-49551924 X-CRM114-CacheID: sfid-20150522_014915_606335_A7B4843F X-CRM114-Status: GOOD ( 12.33 ) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Tejun, On 22.05.2015 02:26, Tejun Heo wrote: > Hello, Vladimir. > > On Fri, May 22, 2015 at 02:04:31AM +0300, Vladimir Zapolskiy wrote: >> But "!size" is a special case, >> >> if (!count || pos >= size) >> return 0; >> >> seems to be incorrect in case of !size ===> (pos >= size) == true. > > Hmmm... Why is that wrong tho? If size is zero and pos is zero, > there's nothing to do, no? positive size value in the context means the fixed exact length of the file and if size == 0, then it represents some undefined size, often dynamic in runtime. So, if size is zero and pos is zero it stands for reading from the beginning of the file as many bytes as allowed by battr->read() realization. This special case is utilized by quite many bin_attribute users, probably more than half of them set .size to 0. > Thanks. > -- With best wishes, Vladimir