[lkml]   [2022]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v3 1/6] device property: Helper to match multiple connections
On Sun, Mar 06, 2022 at 08:18:24PM -0600, Bjorn Andersson wrote:
> On Fri 04 Mar 07:52 CST 2022, Andy Shevchenko wrote:
> > On Fri, Mar 04, 2022 at 03:41:33PM +0200, Sakari Ailus wrote:


> > I have checked vsnprintf() and indeed, it expects to have the size is 0 when
> > the resulting buffer pointer is NULL, and it doesn't do any additional checks.
> Per the vsnprintf() semantics it's not the destination buffer being NULL
> that's significant, but rather just the length being 0 that matters.

Actually the main point is to have buffer to be NULL. But at the same
time size also has to be 0.

When the size is 0, but buffer is not NULL, it's a different story.

> To follow that, I should fill @matches_len entries in @matches and then
> just continue counting without storing anything in @matches.
> But that won't work in this case, because in the event that the @match
> function returns something that has to be freed (such as the refcounted
> objects returned by the typec_mux code), dropping this in favor of just
> counting it would cause memory/reference leaks.
> As such, I think this should differ in that @matches = NULL is
> significant, and it's nice to not have matches_len turn negative/bogus
> in the count case.
> So I like your suggestion.

With Best Regards,
Andy Shevchenko

 \ /
  Last update: 2022-03-07 10:56    [W:0.443 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site