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]
Date:	Wed, 16 Dec 2009 09:06:53 +0100
From:	Pavel Machek <pavel@....cz>
To:	Emese Revfy <re.emese@...il.com>
Cc:	Arjan van de Ven <arjan@...radead.org>,
	Paul Mundt <lethal@...ux-sh.org>,
	Matthew Wilcox <matthew@....cx>, linux-kernel@...r.kernel.org,
	torvalds@...ux-foundation.org, viro@...iv.linux.org.uk,
	akpm@...ux-foundation.org
Subject: Re: [PATCH 0/1] Constify struct address_space_operations for
 2.6.32-git-053fe57ac v2

Hi!

> > One const in structure declaration seems to be just enough, see:
> > 
> > const struct a {
> > 	void (* f)(void);
> > 	void (* const g)(void);
> > } s;
> > 
> > void h(void)
> > {
> > 	struct a *p = &s;
> > 	s.f = 0;
> > 	s.g = 0;
> > 	p->f = 0;
> > 	p->g = 0;
> > }
> > 
> > 
> > delme.c: In function 'h':
> > delme.c:8: warning: initialization discards qualifiers from pointer target type
> > delme.c:9: error: assignment of read-only variable 's'
> > delme.c:10: error: assignment of read-only variable 's'
> > delme.c:12: error: assignment of read-only member 'g'
> > 
> > You get clean-enough warnings.
> 
> Notice how you got an error for line 12 (p->g assignment) but no warning or error
> at all for line 11 (p->f assignment). This example illustrates what I was explaining
> so far:

And notice how you get warning for line 8? That's what I'm talking
about, and it should be enough to make the developer think about what
he's doing. 
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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