remarkable-linux/drivers/thermal
Johannes Berg 053c095a82 netlink: make nlmsg_end() and genlmsg_end() void
Contrary to common expectations for an "int" return, these functions
return only a positive value -- if used correctly they cannot even
return 0 because the message header will necessarily be in the skb.

This makes the very common pattern of

  if (genlmsg_end(...) < 0) { ... }

be a whole bunch of dead code. Many places also simply do

  return nlmsg_end(...);

and the caller is expected to deal with it.

This also commonly (at least for me) causes errors, because it is very
common to write

  if (my_function(...))
    /* error condition */

and if my_function() does "return nlmsg_end()" this is of course wrong.

Additionally, there's not a single place in the kernel that actually
needs the message length returned, and if anyone needs it later then
it'll be very easy to just use skb->len there.

Remove this, and make the functions void. This removes a bunch of dead
code as described above. The patch adds lines because I did

-	return nlmsg_end(...);
+	nlmsg_end(...);
+	return 0;

I could have preserved all the function's return values by returning
skb->len, but instead I've audited all the places calling the affected
functions and found that none cared. A few places actually compared
the return value with <= 0 in dump functionality, but that could just
be changed to < 0 with no change in behaviour, so I opted for the more
efficient version.

One instance of the error I've made numerous times now is also present
in net/phonet/pn_netlink.c in the route_dumpit() function - it didn't
check for <0 or <=0 and thus broke out of the loop every single time.
I've preserved this since it will (I think) have caused the messages to
userspace to be formatted differently with just a single message for
every SKB returned to userspace. It's possible that this isn't needed
for the tools that actually use this, but I don't even know what they
are so couldn't test that changing this behaviour would be acceptable.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-01-18 01:03:45 -05:00
..
int340x_thermal int340x_thermal/processor_thermal_device: return failure when 2015-01-06 08:18:21 +08:00
samsung Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal into thermal-soc 2014-12-21 22:49:12 +08:00
st Driver core patches for 3.19-rc1 2014-12-14 16:10:09 -08:00
ti-soc-thermal Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal into thermal-soc 2014-12-21 22:49:12 +08:00
armada_thermal.c Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2014-12-17 10:16:27 -08:00
clock_cooling.c thermal: introduce clock cooling device 2014-11-20 10:43:16 -04:00
cpu_cooling.c Merge branches 'thermal-core', 'thermal-soc' and 'thermal-int340x' of .git into next 2014-12-24 10:38:30 +08:00
db8500_cpufreq_cooling.c Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal into thermal-soc 2014-12-21 22:49:12 +08:00
db8500_thermal.c thermal: drop owner assignment from platform_drivers 2014-10-20 16:21:42 +02:00
dove_thermal.c thermal: drop owner assignment from platform_drivers 2014-10-20 16:21:42 +02:00
fair_share.c thermal: trace: Trace when temperature is above a trip point 2014-07-29 09:28:43 -04:00
gov_bang_bang.c thermal: Added Bang-bang thermal governor 2014-08-27 15:45:58 +08:00
imx_thermal.c Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal into thermal-soc 2014-12-21 22:49:12 +08:00
intel_powerclamp.c thermal/powerclamp: add ids for future xeon cpus 2014-12-21 21:36:41 +08:00
intel_soc_dts_thermal.c thermal: Intel SoC DTS: Don't do thermal zone update inside spin_lock 2014-12-09 11:38:16 +08:00
Kconfig thermal: rockchip: add driver for thermal 2014-11-24 14:35:07 -04:00
kirkwood_thermal.c thermal: drop owner assignment from platform_drivers 2014-10-20 16:21:42 +02:00
Makefile thermal: rockchip: add driver for thermal 2014-11-24 14:35:07 -04:00
of-thermal.c thermal: of: Extend current of-thermal.c code to allow setting emulated temp 2014-12-08 21:10:00 -04:00
rcar_thermal.c thermal: rcar: remove unnecessary OOM messages 2014-05-15 17:15:26 +08:00
rockchip_thermal.c thermal: drop owner assignment from platform_drivers 2014-12-22 11:05:59 +08:00
spear_thermal.c thermal: drop owner assignment from platform_drivers 2014-10-20 16:21:42 +02:00
step_wise.c Merge branch 'thermal-core-fix' of .git into next 2014-10-11 09:28:13 +08:00
tegra_soctherm.c thermal: of: improve of-thermal sensor registration API 2014-11-20 10:44:54 -04:00
thermal_core.c netlink: make nlmsg_end() and genlmsg_end() void 2015-01-18 01:03:45 -05:00
thermal_core.h thermal: of: Extend of-thermal to export table of trip points 2014-12-08 15:58:01 -04:00
thermal_hwmon.c thermal: hwmon: Make the check for critical temp valid consistent 2014-06-30 10:17:27 +08:00
thermal_hwmon.h thermal: hwmon: move hwmon support to single file 2013-09-03 09:09:12 -04:00
user_space.c Thermal: build thermal governors into thermal_sys module 2013-04-14 23:28:43 +08:00
x86_pkg_temp_thermal.c thermal, x86-pkg-temp: Fix CPU hotplug callback registration 2014-03-20 13:43:47 +01:00