From: Duy Nguyen Date: Wed, 16 Jan 2013 01:08:03 GMT Subject: Re: [PATCH] attr: fix off-by-one directory component length calculation Message-ID: In-Reply-To: <7vwqve2qk3.fsf@alter.siamese.dyndns.org> On Wed, Jan 16, 2013 at 2:29 AM, Junio C Hamano wrote: > "Jean-Noël AVILA" writes: > >> Thank you for the explanation. >> >> I did not monitor the system calls when writing that patch. >> Where is the perf framework? >> >> As the mistake is located in the "find_basename" function, I would propose a >> fix directly into it so that the output fits what the other functions expect. > > Isn't that a crazy semantics for the function, though? I would > expect find_basename("/a/path/to/file") to return "file", not Actually I'd like to remove that function. The function is called twice: - collect_all_attrs + prepare_attr_stack * find_basename + find_basename which could be reordered to - collect_all_attrs + find_basename + prepare_attr_stack (modified to take dirlen from caller) and because that'll be the only place find_basename is used, we could just inline the code there. -- Duy