injoy
injoy

Reputation: 4373

What does the usage of `(void)struct_pointer`?

I am now reading a project and find some of the codes hard to understand, like below:

struct mcachefs_metadata_t* mdata_root;
...
mcachefs_metadata_release(mdata_root);

And the definition of mcachefs_metadata_release is as below:

void
mcachefs_metadata_release(struct mcachefs_metadata_t* mdata)
{
    (void) mdata;
    mcachefs_metadata_unlock ();
}

And the definitioin of mcachefs_metadata_unlock is as below:

#define mcachefs_metadata_unlock() mcachefs_mutex_unlock ( &mcachefs_metadata_mutex, "metadata", __CONTEXT );

Then, the mcachefs_mutex_unlock function:

void
mcachefs_mutex_unlock(struct mcachefs_mutex_t* mutex, const char* name,
    const char* context)
{
  int res;
  ...

  mutex->owner = 0;
  mutex->context = NULL;
  res = pthread_mutex_unlock(&(mutex->mutex));
  if (res == 0)
    {
      return;
    }
  ...
}

I could not understand what does the (void) mdata; mean in the mcachefs_metadata_release function. What does the usage of it?

Upvotes: 1

Views: 71

Answers (1)

user529758
user529758

Reputation:

It's for suppressing unused argument: mdata compiler warnings. Rather bad practice, by the way.

Upvotes: 3

Related Questions