parport: Standardize use of printmode

[ Upstream commit a6abfdff4fe5dd19d1f1b37d72ba34cd4492fd4d ]

Standardize the define and the uses of printmode.

Miscellanea:

o Add missing statement termination ; where necessary

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Link: https://lore.kernel.org/r/20200403134325.11523-8-sudipm.mukherjee@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Stable-dep-of: ab11dac93d2d ("dev/parport: fix the array out-of-bounds risk")
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 884ab25dbf115938facb91be85ffed9266e26f8b)
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
This commit is contained in:
Joe Perches 2020-04-03 14:43:22 +01:00 committed by Vegard Nossum
parent af0192bb58
commit 4582fe6f2d
3 changed files with 17 additions and 11 deletions

View File

@ -304,12 +304,16 @@ struct parport *parport_gsc_probe_port(unsigned long base,
p->dma = PARPORT_DMA_NONE;
pr_cont(" [");
#define printmode(x) {if(p->modes&PARPORT_MODE_##x){pr_cont("%s%s",f?",":"",#x);f++;}}
#define printmode(x) \
do { \
if (p->modes & PARPORT_MODE_##x) \
pr_cont("%s%s", f++ ? "," : "", #x); \
} while (0)
{
int f = 0;
printmode(PCSPP);
printmode(TRISTATE);
printmode(COMPAT)
printmode(COMPAT);
printmode(EPP);
// printmode(ECP);
// printmode(DMA);

View File

@ -2142,19 +2142,17 @@ struct parport *parport_pc_probe_port(unsigned long int base,
pr_cont(" [");
#define printmode(x) \
{\
if (p->modes & PARPORT_MODE_##x) {\
pr_cont("%s%s", f ? "," : "", #x); \
f++;\
} \
}
#define printmode(x) \
do { \
if (p->modes & PARPORT_MODE_##x) \
pr_cont("%s%s", f++ ? "," : "", #x); \
} while (0)
{
int f = 0;
printmode(PCSPP);
printmode(TRISTATE);
printmode(COMPAT)
printmode(COMPAT);
printmode(EPP);
printmode(ECP);
printmode(DMA);

View File

@ -213,7 +213,11 @@ static int do_hardware_modes(struct ctl_table *table, int write,
return -EACCES;
{
#define printmode(x) {if(port->modes&PARPORT_MODE_##x){len+=sprintf(buffer+len,"%s%s",f?",":"",#x);f++;}}
#define printmode(x) \
do { \
if (port->modes & PARPORT_MODE_##x) \
len += sprintf(buffer + len, "%s%s", f++ ? "," : "", #x); \
} while (0)
int f = 0;
printmode(PCSPP);
printmode(TRISTATE);