Method types and return values handling

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Method types and return values handling

Barak Sason Rofman
Hello everyone,

I'd like to bring some points up for discussion:
1 - We have a great number of methods all across Gluster which (for example) are declared to be 'int' but in reality return (for example) 0 in all cases, both on the positive and the negative path.
2 - In many cases there are calls to methods that return a value, but this value is completely ignored (e.g. the method 'foo(...)' return an int, but all calls are in the form of 'foo(...)' instead of ret = 'foo(...)' ).

These 2 issues adversely affects the readability/maintainability of the project and probably also affect error handling (if an error occurs in a method that always returns 0, how will the calling methods know that an error happened?).
These issues are not specific to a certain component, but seem to be all across the project.

I believe this needs addressing, and probably in one of the following ways:
1 - Change methods to 'void', where there is really no need for a return value.
2 - Actually handle the return value and log erros accordingly.

Of course discretion is needed and in some cases we could change to void, while in other handle the return value.
I'd like to hear opinions on if and how this needs to be handled.

Thank you all.
Barak Sason Rofman

Gluster Storage Development

Red Hat Israel

34 Jerusalem rd. Ra'anana, 43501

bsasonro[hidden email]    T: +972-9-7692304
M: +972-52-4326355


Community Meeting Calendar:

APAC Schedule -
Every 2nd and 4th Tuesday at 11:30 AM IST

NA/EMEA Schedule -
Every 1st and 3rd Tuesday at 01:00 PM EDT

Gluster-devel mailing list
[hidden email]