Re: [PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-09 Thread Serge E. Hallyn
Quoting Tejun Heo (t...@kernel.org): > Hello, Serge. > > On Tue, Aug 09, 2016 at 10:33:05AM -0500, Serge E. Hallyn wrote: > > > + for (i = depth_to - 1; i >= 0; i--) { > > > + for (kn = kn_to, j = 0; j < i; j++) > > > + kn = kn->parent; > > > > This is O(n^2) where n is

Re: [PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-09 Thread Serge E. Hallyn
Quoting Tejun Heo (t...@kernel.org): > Hello, Serge. > > On Tue, Aug 09, 2016 at 10:33:05AM -0500, Serge E. Hallyn wrote: > > > + for (i = depth_to - 1; i >= 0; i--) { > > > + for (kn = kn_to, j = 0; j < i; j++) > > > + kn = kn->parent; > > > > This is O(n^2) where n is

Re: [PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-09 Thread Tejun Heo
Hello, Serge. On Tue, Aug 09, 2016 at 10:33:05AM -0500, Serge E. Hallyn wrote: > > + for (i = depth_to - 1; i >= 0; i--) { > > + for (kn = kn_to, j = 0; j < i; j++) > > + kn = kn->parent; > > This is O(n^2) where n is the path depth. It's not a hot path, though, do

Re: [PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-09 Thread Tejun Heo
Hello, Serge. On Tue, Aug 09, 2016 at 10:33:05AM -0500, Serge E. Hallyn wrote: > > + for (i = depth_to - 1; i >= 0; i--) { > > + for (kn = kn_to, j = 0; j < i; j++) > > + kn = kn->parent; > > This is O(n^2) where n is the path depth. It's not a hot path, though, do

Re: [PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-09 Thread Serge E. Hallyn
Quoting Tejun Heo (t...@kernel.org): > kernfs_path*() functions always return the length of the full path but > the path content is undefined if the length is larger than the > provided buffer. This makes its behavior different from strlcpy() and > requires error handling in all its users even

Re: [PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-09 Thread Serge E. Hallyn
Quoting Tejun Heo (t...@kernel.org): > kernfs_path*() functions always return the length of the full path but > the path content is undefined if the length is larger than the > provided buffer. This makes its behavior different from strlcpy() and > requires error handling in all its users even

[PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-08 Thread Tejun Heo
kernfs_path*() functions always return the length of the full path but the path content is undefined if the length is larger than the provided buffer. This makes its behavior different from strlcpy() and requires error handling in all its users even when they don't care about truncation. In

[PATCH 2/4] kernfs: make kernfs_path*() behave in the style of strlcpy()

2016-08-08 Thread Tejun Heo
kernfs_path*() functions always return the length of the full path but the path content is undefined if the length is larger than the provided buffer. This makes its behavior different from strlcpy() and requires error handling in all its users even when they don't care about truncation. In