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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1434955662.9808.26.camel@perches.com>
Date:	Sun, 21 Jun 2015 23:47:42 -0700
From:	Joe Perches <joe@...ches.com>
To:	Krzysztof Hałasa <khalasa@...p.pl>
Cc:	Frans Klaver <fransklaver@...il.com>,
	Andy Whitcroft <apw@...onical.com>,
	lkml <linux-kernel@...r.kernel.org>
Subject: Re: Coding style details (checkpatch)

On Mon, 2015-06-22 at 08:38 +0200, Krzysztof Hałasa wrote:
> Joe Perches <joe@...ches.com> writes:
> 
> > It might be better to use some base + index macro
> > as it could be smaller object code.
> >
> > Something like:
> >
> > #define REG_NO(base, multiplier, index)	(base + (multiplier * index))
> >
> > 	reg_write(vc->dev, REG_NO(0x10, 1, vc->ch), dma_cfg);
> > or
> >
> > #define VDMA_CHANNEL_CONFIG	0x10
> >
> > 	reg_write(vc->dev, REG_NO(VDMA_CHANNEL_CONFIG, 1, vc->ch), dma_cfg);
> 
> Wouldn't work, the register map is a bit messy.
> E.g.
> 
> #define DMA_PAGE_TABLE0_ADDR    ((const u16[8]){0x08, 0xD0, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA, 0xDC})
> #define DMA_PAGE_TABLE1_ADDR    ((const u16[8]){0x09, 0xD1, 0xD3, 0xD5, 0xD7, 0xD9, 0xDB, 0xDD})

Erk, yes, a bit messy.

You could elide the 8 and checkpatch wouldn't emit a warning.

#define VDREG8(a0) ((const u16[]){			\
	a0 + 0x000, a0 + 0x010, a0 +0x020, a0 + 0x030,	\
	a0 + 0x100, a0 + 0x110, a0 +0x120, a0 + 0x130})

as "const u16[]" is a $Type but "const u16[<digits>]" is not.

Still, as written, the code seems fragile as MACRO[index]
allows index to be any value, maybe larger than the array.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ