[erlang-patches] Fix spec for cpu_sup:util/1

Andrew Caruth Andrew.Caruth@REDACTED
Wed Dec 4 15:38:13 CET 2013


Hi OTP devs,

I recently noticed dialyzer was flagging an issue in one of our own modules that was making a call to cpu_sup:util([detailed]). An 'is_list()' guard test was performed on the second element of the tuple returned which dialyzer was reporting as a test that could never succeed. Sample output from a call to cpu_sup:util([detailed]):

{[0],
 [{soft_irq,0.0},
  {hard_irq,0.0},
  {kernel,0.41368935690109065},
  {nice_user,0.0},
  {user,0.9402030838661151}],
 [{steal,0.0},{idle,98.64610755923279},{wait,0.0}],
 []}

The spec implied {'all' | integer | list, tuple | float, tuple | float, []}, which excludes the above output, so I've updated the spec to allow the second and third elements as lists.

Also, the atoms 'soft_irq', 'hard_irq', and 'steal' were also not part of the spec, so I've also added those.

git fetch git://github.com/acaruth/otp.git cpu_sup_spec_fix
https://github.com/acaruth/otp/compare/erlang:maint...cpu_sup_spec_fix
https://github.com/acaruth/otp/compare/erlang:maint...cpu_sup_spec_fix.patch

Thanks,
Andrew Caruth



More information about the erlang-patches mailing list