Re: Preceding a method call with (void)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 18 Sep 2015 17:04:03 +0300, Rami Rosen said:

> Well, there are rare cases in the kernel when you add (void) before calling
> the method. For example, if the method returns int or other type and you
> want to emphasize that you are aware of that and deliberately not check the
> return value.
> See for example:
> http://lxr.free-electrons.com/source/drivers/acpi/acpica/tbxfload.c#L156

The fact something is done in the tree doesn't mean it's *correct*.

If you check the tree, there are 80 instances of it being cast to (void),
and 9 instances of 'status ='.

Now if you go look at the source of the function in drivers/acpi/acpica/utmutex.c
we discover that there's 3 or 4 possible return(..) conditions in the
function (one only if _DEBUG is defined).  Looking at the places that
places that bother checking the return code, they all look something like this:

nsxfeval.c:     status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
nsxfeval.c-     if (ACPI_FAILURE(status)) {
nsxfeval.c-             return (status);
nsxfeval.c-     }

Now, given that 80 other sites don't bother checking, there's a good
chance that these 9 call sites shouldn't bother either, and the calling
code should be changed to not check the status either, and then make
the function definition a void.

(Of course a more careful examination of the code should be undertaken, but
it's more likely that there's 9 sites that are checking a return code that
doesn't actually matter than the chances that it really *does* matter in
9 places but not in 80 others...


Attachment: pgpcna9CxjDHQ.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux