diff mbox series

[BlueZ] shared: Fix the incorrect type with bit shift

Message ID 20220217063145.50497-1-hj.tedd.an@gmail.com (mailing list archive)
State Accepted
Commit 840ca1e7f1aa7faf61b4aa4f5a8ff2818c06885e
Headers show
Series [BlueZ] shared: Fix the incorrect type with bit shift | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint fail [BlueZ] shared: Fix the incorrect type with bit shift 9: B1 Line exceeds max length (114>80): " src/shared/btsnoop.c:339:18: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int'"
tedd_an/setupell success Setup ELL PASS
tedd_an/buildprep success Build Prep PASS
tedd_an/build success Build Configuration PASS
tedd_an/makecheck success Make Check PASS
tedd_an/makecheckvalgrind success Make Check PASS
tedd_an/makedistcheck success Make Distcheck PASS
tedd_an/build_extell success Build External ELL PASS
tedd_an/build_extell_make success Build Make with External ELL PASS

Commit Message

Tedd Ho-Jeong An Feb. 17, 2022, 6:31 a.m. UTC
From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch fixes the following runtime error:

$ sudo ./monitor/btmon -w test.btsnoop
  Bluetooth monitor ver 5.63
  src/shared/btsnoop.c:339:18: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int'
---
 src/shared/btsnoop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com Feb. 17, 2022, 8 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=615253

---Test result---

Test Summary:
CheckPatch                    PASS      0.52 seconds
GitLint                       FAIL      0.37 seconds
Prep - Setup ELL              PASS      49.17 seconds
Build - Prep                  PASS      0.59 seconds
Build - Configure             PASS      9.06 seconds
Build - Make                  PASS      1702.34 seconds
Make Check                    PASS      12.60 seconds
Make Check w/Valgrind         PASS      502.72 seconds
Make Distcheck                PASS      259.75 seconds
Build w/ext ELL - Configure   PASS      9.78 seconds
Build w/ext ELL - Make        PASS      1660.32 seconds
Incremental Build with patchesPASS      0.00 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint with rule in .gitlint
Output:
[BlueZ] shared: Fix the incorrect type with bit shift
9: B1 Line exceeds max length (114>80): "  src/shared/btsnoop.c:339:18: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int'"




---
Regards,
Linux Bluetooth
Marcel Holtmann Feb. 17, 2022, 9:55 a.m. UTC | #2
Hi Tedd,

> This patch fixes the following runtime error:
> 
> $ sudo ./monitor/btmon -w test.btsnoop
>  Bluetooth monitor ver 5.63
>  src/shared/btsnoop.c:339:18: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int'

what compiler version is this? Or what warnings did you enable? Since this is weird, so while yes 0xffff can not be shifted, but we are also not shifting into an uint16_t. The fix is fine, I am just curious. There will be other places with the same problem.

Regards

Marcel
Tedd Ho-Jeong An Feb. 17, 2022, 4:36 p.m. UTC | #3
Hi Marcel,

On Thu, 2022-02-17 at 10:55 +0100, Marcel Holtmann wrote:
> Hi Tedd,
> 
> > This patch fixes the following runtime error:
> > 
> > $ sudo ./monitor/btmon -w test.btsnoop
> >  Bluetooth monitor ver 5.63
> >  src/shared/btsnoop.c:339:18: runtime error: left shift of 65535 by 16 places cannot be represented in type 'int'
> 
> what compiler version is this? Or what warnings did you enable? Since this is weird, so while yes 0xffff can not be shifted, but we are also not shifting into an uint16_t. The fix is fine, I am just
> curious. There will be other places with the same problem.

I am using gcc 9.3.0 came with Ubuntu 20.04.
This is enabled by the "-fsanitize=undefined" option.

Recent change enabled LSAN, ASAN, and UBSAN by default.


> 
> Regards
> 
> Marcel
>
diff mbox series

Patch

diff --git a/src/shared/btsnoop.c b/src/shared/btsnoop.c
index a29bc928f..0a68282bc 100644
--- a/src/shared/btsnoop.c
+++ b/src/shared/btsnoop.c
@@ -336,7 +336,7 @@  bool btsnoop_write_hci(struct btsnoop *btsnoop, struct timeval *tv,
 		break;
 
 	case BTSNOOP_FORMAT_MONITOR:
-		flags = (index << 16) | opcode;
+		flags = ((uint32_t)index << 16) | opcode;
 		break;
 
 	default: