Why assign a variable to yourself

The employee wrote this function (the comment was written by me):

static void foo(void *arg)
{
    //arg is NOT global variable
    arg = arg;
    // call other function, but doesn't use arg
    foo2();
}

Is there any reason to write such code? Does he have any special purpose?

+4
source share
3 answers

This may be for future expansion purposes. Now this argument is not used, but it can be in later versions, it can be used for more functionality without changing the signature of the function.

Adding the target specified by Paul R.'s instruction is arg = arg;simply trying to use argcompiler warnings to suppress clean assemblies without warning.

PS: Codes like this are also used in my company.

+3
source

.

:

(void)arg;

#pragma unused (arg)    // not supported by all compilers
+5

This seems to be done to avoid the warning of an "unused argument". They could just use __attribute__((unused))for arg.

+3
source

All Articles