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]
Message-ID: <Pine.LNX.4.64.1107281211120.20737@axis700.grange>
Date:	Thu, 28 Jul 2011 12:16:04 +0200 (CEST)
From:	Guennadi Liakhovetski <g.liakhovetski@....de>
To:	Bernd Petrovitsch <bernd@...rovitsch.priv.at>
cc:	linux-kernel@...r.kernel.org
Subject: Re: [Q] compiler no longer warning about undeclared struct?

On Thu, 28 Jul 2011, Bernd Petrovitsch wrote:

> Hi!
> 
> On Mit, 2011-07-27 at 19:57 +0200, Guennadi Liakhovetski wrote:
> [....]
> > I just ran across a driver in the kernel (drivers/media/video/ov2640.c, 
> > struct ov2640_priv::info), that does something like
> > 
> > struct xx {
> > 	struct yy *y;
> > };
> > 
> > static void z(void)
> > {
> > 	struct xx *x;
> > 	void *p;
> > 
> > 	x = ...;
> > 	p = ...;
> > 	x->y = p;
> > }
> > 
> > where "struct yy" is nowhere declared, and the compiler happily swallows 
> > this... Shouldn't it complain? Didn't it complain before?
> 
> It's normal C behaviour: As long as the compiler doesn't need the size
> or fields of struct yy, it doesn't complain that it doesn't know the
> details.

I always thought you need forward declarations for those, as in

struct yy;

before declaring struct xx above.

> Otherwise you could not define recursive structures as in
> ----  snip  ----
> struct a {
> 	struct *b;
> };
> struct b {
> 	struct *a;
> };
> ----  snip  ----

I would add a "struct b;" forward declaration before "struct a".

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
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