From: Joe Perches <joe@perches.com>
To: "André Silva" <andre.beat@gmail.com>
Cc: gregkh@suse.de, linville@tuxdriver.com,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: 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@gmail.com>
Date: Wed, 10 Mar 2010 19:28:10 -0800 [thread overview]
Message-ID: <1268278090.1674.37.camel@Joe-Laptop.home> (raw)
In-Reply-To: <1268276306-14324-1-git-send-email-andre.beat@gmail.com>
On Thu, 2010-03-11 at 02:58 +0000, André Silva wrote:
> From: Andre Silva <andre.beat@gmail.com>
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
next prev parent reply other threads:[~2010-03-11 3:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 2:58 André Silva
2010-03-11 3:28 ` Joe Perches [this message]
2010-03-11 3:32 ` Greg KH
2010-03-11 4:40 ` Joe Perches
2010-03-11 7:09 ` [PATCH] Staging: arlan: fixed coding style issues in arlan-proc.c (etc...) Frans Pop
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1268278090.1674.37.camel@Joe-Laptop.home \
--to=joe@perches.com \
--cc=andre.beat@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®