Skip to contentSkip to conversation

drivers/usb/gadget/serial.c:89:22: sparse: cast truncates bits from constan

PATCH In review Fengguang Wu 2 participants 3 messages Sep 10, 2012 – Sep 11, 2012 1 message not in the archive Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 33/36 drivers/usb/gadget/serial.c:89:22: sparse: cast truncates bits from constan

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git master
head:   d9c88901337158c9f253a7de58a10b5125d61d26
commit: 7a7322b0a5d984025dd4faea9098b8fef07f8d8f [33/36] usb: gadget: remove usb_gadget_controller_number()

All sparse warnings:

drivers/usb/gadget/f_acm.c:287:9: sparse: advancing past deep designator drivers/usb/gadget/f_obex.c:60:9: sparse: advancing past deep designator drivers/usb/gadget/f_serial.c:134:9: sparse: advancing past deep designator drivers/usb/gadget/serial.c:66:9: sparse: advancing past deep designator
+ drivers/usb/gadget/serial.c:89:22: sparse: cast truncates bits from constant value (24000000 becomes 0)

vim +89 drivers/usb/gadget/serial.c

    79	static struct usb_device_descriptor device_desc = {
    80		.bLength =		USB_DT_DEVICE_SIZE,
    81		.bDescriptorType =	USB_DT_DEVICE,
    82		.bcdUSB =		cpu_to_le16(0x0200),
    83		/* .bDeviceClass = f(use_acm) */
    84		.bDeviceSubClass =	0,
    85		.bDeviceProtocol =	0,
    86		/* .bMaxPacketSize0 = f(hardware) */
    87		.idVendor =		cpu_to_le16(GS_VENDOR_ID),
    88		/* .idProduct =	f(use_acm) */
Quoted 1 line

89 .bcdDevice = cpu_to_le16(GS_VERSION_NUM << 16),

    90		/* .iManufacturer = DYNAMIC */
    91		/* .iProduct = DYNAMIC */
    92		.bNumConfigurations =	1,
    93	};
    94	
    95	static struct usb_otg_descriptor otg_descriptor = {
    96		.bLength =		sizeof otg_descriptor,
    97		.bDescriptorType =	USB_DT_OTG,
    98	
    99		/* REVISIT SRP-only hardware is possible, although

---
0-DAY kernel build testing backend Open Source Technology Centre
Fengguang Wu <[email protected]> Intel Corporation

#1 lore raw

Re: [balbi-usb:master 33/36] drivers/usb/gadget/serial.c:89:22: sparse: cast truncates bits from con

Quoted 5 lines · Fengguang Wu
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git master
head:   d9c88901337158c9f253a7de58a10b5125d61d26
commit: 7a7322b0a5d984025dd4faea9098b8fef07f8d8f [33/36] usb: gadget: remove usb_gadget_controller_number()

All sparse warnings:

Once again, thank you.

Quoted 4 lines

drivers/usb/gadget/f_acm.c:287:9: sparse: advancing past deep designator drivers/usb/gadget/f_obex.c:60:9: sparse: advancing past deep designator drivers/usb/gadget/f_serial.c:134:9: sparse: advancing past deep designator drivers/usb/gadget/serial.c:66:9: sparse: advancing past deep designator

I don't get these. The purpose is an all NULL terminating entry. Could this be a sparse bug or is the [] / {} switch not really good C code?

Quoted 1 line

+ drivers/usb/gadget/serial.c:89:22: sparse: cast truncates bits from constant value (24000000 becomes 0)

I've sent a patch for this.

Sebastian

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Re: [balbi-usb:master 33/36] drivers/usb/gadget/serial.c:89:22: sparse: cast truncates bits from con

Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 5 lines · Fengguang Wu
tree:   git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git master
head:   d9c88901337158c9f253a7de58a10b5125d61d26
commit: 7a7322b0a5d984025dd4faea9098b8fef07f8d8f [33/36] usb: gadget: remove usb_gadget_controller_number()

All sparse warnings:

Once again, thank you.

You are welcome!

Quoted 7 lines
Quoted 4 lines

drivers/usb/gadget/f_acm.c:287:9: sparse: advancing past deep designator drivers/usb/gadget/f_obex.c:60:9: sparse: advancing past deep designator drivers/usb/gadget/f_serial.c:134:9: sparse: advancing past deep designator drivers/usb/gadget/serial.c:66:9: sparse: advancing past deep designator

I don't get these. The purpose is an all NULL terminating entry. Could this be a sparse bug or is the [] / {} switch not really good C code?

http://marc.info/?l=linux-sparse&m0673652023059&w=4

According to Dan's explanations, I'll filter out these warnings in future.

Quoted 3 lines
Quoted 1 line

+ drivers/usb/gadget/serial.c:89:22: sparse: cast truncates bits from constant value (24000000 becomes 0)

I've sent a patch for this.

Thank you!

Fengguang