[lkml]   [2019]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Improving documentation for programming interfaces
>> Further examples:
>> * kmalloc ⇒ kfree
>> * kobject_create ⇒ kobject_put
>> * device_register ⇒ put_device
>> Can preprocessor macros help to express any more relationships for similar function pairs?
> Sorry, this is still not making sense.

I suggest to reconsider such a view.

> … You said "a pointer would
> contain also the background information by which the resource should
> usually be released". Huh? There's no room for a pointer to also
> store context of whether it was allocated using kmalloc, or malloc, etc.

There are metadata (software documentation) to consider in the source code.

You get usually informed by comments for some allocation functions
which is the corresponding resource release function.
Such comments can vary. Thus I would appreciate to work with these data
in a more structured format.

> Did you have some concrete idea of how a preprocessor macros could be
> used to perform what appears to be completely impractical?

A macro can be chosen to which function names can be passed.

TRIGGER_RELEASE_AFTER(kfree, kmalloc, kcalloc, kzalloc, kmemdup)

Appropriate data type definitions could eventually be generated
by related macros.

> And how would that information be used by the kernel?

Documentation purposes.

> And for what benefit?

Consistent representation of relationships in a structured way.

> And can you show that the benefits will be worth the costs?

I propose to improve possibilities also for the support of better
source code analysis.


 \ /
  Last update: 2019-12-20 19:00    [W:0.037 / U:53.416 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site