Bug 14237 - dvision of signed and unsigned operators usb_stream.c
Summary: dvision of signed and unsigned operators usb_stream.c
Status: CLOSED WILL_NOT_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(OSS) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_sound
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-26 17:04 UTC by Martin Ettl
Modified: 2012-06-13 17:12 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.31
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Martin Ettl 2009-09-26 17:04:04 UTC
Hello,

i have checked the linux kernel with the static code analysis tool cppcheck. It brought up an issue in file linux-2.6.31/sound/usb/usx2y/usb_stream.c at line 177. Cppcheck printed the following warning:

- dvision of signed and unsigned operators at line 177

Take a look at the code:

struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
				  struct usb_device *dev,
				  unsigned in_endpoint, unsigned out_endpoint,
				  unsigned sample_rate, unsigned use_packsize,
				  unsigned period_frames, unsigned frame_size)
{
	int packets, max_packsize;
	int in_pipe, out_pipe;
	int read_size = sizeof(struct usb_stream);
	int write_size;
	int usb_frames = dev->speed == USB_SPEED_HIGH ? 8000 : 1000;
	int pg;

	in_pipe = usb_rcvisocpipe(dev, in_endpoint);
	out_pipe = usb_sndisocpipe(dev, out_endpoint);

	max_packsize = use_packsize ?
		use_packsize : usb_maxpacket(dev, in_pipe, 0);

	/*
		t_period = period_frames / sample_rate
		iso_packs = t_period / t_iso_frame
			= (period_frames / sample_rate) * (1 / t_iso_frame)
	*/

177	packets = period_frames * usb_frames / sample_rate + 1;
....

Indeed, the tool is right, at line 177 there is a division of signed and unsigned operator. This can lead to undifined behaviour!

Best regards

Martin

Note You need to log in before you can comment on or make changes to this bug.