Skip to contentSkip to conversation

tep_free_plugin_paths() function in libtraceevent

DISCUSSION Ben Hutchings 4 participants 5 messages Sep 11, 2020 – Sep 16, 2020

lore
Share & tools
lore
#0 lore raw

I noticed that the new function tep_free_plugin_paths() is exported from libtraceevent, but is only declared in a private header file.

If it's meant to be part of the API, it should be declared in a public header file. If not, I think it should be hidden from library users.

(I think there are other only functions with this issue; this just came to my attention because the Debian packaging tools prompted me to update the symbol-to-minimum-version mapping.)

Ben.

Signature · 2 lines
Ben Hutchings
Never put off till tomorrow what you can avoid all together.
#1 lore raw

Em Fri, Sep 11, 2020 at 03:08:16AM +0100, Ben Hutchings escreveu:

Quoted 9 lines

I noticed that the new function tep_free_plugin_paths() is exported from libtraceevent, but is only declared in a private header file.

If it's meant to be part of the API, it should be declared in a public header file. If not, I think it should be hidden from library users.

(I think there are other only functions with this issue; this just came to my attention because the Debian packaging tools prompted me to update the symbol-to-minimum-version mapping.)

Tzvetomir, can you please take a look?

- Arnaldo

#2 lore raw
Quoted 4 lines · Arnaldo Carvalho de Melo

Em Fri, Sep 11, 2020 at 03:08:16AM +0100, Ben Hutchings escreveu:

Quoted 2 lines

I noticed that the new function tep_free_plugin_paths() is exported from libtraceevent, but is only declared in a private header file.

Hi Ben,
The tep_free_plugin_paths() function is supposed to be an internal function, not an API - that's why it is in a private header. What do you mean by "exported": the "tep_" prefix, or the fact that it is not static? I can remove the prefix, if that is what bothers you. The function is defined in event-plugin.c and is used in event-parse.c, that's why it cannot be made static without a library redesign.

Quoted 11 lines
Quoted 7 lines

If it's meant to be part of the API, it should be declared in a public header file. If not, I think it should be hidden from library users.

(I think there are other only functions with this issue; this just came to my attention because the Debian packaging tools prompted me to update the symbol-to-minimum-version mapping.)

Tzvetomir, can you please take a look?

- Arnaldo

Signature · 2 lines
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center
#3 lore raw
Quoted 10 lines · Tzvetomir Stoyanov
Quoted 3 lines · Arnaldo Carvalho de Melo

Em Fri, Sep 11, 2020 at 03:08:16AM +0100, Ben Hutchings escreveu:

Quoted 2 lines

I noticed that the new function tep_free_plugin_paths() is exported from libtraceevent, but is only declared in a private header file.

Hi Ben,
The tep_free_plugin_paths() function is supposed to be an internal function, not an API - that's why it is in a private header. What do you mean by "exported": the "tep_" prefix, or the fact that it is not static?

It is exported from the shared library, i.e. it's included in the library's dynamic symbols. That means that it could be called by a program using the library, and would conflict with a function defined by the program.

Quoted 1 line

I can remove the prefix, if that is what bothers you.

No, exporting symbols without that prefix would make conflicts more likely.

Quoted 3 lines

The function is
defined in event-plugin.c and is used in event-parse.c, that's why it cannot be made static without a library redesign.

Yes, I realise that. However you can define it as "hidden":
<https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Common-Function-Attributes.html#index-visibility-function-attribute>.

Ben.

Quoted 12 lines
Quoted 10 lines
Quoted 6 lines

If it's meant to be part of the API, it should be declared in a public header file. If not, I think it should be hidden from library users.

(I think there are other only functions with this issue; this just came to my attention because the Debian packaging tools prompted me to update the symbol-to-minimum-version mapping.)

Tzvetomir, can you please take a look?

- Arnaldo

Signature · 3 lines
Ben Hutchings
I'm not a reverse psychological virus.
Please don't copy me into your signature.
#4 lore raw
Quoted 12 lines · On Tue, 15 Sep 2020 14:26:48 +0100 Ben Hutchings <[email protected]> wrote:
Quoted 10 lines · Tzvetomir Stoyanov
Quoted 3 lines · Arnaldo Carvalho de Melo

Em Fri, Sep 11, 2020 at 03:08:16AM +0100, Ben Hutchings escreveu:

Quoted 2 lines

I noticed that the new function tep_free_plugin_paths() is exported from libtraceevent, but is only declared in a private header file.

Hi Ben,
The tep_free_plugin_paths() function is supposed to be an internal function, not an API - that's why it is in a private header. What do you mean by "exported": the "tep_" prefix, or the fact that it is not static?

Quoted 4 lines

It is exported from the shared library, i.e. it's included in the library's dynamic symbols. That means that it could be called by a program using the library, and would conflict with a function defined by the program.

Of course a program that uses this shouldn't have any tep_ prefix functions ;-)

Quoted 5 lines
Quoted 2 lines

I can remove the prefix, if that is what bothers you.

No, exporting symbols without that prefix would make conflicts more likely.

Right!

Quoted 7 lines
Quoted 4 lines

The function is
defined in event-plugin.c and is used in event-parse.c, that's why it cannot be made static without a library redesign.

Yes, I realise that. However you can define it as "hidden":
<https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Common-Function-Attributes.html#index-visibility-function-attribute>.

Ah, that's how libraries can hide non static functions. I learned something new today!

Tzvetomir,

Let's only have functions that are part of the library's API start with "tep_", and all other functions not have "tep_" in the name (so we know which ones are exported and which ones are not).

Then any function that doesn't start with "tep_" should either be static, or hidden.

#define __hidden __attribute__((visibility ("hidden")))

static void foo ()
{
}

void __hidden bar ()
{
}

-- Steve