Bluetooth: Fix false-positive "uninitialized" compiler warning
authorJohan Hedberg <johan.hedberg@intel.com>
Wed, 3 Dec 2014 14:26:37 +0000 (16:26 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 3 Dec 2014 15:51:22 +0000 (16:51 +0100)
commit580039e838a7efaee0048b0857d1bb5582327aa5
tree5378a8290cbe54b9d22b71bcba9c89fc166f0645
parent7f376cd6dc1c9bfd14514c70765e6900a961c4b8
Bluetooth: Fix false-positive "uninitialized" compiler warning

Some gcc versions don't seem to be able to properly track the flow of
the smp_cmd_pairing_random() function and end up causing the following
types of (false-positive) warnings:

 smp.c:1995:6: warning: ‘nb’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey);
 smp.c:1995:6: warning: ‘na’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey);
       ^
 smp.c:1995:6: warning: ‘pkbx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey);
       ^
 smp.c:1995:6: warning: ‘pkax’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   err = smp_g2(smp->tfm_cmac, pkax, pkbx, na, nb, &passkey);

This patch fixes the issue by moving the pkax/pkbx and na/nb
initialization earlier in the function.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/smp.c