lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 9 Mar 2011 17:37:36 +0200
From:	Roger Quadros <roger.quadros@...ia.com>
To:	ext Alan Stern <stern@...land.harvard.edu>
CC:	<gregkh@...e.de>, <linux-usb@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] usb: gadget: storage: Add fsg_get_toc helper

On 03/09/2011 05:10 PM, ext Alan Stern wrote:

>> +	case 2:
>> +		/* Raw TOC */
>> +		memset(buf, 0, 37);	/* Header + A0, A1&  A2 descriptors */
>> +		buf[1] = 37;		/* 4 + 3*11 */
>
> There's no reason to do it this way.  The compiler is a lot better than
> you are at addition.  Just put 4 + 3*11 in the assignment statement,
> and in the comment explain what the numbers mean.

OK.

>
>> +		buf[2] = 1;		/* First complete session */
>> +		buf[3] = 2;		/* Last complete session */
>> +
>> +		buf += 4;
>> +		/* A0 point */
>> +		buf[0] = 1;		/* Session number */
>> +		buf[1] = 0x16;		/* Data track, copying alowed */
>> +		/* 2 - Track number 0 ->  TOC */
>> +		buf[3] = 0xA0;		/* Point A0 */
>> +		/* 4, 5, 6 - Min, sec, frame is zero */
>> +		/* 7 - zero */
>> +		buf[8] = 1;		/* Pmin: 1st track number */
>> +		/* 9 - disc type 0: CD-ROM/DA with 1st track in mode 1 */
>> +		/* 10 - pframe 0 */
>> +
>> +		buf += 11;
>> +		/* A1 point*/
>> +		buf[0] = 1;		/* Session number */
>> +		buf[1] = 0x16;		/* Data track, copying alowed */
>> +		/* 2 - Track number 0 ->  TOC */
>> +		buf[3] = 0xA1;		/* Point A1 */
>> +		/* 4, 5, 6 - Min, sec, frame is zero */
>> +		/* 7, zero */
>> +		buf[8] = 1;		/* Pmin: last track number */
>> +		/* 9, 10 - pmin and pframe are 0 */
>> +
>> +		buf += 11;
>> +		/* A2 point*/
>> +		buf[0] = 1;		/* Session number */
>> +		buf[1] = 0x16;		/* Data track, copying alowed */
>> +		/* 2 - Track number 0 ->  TOC */
>> +		buf[3] = 0xA2;		/* Point A2 */
>> +		/* 4, 5, 6 - Min, sec, frame is zero */
>> +		/* 7, 8, 9, 10 - zero, Pmin, Psec, Pframe of Lead out */
>> +		store_cdrom_address(&buf[7], msf, curlun->num_sectors);
>
> These things could be put into a loop, instead of a separate function.

Yes loop is better than function for this case.

>
>> +		return 37;
>
> It might be a good idea to use a variable instead of having all these
> "37"s floating around.  It would make future updates more reliable.

OK.

-- 
regards,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ