Skip to contentSkip to conversation

libtracefs: Improve exception handling in instance_alloc()

RFC PATCH Steven Rostedt 1 participant 2 messages Mar 10, 2023 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · On Fri, 10 Mar 2023 17:30:22 +0100 Markus Elfring <[email protected]> wrote:

Hello,

I hope that the following information sources can be taken better into account.

Quoted 9 lines

* Centralized exiting of functions
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.3-rc1#n526

* MEM12-C: Consider using a goto chain when leaving a function on error when using and releasing resources
  https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources#MEM12C.Considerusingagotochainwhenleavingafunctiononerrorwhenusingandreleasingresources-CompliantSolution%28POSIX,GotoChain%29

How will the chances evolve to integrate the attached change suggestion?

Everything is initialized to NULL, and free(NULL) is perfectly acceptable. Why complicate the code with more labels than needed?

So no, I will not consider this change.

-- Steve

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 5 lines · On Fri, 10 Mar 2023 18:02:55 +0100 Markus Elfring <[email protected]> wrote:
Quoted 3 lines
Quoted 2 lines

How will the chances evolve to integrate the attached change suggestion?

Everything is initialized to NULL, and free(NULL) is perfectly acceptable.

I propose to avoid unnecessary data processing.

No it won't. instance_alloc() is a slow operation, no need to micro-optimize it.

Quoted 11 lines
Quoted 4 lines

Why complicate the code with more labels than needed?

* The control flow can become a bit smaller because a redundant null pointer check will not be performed.

* Less function calls will be performed in some failure cases.

Who cares?

Quoted 6 lines
Quoted 3 lines

So no, I will not consider this change.

I am curious under which circumstances the shown change possibilities will become more attractive.

There is none.

-- Steve