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]
Message-ID: <1412874973.2975.8.camel@joe-AO725>
Date:	Thu, 09 Oct 2014 10:16:13 -0700
From:	Joe Perches <joe@...ches.com>
To:	Tsung-Han Lin <tsunghan.tw@...il.com>
Cc:	gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: rtl8192u: correct coding style errors

On Fri, 2014-10-10 at 01:02 +0800, Tsung-Han Lin wrote:
> Correct some coding style errors in
> drivers/staging/rtl8192u/r819xU_firmware.c.

Generic advice is not to merely shut up checkpatch
complaints, but try to make the code better/more readable.

> diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c
[]
> @@ -37,7 +37,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>  	bool		    rt_status = true;
>  	u16		    frag_threshold;
>  	u16		    frag_length, frag_offset = 0;
> -	//u16		    total_size;
> +	/* u16		    total_size; */

probably better to delete this instead.

> @@ -66,7 +66,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>  		skb  = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4);
>  		if (!skb)
>  			return false;
> -		memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev));
> +		memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));

Unnecessary cast

		memcpy(sk->cb, &dev, sizeof(dev));

> @@ -78,19 +78,19 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address,
>  		 * Transform from little endian to big endian
>  		 * and pending  zero
>  		 */
> -		for (i=0; i < frag_length; i+=4) {
> -			*seg_ptr++ = ((i+0)<frag_length)?code_virtual_address[i+3]:0;
> -			*seg_ptr++ = ((i+1)<frag_length)?code_virtual_address[i+2]:0;
> -			*seg_ptr++ = ((i+2)<frag_length)?code_virtual_address[i+1]:0;
> -			*seg_ptr++ = ((i+3)<frag_length)?code_virtual_address[i+0]:0;
> +		for (i = 0; i < frag_length; i += 4) {
> +			*seg_ptr++ = ((i+0) < frag_length)?code_virtual_address[i+3]:0;
> +			*seg_ptr++ = ((i+1) < frag_length)?code_virtual_address[i+2]:0;
> +			*seg_ptr++ = ((i+2) < frag_length)?code_virtual_address[i+1]:0;
> +			*seg_ptr++ = ((i+3) < frag_length)?code_virtual_address[i+0]:0;

It may be better to create a helper function.
Spaces around ternaries are generally more readable

			*seg_ptr++ = frag_length >= i + 0 ? code_virtual_address[i + 3] : 0;
			*seg_ptr++ = frag_length >= i + 1 ? code_virtual_address[i + 2] : 0;
			*seg_ptr++ = frag_length >= i + 2 ? code_virtual_address[i + 1] : 0;
			*seg_ptr++ = frag_length >= i + 3 ? code_virtual_address[i + 0] : 0;



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