shared: Fix the incorrect type with bit shift
PATCH 1/1 shared: Fix the incorrect type with bit shift
From: Tedd Ho-Jeong An <[email protected]>
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(-)
src/shared/btsnoop.c +1 -1
@@ -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 :
Signature · 1 line
2.25.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
maintainerHi Tedd,
Quoted 5 lines
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
Hi Marcel,
Quoted 10 lines · Marcel Holtmann
Hi Tedd,
Quoted 5 lines
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
0xffffcan not be shifted, but we are also not shifting into anuint16_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.
Quoted 5 lines
Regards
Marcel