linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BlueZ PATCH] shared: Fix the incorrect type with bit shift
@ 2022-02-17  6:31 Tedd Ho-Jeong An
  2022-02-17  8:00 ` [BlueZ] " bluez.test.bot
  2022-02-17  9:55 ` [BlueZ PATCH] " Marcel Holtmann
  0 siblings, 2 replies; 4+ messages in thread
From: Tedd Ho-Jeong An @ 2022-02-17  6:31 UTC (permalink / raw)
  To: linux-bluetooth

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(-)

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:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [BlueZ] shared: Fix the incorrect type with bit shift
  2022-02-17  6:31 [BlueZ PATCH] shared: Fix the incorrect type with bit shift Tedd Ho-Jeong An
@ 2022-02-17  8:00 ` bluez.test.bot
  2022-02-17  9:55 ` [BlueZ PATCH] " Marcel Holtmann
  1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2022-02-17  8:00 UTC (permalink / raw)
  To: linux-bluetooth, hj.tedd.an

[-- Attachment #1: Type: text/plain, Size: 1316 bytes --]

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BlueZ PATCH] shared: Fix the incorrect type with bit shift
  2022-02-17  6:31 [BlueZ PATCH] shared: Fix the incorrect type with bit shift Tedd Ho-Jeong An
  2022-02-17  8:00 ` [BlueZ] " bluez.test.bot
@ 2022-02-17  9:55 ` Marcel Holtmann
  2022-02-17 16:36   ` Tedd Ho-Jeong An
  1 sibling, 1 reply; 4+ messages in thread
From: Marcel Holtmann @ 2022-02-17  9:55 UTC (permalink / raw)
  To: Tedd Ho-Jeong An; +Cc: BlueZ

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BlueZ PATCH] shared: Fix the incorrect type with bit shift
  2022-02-17  9:55 ` [BlueZ PATCH] " Marcel Holtmann
@ 2022-02-17 16:36   ` Tedd Ho-Jeong An
  0 siblings, 0 replies; 4+ messages in thread
From: Tedd Ho-Jeong An @ 2022-02-17 16:36 UTC (permalink / raw)
  To: Marcel Holtmann, Tedd Ho-Jeong An; +Cc: BlueZ

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
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-17 16:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17  6:31 [BlueZ PATCH] shared: Fix the incorrect type with bit shift Tedd Ho-Jeong An
2022-02-17  8:00 ` [BlueZ] " bluez.test.bot
2022-02-17  9:55 ` [BlueZ PATCH] " Marcel Holtmann
2022-02-17 16:36   ` Tedd Ho-Jeong An

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).