Skip to contentSkip to conversation

Bluetooth: Fix compiler warning with selftest duration calculation

PATCH Applied Marcel Holtmann 2 participants 2 messages Oct 6, 2017 – Oct 7, 2017

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: Fix compiler warning with selftest duration calculation

CC net/bluetooth/selftest.o
net/bluetooth/selftest.c: In function ‘bt_selftest_init’:
net/bluetooth/selftest.c:246:3: warning: ‘duration’ may be used uninitialized in this function [-Wmaybe-uninitialized]
snprintf(test_ecdh_buffer, sizeof(test_ecdh_buffer), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     "PASS (%llu usecs)\n", duration);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/bluetooth/selftest.c:203:21: note: ‘duration’ was declared here
  unsigned long long duration;
                     ^~~~~~~~
---
 net/bluetooth/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/selftest.c +1 -1
index 2d1519d0affa..03e3c89c3046 100644
@@ -200,7 +200,7 @@ static int __init test_ecdh(void)
 {
 	struct crypto_kpp *tfm;
 	ktime_t calltime, delta, rettime;
-	unsigned long long duration;
+	unsigned long long duration = 0;
 	int err;
 
 	calltime = ktime_get();
Signature · 1 line
2.13.6
#1 lore raw

Hi Marcel,

Quoted 11 lines · Marcel Holtmann

CC net/bluetooth/selftest.o
net/bluetooth/selftest.c: In function ‘bt_selftest_init’:
net/bluetooth/selftest.c:246:3: warning: ‘duration’ may be used uninitialized in this function [-Wmaybe-uninitialized]
snprintf(test_ecdh_buffer, sizeof(test_ecdh_buffer), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     "PASS (%llu usecs)\n", duration);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/bluetooth/selftest.c:203:21: note: ‘duration’ was declared here
  unsigned long long duration;
                     ^~~~~~~~
Quoted 4 lines
---
 net/bluetooth/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to bluetooth-next. Thanks.

Johan