Re: [PATCH] Staging: arlan: fixed coding style issues in arlan-proc.c This is a patch to the arlan-proc.c file that fixes up multiple coding style errors and warnings found by the checkpatch.pl tool Signed-off-by: Andre Silva <andre.beat@xxxxxxxxx>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2010-03-11 at 02:58 +0000, André Silva wrote:
> From: Andre Silva <andre.beat@xxxxxxxxx>

Hi Andre.

When you send a patch, please use a shorter subject
and add some commentary in the body of the email
that describes the changes before the patch itself.

> ---
>  drivers/staging/arlan/arlan-proc.c |  623 ++++++++++++++++++------------------
>  1 files changed, 306 insertions(+), 317 deletions(-)
> 
> diff --git a/drivers/staging/arlan/arlan-proc.c b/drivers/staging/arlan/arlan-proc.c
> index b22983e..62cd1d0 100644
> --- a/drivers/staging/arlan/arlan-proc.c
> +++ b/drivers/staging/arlan/arlan-proc.c
> @@ -9,48 +9,55 @@ 

What you did here 

From:
#define ARLAN_STR_SIZE 	0x2ff0
#define DEV_ARLAN_INFO 	1
#define DEV_ARLAN 	1

to:
#define ARLAN_STR_SIZE 0x2ff0
#define DEV_ARLAN_INFO 1
#define DEV_ARLAN 1

isn't an improvement.  A lot of code in the kernel uses:

#define NAME		value

using tabs so name is in one column, value another.

> +#define SARLG(type, var) {\
> +	pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var,\
> +		READSHMB(priva->card->var));\
>  	}

This macro isn't nice:

It could be better as:

#define SARLG(type, var)					\
do {								\
	pos += sprintf(arlan_drive_info + pos, "%s\t=\t0x%x\n",	\
		       #var, READSHMG(priva->card->var));	\
} while (0)

or even more simpler:

#define SARLG(type, var)					\
	pos += sprintf(arlan_drive_info + pos, "%s\t=\t0x%x\n",	\
		       #var, READSHMG(priva->card->var))	\

And this:

> +#define SARLBN(type, var, nn) {\
> +	pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x", #var);\
> +	for (i = 0; i < nn; i++)\
> +		pos += sprintf(arlan_drive_info+pos, "%02x",\
> +			READSHMB(priva->card->var[i]));\
> +		pos += sprintf(arlan_drive_info+pos, "\n");\
>  	}

This change is poor as you've made it seem that the last
two sprintfs are in the loop.  Only one is.

I suggest something like:

#define SARLBN(type, var, nn)					\
do {								\
	SARLG(type, var);					\
	for (i = 0; i < nn; i++)				\
		pos += sprintf(arlan_drive_info + pos, "%02x",	\
			       READSHMB(priva->card->var[i]));	\
	pos += sprintf(arlan_drive_info+pos, "\n");		\
}

Another thing you might do is get not use pos as an int,
but instead declare it as a char * starting at arlan_drive_info
so that the macros become:

	pos += sprintf(pos, fmt, args)

cheers, Joe

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux