Question about unused parameters in Blender

Compiling, libraries, modules, coding guidelines and porting

Moderators: jesterKing, stiv

Post Reply
mjordan
Posts: 0
Joined: Tue Nov 23, 2004 3:33 pm

Question about unused parameters in Blender

Post by mjordan » Tue Mar 08, 2005 10:13 pm

I see, while compiling blender under Linux and using GCC, that a lot of warnings are about unused parameters.
For example, in /source/blender/src/editobject.c at line 2622 the following function is declared:

Code: Select all

void link_to_scene(unsigned short nr)
{
      ...
      ...
}
but the parameter nr is never used in the function.

What is the particular reason to do that?
Thank you.
Regards,
Renato Perini
-
You can't live with women, you can't live without women.
Fuzzy logic example.

matt_e
Posts: 410
Joined: Mon Oct 14, 2002 4:32 am
Location: Sydney, Australia
Contact:

Post by matt_e » Wed Mar 09, 2005 12:54 am

Probably just laziness/forgetfulness. Jean-luc (lukep) is about to do a big commit to the BF tree to clean up hundreds and hundreds of warnings, so this should be less of an issue soon.

mjordan
Posts: 0
Joined: Tue Nov 23, 2004 3:33 pm

Post by mjordan » Wed Mar 09, 2005 1:33 am

Wow.
Thank you broken.
Regards,
Renato Perini
-
You can't live with women, you can't live without women.
Fuzzy logic example.

mjordan
Posts: 0
Joined: Tue Nov 23, 2004 3:33 pm

Post by mjordan » Thu Mar 10, 2005 9:10 am

The big warning hunt commit is done.
But the unused parameters are still there.

I don't think it's a matter of laziness. They constitute more than 60% of Blender warnings on a Linux machine with gcc 3.4.3.
So I'm really wondering what they used for. I cannot find a real motivation to this.
:? :?:
Regards,
Renato Perini
-
You can't live with women, you can't live without women.
Fuzzy logic example.

SirDude
Posts: 233
Joined: Sun Oct 13, 2002 7:37 pm
Location: University of Minnesota (USA)
Contact:

Post by SirDude » Thu Mar 10, 2005 2:55 pm

It really depends on the code.

There are some places that are still under development and the
function should probably use the variable passed in but doesn't yet.

There are others that use to use the variable and do not anymore
and the function was never cleaned up.

There are also ones where someone just made 4-5 functions all with
the same paramiters and then only used the ones they needed.

My point is its not just as simple as lets remove them each one needs to
be looked at and no one has taken the time to sit down and figure out
whats what. I'm sure they will be addressed some time...

lukep
Posts: 0
Joined: Sun Apr 04, 2004 1:39 pm

Post by lukep » Thu Mar 10, 2005 9:44 pm

mjordan wrote:The big warning hunt commit is done.
But the unused parameters are still there.

I don't think it's a matter of laziness. They constitute more than 60% of Blender warnings on a Linux machine with gcc 3.4.3.
So I'm really wondering what they used for. I cannot find a real motivation to this.
:? :?:
First, with the default settings of warnings in GCC, you shouldn't have those warnings either with makefiles or Scons.

After my commit, I'm down to 52 warnings on XCode with the followings parameters :

for C files : -Wall -Wno-char-subscript -Wmissing-prototypes
for C++ files : -Wall -Wno-char-subscript

these settings are good enough.

adding -W or -Wunused-parameter will turn on this warning.

I will continue cleaning the files but later.

Also, having unused parameters is not necessary an error. you can have several functions using the same templates of parameters, called by pointers, and each function may not need all parameters.

Python API has things like that, as wall as texture code (and certainly other places).

Now it should be the responsability of the coder to add unused qualifier for such parameters.

mjordan
Posts: 0
Joined: Tue Nov 23, 2004 3:33 pm

Post by mjordan » Fri Mar 11, 2005 12:52 am

lukep wrote: First, with the default settings of warnings in GCC, you shouldn't have those warnings either with makefiles or Scons.

After my commit, I'm down to 52 warnings on XCode with the followings parameters :

for C files : -Wall -Wno-char-subscript -Wmissing-prototypes
for C++ files : -Wall -Wno-char-subscript

these settings are good enough.

adding -W or -Wunused-parameter will turn on this warning.

I will continue cleaning the files but later.
SConstruct in the root dir has only -O2 for C parameters and none for C++. This by default.
lukep wrote: Also, having unused parameters is not necessary an error. you can have several functions using the same templates of parameters, called by pointers, and each function may not need all parameters.

Python API has things like that, as wall as texture code (and certainly other places).

Now it should be the responsability of the coder to add unused qualifier for such parameters.
That's the reason I was wondering. Thank you.
Regards,
Renato Perini
-
You can't live with women, you can't live without women.
Fuzzy logic example.

lukep
Posts: 0
Joined: Sun Apr 04, 2004 1:39 pm

Post by lukep » Fri Mar 11, 2005 7:35 am

mjordan wrote: SConstruct in the root dir has only -O2 for C parameters and none for C++. This by default.
warn flags for the linux platform in SConstruct :
warn_flags = ['-Wall', '-W']

here is your culprit, i have supressed the -W since a long time on the platform i maintain

mjordan
Posts: 0
Joined: Tue Nov 23, 2004 3:33 pm

Post by mjordan » Sat Mar 12, 2005 2:41 am

lukep wrote:
mjordan wrote: SConstruct in the root dir has only -O2 for C parameters and none for C++. This by default.
warn flags for the linux platform in SConstruct :
warn_flags = ['-Wall', '-W']

here is your culprit, i have supressed the -W since a long time on the platform i maintain
Yes, I removed that parameter. Things are much better now.
I think it is a too much paranoic setting to have it by default on a project that supports many different compilers, like Blender.
Effectively, for what I have seen, the "-W" flag is not much used in general. It helps a lot on gcc-only code. But I think it can give serious problems when trying to sync code with different compilers.
Regards,
Renato Perini
-
You can't live with women, you can't live without women.
Fuzzy logic example.

Post Reply